From 5ac59e495d74b64ab377f1ba25bb00b11da14e67 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Tue, 3 Apr 2018 06:23:42 +0000 Subject: Bugfix: Can't get image list in API JIRA: YARDSTICK-1110 To match OpenStack Pike release, we upgrade novaclient from 7.1.1 to 9.1.1. And the client interface has changed, it no longer has nova_client.images attribute. So I use shade instead. Later will change all same issue. Change-Id: Ie4f54069d4346e44e2ad925439930504b945cbad Signed-off-by: chenjiankun --- yardstick/common/openstack_utils.py | 14 +++++++++++++- yardstick/common/utils.py | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'yardstick/common') diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py index 2785230c0..5208a2749 100644 --- a/yardstick/common/openstack_utils.py +++ b/yardstick/common/openstack_utils.py @@ -733,7 +733,7 @@ def create_security_group_full(neutron_client, sg_name, log.debug("Adding ICMP rules in security group '%s'...", sg_name) if not create_security_group_rule(neutron_client, sg_id, - 'ingress', 'icmp'): + 'ingress', 'icmp'): log.error("Failed to create the security group rule...") return None @@ -797,6 +797,18 @@ def delete_image(glance_client, image_id): # pragma: no cover return True +def list_images(shade_client=None): + if shade_client is None: + shade_client = get_shade_client() + + try: + return shade_client.list_images() + except exc.OpenStackCloudException as o_exc: + log.error("Error [list_images(shade_client)]." + "Exception message, '%s'", o_exc.orig_message) + return False + + # ********************************************* # CINDER # ********************************************* diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py index 357f66be8..44cc92a7c 100644 --- a/yardstick/common/utils.py +++ b/yardstick/common/utils.py @@ -136,6 +136,11 @@ def source_env(env_file): p = subprocess.Popen(". %s; env" % env_file, stdout=subprocess.PIPE, shell=True) output = p.communicate()[0] + + # sometimes output type would be binary_type, and it don't have splitlines + # method, so we need to decode + if isinstance(output, six.binary_type): + output = encodeutils.safe_decode(output) env = dict(line.split('=', 1) for line in output.splitlines() if '=' in line) os.environ.update(env) return env -- cgit 1.2.3-korg