Fix create_image_snapshot

This method from novaclient returns an image id, not an object
as was apparently assumed.  Before returning, perform an image
lookup so that we can return a Bunch() object of the image.

Note that if the provider does not immediately make an image
available for lookups, this will fail and the user will have
no record of the image id.  Notably, because it worked with
the image_id until the image was built, nodepool was not suceptible
to this problem.  I am unsure whether there are any clouds that
might behave in this way.  However, this code matches what we do
in shade with servers.

Change-Id: Icaff5d8e66a2458817fcbced16014efbc5ff33b8
This commit is contained in:
James E. Blair
2015-10-02 16:05:06 -07:00
parent 3e4bcd0a6c
commit d3b17d1403

View File

@@ -1408,11 +1408,9 @@ class OpenStackCloud(object):
return None
def create_image_snapshot(self, name, server, **metadata):
image = self.manager.submitTask(_tasks.ImageSnapshotCreate(
image_name=name, server=server, metadata=metadata))
if image:
return meta.obj_to_dict(image)
return None
image_id = str(self.manager.submitTask(_tasks.ImageSnapshotCreate(
image_name=name, server=server, metadata=metadata)))
return self.get_image(image_id)
def delete_image(self, name_or_id, wait=False, timeout=3600):
image = self.get_image(name_or_id)