aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-04-12 13:38:21 +0100
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-05-31 08:27:53 +0000
commitd6c1b8b7bfd257efd5fe2df30dd450bdb2c57c7d (patch)
tree8843a5d772ef7c8dbc55f1f90b08ceda90969743 /yardstick/common
parent2e6ac1229309227398cb651e68ec062dbb95c955 (diff)
Replace glance delete image with shade client.
Remove get_image_id function. Function delete_image now uses shade client. JIRA: YARDSTICK-892 Change-Id: I6e8510dfa49aa14786ed7ac3382b85c4e699fb9e Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
Diffstat (limited to 'yardstick/common')
-rw-r--r--yardstick/common/exceptions.py4
-rw-r--r--yardstick/common/openstack_utils.py19
2 files changed, 12 insertions, 11 deletions
diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py
index 80fe8aed8..e6a1f1fa1 100644
--- a/yardstick/common/exceptions.py
+++ b/yardstick/common/exceptions.py
@@ -263,3 +263,7 @@ class UpdateOpenrcError(ApiServerError):
class ScenarioCreateImageError(YardstickException):
message = 'Glance Create Image Scenario failed'
+
+
+class ScenarioDeleteImageError(YardstickException):
+ message = 'Glance Delete Image Scenario failed'
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py
index 8d7e99222..6ff6617a9 100644
--- a/yardstick/common/openstack_utils.py
+++ b/yardstick/common/openstack_utils.py
@@ -724,11 +724,6 @@ def create_security_group_full(shade_client, sg_name,
# *********************************************
# GLANCE
# *********************************************
-def get_image_id(glance_client, image_name): # pragma: no cover
- images = glance_client.images.list()
- return next((i.id for i in images if i.name == image_name), None)
-
-
def create_image(shade_client, name, filename=None, container='images',
md5=None, sha256=None, disk_format=None,
container_format=None, disable_vendor_agent=True,
@@ -787,15 +782,17 @@ def create_image(shade_client, name, filename=None, container='images',
"Exception message: %s", op_exc.orig_message)
-def delete_image(glance_client, image_id): # pragma: no cover
+def delete_image(shade_client, name_or_id, wait=False, timeout=3600,
+ delete_objects=True):
try:
- glance_client.images.delete(image_id)
+ return shade_client.delete_image(name_or_id, wait=wait,
+ timeout=timeout,
+ delete_objects=delete_objects)
- except Exception: # pylint: disable=broad-except
- log.exception("Error [delete_flavor(glance_client, %s)]", image_id)
+ except exc.OpenStackCloudException as op_exc:
+ log.error("Failed to delete_image(shade_client). "
+ "Exception message: %s", op_exc.orig_message)
return False
- else:
- return True
def list_images(shade_client=None):