Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

For loop for server creation completed

  • Loading branch information...
commit aa212e15678a6f1226ad73010d50c69432639b1a 1 parent bd98b4c
@madasi authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 challenge1.py
View
8 challenge1.py
@@ -28,14 +28,16 @@
pyrax.set_credential_file(os.path.expanduser('~/.rackspace_cloud_credentials'))
cs = pyrax.cloudservers
+name = "dev_{0:02d}"
my_image = [img for img in cs.images.list()
if "CentOS 6.3" in img.name][0]
flavor_512 = [flavor for flavor in cs.flavors.list()
if flavor.ram == 512][0]
my_servers=[]
-my_servers.append(cs.servers.create("dev1", my_image.id, flavor_512.id))
-my_servers.append(cs.servers.create("dev2", my_image.id, flavor_512.id))
-my_servers.append(cs.servers.create("dev3", my_image.id, flavor_512.id))
+for i in range(1,4):
+ servername = name.format(i)
+ my_servers.append(cs.servers.create(servername, my_image.id, flavor_512.id))
+
for server in my_servers:
print "Server ", server.name, " -- Password: ", server.adminPass, " -- Network: ", server.networks
Please sign in to comment.
Something went wrong with that request. Please try again.