aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-04-10 14:13:50 +0100
committerShobhi Jain <shobhi.jain@intel.com>2018-05-08 11:35:09 +0100
commit4c672aa7012a530806a2f8ff2d45a8badb7f7b21 (patch)
tree756f2756127fdf796818bee66056d98d7bb5291d /yardstick/common
parent2d33d0f289f3dd3864fe57289e953b876f362c06 (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>
Diffstat (limited to 'yardstick/common')
-rw-r--r--yardstick/common/exceptions.py4
-rw-r--r--yardstick/common/openstack_utils.py32
2 files changed, 18 insertions, 18 deletions
diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py
index 1aa734ae3..f82290036 100644
--- a/yardstick/common/exceptions.py
+++ b/yardstick/common/exceptions.py
@@ -234,3 +234,7 @@ class ScenarioGetFlavorError(YardstickException):
class ScenarioCreateVolumeError(YardstickException):
message = 'Cinder Create Volume Scenario failed'
+
+
+class ScenarioDeleteVolumeError(YardstickException):
+ message = 'Cinder Delete Volume Scenario failed'
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py
index 026ec620f..3909bcb2e 100644
--- a/yardstick/common/openstack_utils.py
+++ b/yardstick/common/openstack_utils.py
@@ -10,7 +10,6 @@
import copy
import logging
import os
-import sys
from cinderclient import client as cinderclient
from novaclient import client as novaclient
@@ -822,24 +821,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