Don't fail on trying to delete non-existant images
This currently throws an attribute exception, which is definitely not the right choice. Change-Id: I2e08ce9f46f4fa8ec1d42508efb16a014d485850
This commit is contained in:
parent
e545865f8f
commit
6996f2329e
@ -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.
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user