From 051b5486ec41d1b901be59bd07c0150878f97a19 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Sat, 9 Jun 2018 14:18:03 -0400 Subject: [PATCH] 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 --- lftools/openstack/image.py | 4 ++++ 1 file changed, 4 insertions(+) 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: -- 2.16.6