pyrax icon indicating copy to clipboard operation
pyrax copied to clipboard

create_image function returns a string

Open stevekaten opened this issue 11 years ago • 1 comments

Example:

image_id =  cs.servers.create_image(server, "NAME")
pyrax.utils.wait_until(image, "status", "ACTIVE", interval=10, attempts=30)

The wait_until function requires an object. The create_image function returns a string. This requires another request to get the object just to use wait_until:

image_id =  cs.servers.create_image(server, "NAME")
image = cs.images.get(image_id)
pyrax.utils.wait_until(image, "status", "ACTIVE", interval=10, attempts=30)

stevekaten avatar Dec 05 '14 03:12 stevekaten

Unfortunately, that's a result of the dependency on novaclient. You can work around it like this:

image_id =  cs.servers.create_image(server, "NAME")
image_obj = cs.images.get(image_id)
pyrax.utils.wait_until(image, "status", ["ACTIVE", "ERROR"], interval=10, attempts=30)

Note that I added a second condition to the wait_until call; image creation fails sometimes, and you always want to be able to handle that condition, too.

EdLeafe avatar Dec 05 '14 13:12 EdLeafe