From: Thanh Ha Date: Sat, 9 Jun 2018 18:18:03 +0000 (-0400) Subject: Ignore protected images that are protected X-Git-Tag: v0.14.0~14 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=051b5486ec41d1b901be59bd07c0150878f97a19;p=releng%2Flftools.git Ignore protected images that are protected Print a warning to inform the caller that we cannot delete images that are protected. Change-Id: I236f6f55964f483016500b58cbeb48fd8665b62b Signed-off-by: Thanh Ha --- diff --git a/lftools/openstack/image.py b/lftools/openstack/image.py index 8b2a77f2..5ca92592 100644 --- a/lftools/openstack/image.py +++ b/lftools/openstack/image.py @@ -66,6 +66,10 @@ def cleanup(os_cloud, days=0, hide_public=False, ci_managed=True, clouds=None): def _remove_images_from_cloud(images, cloud): print('Removing {} images from {}.'.format(len(images), cloud.cloud_config.name)) for image in images: + if image.is_protected: + print('WARNING: Image {} is protected. Cannot remove...'.format(image.name)) + continue + try: result = cloud.delete_image(image.name) except shade.exc.OpenStackCloudException as e: