From ef1a86a802149e0a62c68fb93edf66b802bc72d1 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Fri, 17 Feb 2017 12:14:33 -0600 Subject: Fix image selection in server function tests The image selection has been affected by Cirros image changes in DevStack, make the logic moe robust and convert it to JSON. The conversion for the remainder of the file will follow. Change-Id: I8f3318f55ed79d617c3594142f0c086e2bd1a7b1 --- .../tests/functional/compute/v2/test_server.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'openstackclient') diff --git a/openstackclient/tests/functional/compute/v2/test_server.py b/openstackclient/tests/functional/compute/v2/test_server.py index 119ef05c..140404de 100644 --- a/openstackclient/tests/functional/compute/v2/test_server.py +++ b/openstackclient/tests/functional/compute/v2/test_server.py @@ -37,13 +37,18 @@ class ServerTests(base.TestCase): @classmethod def get_image(cls): - # NOTE(rtheis): Get cirros image since functional tests may - # create other images. - images = cls.openstack('image list -c Name -f value').split('\n') + # NOTE(rtheis): Get first Cirros image since functional tests may + # create other images. Image may be named '-uec' or + # '-disk'. + cmd_output = json.loads(cls.openstack( + "image list -f json " + )) server_image = None - for image in images: - if image.startswith('cirros-') and image.endswith('-uec'): - server_image = image + for image in cmd_output: + if (image['Name'].startswith('cirros-') and + (image['Name'].endswith('-uec') or + image['Name'].endswith('-disk'))): + server_image = image['Name'] break return server_image -- cgit v1.2.1