diff options
author | Shobhi Jain <shobhi.jain@intel.com> | 2018-03-30 10:45:54 +0100 |
---|---|---|
committer | Shobhi Jain <shobhi.jain@intel.com> | 2018-05-03 08:24:18 +0000 |
commit | d75a91ebf2937e5cfe5cf2aa5a90db9121f73967 (patch) | |
tree | fd6440ec4e0f1b7bb0d500f0a06a8a01699a8d64 /yardstick/common | |
parent | 346a2660b24ff3ca0128b0d873a716e735332a55 (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>
Diffstat (limited to 'yardstick/common')
-rw-r--r-- | yardstick/common/exceptions.py | 4 | ||||
-rw-r--r-- | yardstick/common/openstack_utils.py | 24 |
2 files changed, 23 insertions, 5 deletions
diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py index 13117e02f..2d48abc61 100644 --- a/yardstick/common/exceptions.py +++ b/yardstick/common/exceptions.py @@ -218,3 +218,7 @@ class ScenarioDeleteKeypairError(YardstickException): class ScenarioAttachVolumeError(YardstickException): message = 'Nova Attach Volume Scenario failed' + + +class ScenarioGetServerError(YardstickException): + message = 'Nova Get Server Scenario failed' 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 |