diff options
author | Shobhi Jain <shobhi.jain@intel.com> | 2018-04-10 14:13:50 +0100 |
---|---|---|
committer | Emma Foley <emma.l.foley@intel.com> | 2018-06-27 17:24:14 +0100 |
commit | 537d0a18ee5df89c0372f359e4496f0fb7ab1776 (patch) | |
tree | 97cc5adac1e194e3241de2e659f2f6fbc926097c /yardstick/common | |
parent | 952b7604129474fc080ef2fbbbe1150ffe7775c6 (diff) |
Replace cinder delete volume with shade client.
Function delete volume now uses shade client.
JIRA: YARDSTICK-891
Change-Id: I016e1d3bf5972879cad176b56c7282e35413945e
Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
(cherry picked from commit 4c672aa7012a530806a2f8ff2d45a8badb7f7b21)
Diffstat (limited to 'yardstick/common')
-rw-r--r-- | yardstick/common/exceptions.py | 4 | ||||
-rw-r--r-- | yardstick/common/openstack_utils.py | 32 |
2 files changed, 18 insertions, 18 deletions
diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py index c6bae444e..1ddd88432 100644 --- a/yardstick/common/exceptions.py +++ b/yardstick/common/exceptions.py @@ -250,6 +250,10 @@ class ScenarioCreateVolumeError(YardstickException): message = 'Cinder Create Volume Scenario failed' +class ScenarioDeleteVolumeError(YardstickException): + message = 'Cinder Delete Volume Scenario failed' + + class ApiServerError(YardstickException): message = 'An unkown exception happened to Api Server!' diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py index 1c4ad77e5..a9d833fff 100644 --- a/yardstick/common/openstack_utils.py +++ b/yardstick/common/openstack_utils.py @@ -8,7 +8,6 @@ ############################################################################## import os -import sys import logging from keystoneauth1 import loading @@ -807,24 +806,21 @@ def create_volume(shade_client, size, wait=True, timeout=None, "Exception message: %s", op_exc.orig_message) -def delete_volume(cinder_client, volume_id, - forced=False): # pragma: no cover +def delete_volume(shade_client, name_or_id=None, wait=True, timeout=None): + """Delete a volume. + + :param name_or_id:(string) Name or unique ID of the volume. + :param wait:(bool) If true, waits for volume to be deleted. + :param timeout:(string) Seconds to wait for volume deletion. None is forever. + + :return: True on success, False otherwise. + """ try: - if forced: - try: - cinder_client.volumes.detach(volume_id) - except Exception: # pylint: disable=broad-except - log.error(sys.exc_info()[0]) - cinder_client.volumes.force_delete(volume_id) - else: - while True: - volume = get_cinder_client().volumes.get(volume_id) - if volume.status.lower() == 'available': - break - cinder_client.volumes.delete(volume_id) - return True - except Exception: # pylint: disable=broad-except - log.exception("Error [delete_volume(cinder_client, '%s')]", volume_id) + return shade_client.delete_volume(name_or_id=name_or_id, + wait=wait, timeout=timeout) + except (exc.OpenStackCloudException, exc.OpenStackCloudTimeout) as o_exc: + log.error("Error [delete_volume(shade_client,'%s')]. " + "Exception message: %s", name_or_id, o_exc.orig_message) return False |