Fix image alias creation

The add_alias method requires two arguments, a name and description.
Also ensure that the image alias does not already exist before
attempting to upload the image.

Closes-Bug: 1641345
Change-Id: I26dd4328aae5594a52c88ea00bfa3594a0ae617e
This commit is contained in:
Jimmy McCrory 2016-11-12 11:50:16 -08:00
parent 42ed04c572
commit ccae5dcec4
1 changed files with 2 additions and 2 deletions

View File

@ -1260,7 +1260,7 @@ class LXDDriver(driver.ComputeDriver):
external=True):
try:
self.client.images.get(instance.name)
self.client.images.get_by_alias(instance.image_ref)
return
except lxd_exceptions.LXDAPIException as e:
if e.response.status_code != 404:
@ -1381,7 +1381,7 @@ class LXDDriver(driver.ComputeDriver):
fingerprint = hashlib.sha256(
meta_fd.read() + rootfs_fd.read()).hexdigest()
image = self.client.images.get(fingerprint)
image.add_alias(instance.image_ref)
image.add_alias(instance.image_ref, image_meta.name)
except Exception as ex:
with excutils.save_and_reraise_exception:
LOG.error(