summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2017-02-17 12:14:33 -0600
committerDean Troyer <dtroyer@gmail.com>2017-02-17 12:14:41 -0600
commitef1a86a802149e0a62c68fb93edf66b802bc72d1 (patch)
tree1938b6dcbf0d14e83a15232d1d9c726148199a3a /openstackclient
parent3b562ffa904ebb23396c2d6c7398a520cd535238 (diff)
downloadpython-openstackclient-ef1a86a802149e0a62c68fb93edf66b802bc72d1.tar.gz
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
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/tests/functional/compute/v2/test_server.py17
1 files changed, 11 insertions, 6 deletions
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