Ignore protected images that are protected 52/11152/1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Sat, 9 Jun 2018 18:18:03 +0000 (14:18 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Sat, 9 Jun 2018 18:18:47 +0000 (14:18 -0400)
Print a warning to inform the caller that we cannot delete
images that are protected.

Change-Id: I236f6f55964f483016500b58cbeb48fd8665b62b
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
lftools/openstack/image.py

index 8b2a77f..5ca9259 100644 (file)
@@ -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: