summaryrefslogtreecommitdiffstats
path: root/functest/utils/openstack_clean.py
diff options
context:
space:
mode:
authorJose Lausuch <jose.lausuch@ericsson.com>2017-06-26 10:06:41 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-06-26 10:06:41 +0000
commit4252d177e9ccb0e533b74751008d7f8d5ab57840 (patch)
treeef83382cc610dffb89bd8708b015983ca2c6b0c2 /functest/utils/openstack_clean.py
parentc8d5216c01c42f0e090f9b441985f8ebc3eca0ed (diff)
parent5cfd8ce686f8b539d01a3e7e009e7d5a18b8228f (diff)
Merge "Use glance to list images"
Diffstat (limited to 'functest/utils/openstack_clean.py')
-rwxr-xr-xfunctest/utils/openstack_clean.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py
index 229fbf02..b5167893 100755
--- a/functest/utils/openstack_clean.py
+++ b/functest/utils/openstack_clean.py
@@ -80,22 +80,25 @@ def remove_instances(nova_client, default_instances):
break
-def remove_images(nova_client, default_images):
+def remove_images(glance_client, default_images):
logger.debug("Removing Glance images...")
- images = os_utils.get_images(nova_client)
- if images is None or len(images) == 0:
+ images = os_utils.get_images(glance_client)
+ if images is None:
+ return -1
+ images = {image.id: image.name for image in images}
+ if len(images) == 0:
logger.debug("No images found.")
return
for image in images:
- image_name = getattr(image, 'name')
- image_id = getattr(image, 'id')
+ image_id = image
+ image_name = images.get(image_id)
logger.debug("'%s', ID=%s " % (image_name, image_id))
if (image_id not in default_images and
image_name not in default_images.values()):
logger.debug("Removing image '%s', ID=%s ..."
% (image_name, image_id))
- if os_utils.delete_glance_image(nova_client, image_id):
+ if os_utils.delete_glance_image(glance_client, image_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the"
@@ -385,6 +388,7 @@ def main():
neutron_client = os_utils.get_neutron_client()
keystone_client = os_utils.get_keystone_client()
cinder_client = os_utils.get_cinder_client()
+ glance_client = os_utils.get_glance_client()
try:
with open(OS_SNAPSHOT_FILE) as f:
@@ -411,7 +415,7 @@ def main():
remove_instances(nova_client, default_instances)
separator()
- remove_images(nova_client, default_images)
+ remove_images(glance_client, default_images)
separator()
remove_volumes(cinder_client, default_volumes)
separator()