Пример #1
0
def make_a_website(cf, dns, siteName, contName, indexFileContents, 
                 indexFileName):
  """Create a simple website on CloudFiles using specified content

  Create a new, randomly named, public, CloudFiles container

  Upload the specified file (or a default, if not specified) to the new
  CloudFiles container.

  Set the "Index Page" on the Container to be the uploaded file.

  Create a DNS CNAME record for the specified name pointing to the CDN URL
  of the new CloudFiles container.
  """

  # Create a new, public container 
  cont = cf.create_container(contName)
  print "New Container:", cont.name
  cf.make_container_public(cont)

  # Store index file contents in a new object 
  indexObj = cf.store_object(cont, indexFileName, indexFileContents)

  # Make this new image the "index page" for the container
  cf.set_container_web_index_page(cont, indexFileName)

  c4.create_dns_record(dns, siteName, cont.cdn_uri.lstrip('http://'), 'CNAME')
  print "Done!"
  c1.print_servers_info(servers)

  #Create CBS volumes and attach to servers
  for srv in servers:
    volname = "%s-vol" % srv.name
    print "Creating Block Storage Volume %s of size %d" % (volname, 
                                                           args.volumesize)
    vol = cbs.create(name=volname, size=args.volumesize, volume_type="SATA")
    print "Attaching volume %s to server %s" % (volname, srv.name)
    vol.attach_to_instance(srv, mountpoint='/dev/xvdd')

  #Create LB, with server nodes 
  if not args.lbname:
    LBName = '%s-LB' % args.FQDN
  else:
    LBName = args.lbname
  print "Creating Loadbalancer %s" % LBName
  lb = c7.create_lb_and_add_servers(clb, LBName, servers)
  c10.wait_for_lb_build(lb)

  #install ssl cert/key on LB
  print "Applying SSL certificate to Loadbalancer\n" 
  lb.add_ssl_termination(securePort=443, enabled=True, secureTrafficOnly=False,
                         certificate=cert, privatekey=key)

  # create DNS entries for the LB
  c4.create_dns_record(dns, args.FQDN, lb.virtual_ips[0].address, 'A')
  print "\nDone!\n"

# vim: ts=2 sw=2 tw=78 expandtab
Пример #3
0
    pyrax.set_credential_file(credential_file)
    if c1.is_valid_region(args.region, "compute"):
        cs = pyrax.connect_to_cloudservers(region=args.region)
        dns = pyrax.connect_to_cloud_dns(region=args.region)
    else:
        print "The region you requested is not valid: %s" % args.region
        sys.exit(2)

    # unbuffer stdout for pretty output
    sys.stdout = os.fdopen(sys.stdout.fileno(), "w", 0)

    if not c4.is_valid_hostname(args.FQDN):
        print "This does not appear to be a valid host name: %s" % args.FQDN
        sys.exit(2)
    if not c1.is_valid_image(cs, args.image):
        print "This does not appear to be a valid image-uuid: %s" % args.image
        sys.exit(3)
    if not c1.is_valid_flavor(cs, args.flavor):
        print "This does not appear to be a valid flavor-id: %s" % args.flavor
        sys.exit(4)

    servers = c1.build_some_servers(cs, args.flavor, args.image, args.FQDN, 1)
    c1.wait_for_server_networks(servers)
    c1.print_servers_info(servers)
    pubIPv4 = cloud_server_public_ipv4(servers[0])
    c4.create_dns_record(dns, args.FQDN, pubIPv4, "A")
    pubIPv6 = cloud_server_public_ipv6(servers[0])
    c4.create_dns_record(dns, args.FQDN, pubIPv6, "AAAA")

# vim: ts=2 sw=2 tw=78 expandtab