diff --git a/releasenotes/notes/false-not-attribute-error-49484d0fdc61f75d.yaml b/releasenotes/notes/false-not-attribute-error-49484d0fdc61f75d.yaml new file mode 100644 index 000000000..e474e0266 --- /dev/null +++ b/releasenotes/notes/false-not-attribute-error-49484d0fdc61f75d.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - delete_image used to fail with an AttributeError if an invalid image + name or id was passed, rather than returning False which was the + intent. This is worthy of note because it's a behavior change, but the + previous behavior was a bug. diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 581e93b82..8d3dc4cb5 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -2820,6 +2820,8 @@ class OpenStackCloud(_normalize.Normalizer): self, name_or_id, wait=False, timeout=3600, delete_objects=True): image = self.get_image(name_or_id) + if not image: + return False with _utils.shade_exceptions("Error in deleting image"): # Note that in v1, the param name is image, but in v2, # it's image_id @@ -2843,7 +2845,8 @@ class OpenStackCloud(_normalize.Normalizer): "Timeout waiting for the image to be deleted."): self._get_cache(None).invalidate() if self.get_image(image.id) is None: - return + break + return True def _get_name_and_filename(self, name): # See if name points to an existing file