pyrax
pyrax copied to clipboard
create_image function returns a string
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)
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.