summaryrefslogtreecommitdiffstats
path: root/yardstick/common
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-03-30 10:45:54 +0100
committerEmma Foley <emma.l.foley@intel.com>2018-06-27 17:14:54 +0100
commit60aa5d558a80bd3cfa51f962cef794c25a2eb828 (patch)
tree9ef89db36f033d72ffdf441a397e102bffdf1cea /yardstick/common
parent8442ad76bb4f93eeb87f5bbf0f2292bb2400ea2d (diff)
Replace nova get server with shade client.
Rename get_server_by_name with get_server. Function get_server now uses shade client. JIRA: YARDSTICK-1088 Change-Id: I69c59145cefdb565f3ece27baaaf932905e1b757 Signed-off-by: Shobhi Jain <shobhi.jain@intel.com> (cherry picked from commit d75a91ebf2937e5cfe5cf2aa5a90db9121f73967)
Diffstat (limited to 'yardstick/common')
-rw-r--r--yardstick/common/exceptions.py4
-rw-r--r--yardstick/common/openstack_utils.py24
2 files changed, 23 insertions, 5 deletions
diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py
index 3a51892cc..cb8fabda8 100644
--- a/yardstick/common/exceptions.py
+++ b/yardstick/common/exceptions.py
@@ -238,6 +238,10 @@ class ScenarioAttachVolumeError(YardstickException):
message = 'Nova Attach Volume Scenario failed'
+class ScenarioGetServerError(YardstickException):
+ message = 'Nova Get Server 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 0a3cfb5fc..0220c4212 100644
--- a/yardstick/common/openstack_utils.py
+++ b/yardstick/common/openstack_utils.py
@@ -321,12 +321,26 @@ def delete_instance(shade_client, name_or_id, wait=False, timeout=180,
return False
-def get_server_by_name(name): # pragma: no cover
+def get_server(shade_client, name_or_id=None, filters=None, detailed=False,
+ bare=False):
+ """Get a server by name or ID.
+
+ :param name_or_id: Name or ID of the server.
+ :param filters:(dict) A dictionary of meta data to use for further
+ filtering.
+ :param detailed:(bool) Whether or not to add detailed additional
+ information.
+ :param bare:(bool) Whether to skip adding any additional information to the
+ server record.
+
+ :returns: A server ``munch.Munch`` or None if no matching server is found.
+ """
try:
- return get_nova_client().servers.list(search_opts={'name': name})[0]
- except IndexError:
- log.exception('Failed to get nova client')
- raise
+ return shade_client.get_server(name_or_id=name_or_id, filters=filters,
+ detailed=detailed, bare=bare)
+ except exc.OpenStackCloudException as o_exc:
+ log.error("Error [get_server(shade_client, '%s')]. "
+ "Exception message: %s", name_or_id, o_exc.orig_message)
def create_flavor(name, ram, vcpus, disk, **kwargs): # pragma: no cover