diff options
author | Shobhi Jain <shobhi.jain@intel.com> | 2018-04-10 15:17:35 +0100 |
---|---|---|
committer | Shobhi Jain <shobhi.jain@intel.com> | 2018-05-08 11:03:45 +0000 |
commit | f6cca46f6b1aa6134a0e634a3a9e524cdbbfa729 (patch) | |
tree | 86d7a7e8106c0c0ccc8e7d49112e68e6ba96b5cb /yardstick/common/openstack_utils.py | |
parent | 4c672aa7012a530806a2f8ff2d45a8badb7f7b21 (diff) |
Replace cinder detach volume with shade client.
Function detach volume now uses shade client.
JIRA: YARDSTICK-891
Change-Id: Ie437ccf1172cb82dc869963f0d62e31a5ab23ebb
Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
Diffstat (limited to 'yardstick/common/openstack_utils.py')
-rw-r--r-- | yardstick/common/openstack_utils.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py index 3909bcb2e..e3e08feb6 100644 --- a/yardstick/common/openstack_utils.py +++ b/yardstick/common/openstack_utils.py @@ -839,11 +839,23 @@ def delete_volume(shade_client, name_or_id=None, wait=True, timeout=None): return False -def detach_volume(server_id, volume_id): # pragma: no cover +def detach_volume(shade_client, server_name_or_id, volume_name_or_id, + wait=True, timeout=None): + """Detach a volume from a server. + + :param server_name_or_id: The server name or id to detach from. + :param volume_name_or_id: The volume name or id to detach. + :param wait: If true, waits for volume to be detached. + :param timeout: Seconds to wait for volume detachment. None is forever. + + :return: True on success. + """ try: - get_nova_client().volumes.delete_server_volume(server_id, volume_id) + volume = shade_client.get_volume(volume_name_or_id) + server = get_server(shade_client, name_or_id=server_name_or_id) + shade_client.detach_volume(server, volume, wait=wait, timeout=timeout) return True - except Exception: # pylint: disable=broad-except - log.exception("Error [detach_server_volume(nova_client, '%s', '%s')]", - server_id, volume_id) + except (exc.OpenStackCloudException, exc.OpenStackCloudTimeout) as o_exc: + log.error("Error [detach_volume(shade_client)]. " + "Exception message: %s", o_exc.orig_message) return False |