From ccae5dcec47b956316ac0ea382e991e7b82868df Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Sat, 12 Nov 2016 11:50:16 -0800 Subject: [PATCH] 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 --- nova/virt/lxd/driver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/virt/lxd/driver.py b/nova/virt/lxd/driver.py index a277f51f..9b3b9609 100644 --- a/nova/virt/lxd/driver.py +++ b/nova/virt/lxd/driver.py @@ -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(