summaryrefslogtreecommitdiffstats
path: root/yardstick/common/openstack_utils.py
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-06-28 07:23:53 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-06-28 07:23:53 +0000
commitecade87f9b6b10c2c13ae42d78b82e0792a31ffe (patch)
tree82ce2c7abcdabb83f280e3546f42e561bc6acef2 /yardstick/common/openstack_utils.py
parente8a0b1b9662e323499de66aaf3800750f51c1299 (diff)
parent60aa5d558a80bd3cfa51f962cef794c25a2eb828 (diff)
Merge "Replace nova get server with shade client." into stable/fraser
Diffstat (limited to 'yardstick/common/openstack_utils.py')
-rw-r--r--yardstick/common/openstack_utils.py24
1 files changed, 19 insertions, 5 deletions
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