Permalink
Browse files

For loop for server creation completed

  • Loading branch information...
1 parent bd98b4c commit aa212e15678a6f1226ad73010d50c69432639b1a @madasi committed Apr 10, 2013
Showing with 5 additions and 3 deletions.
  1. +5 −3 challenge1.py
View
@@ -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

0 comments on commit aa212e1

Please sign in to comment.