Skip to content

Commit ef1a86a

Browse files
author
Dean Troyer
committed
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
1 parent 3b562ff commit ef1a86a

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

openstackclient/tests/functional/compute/v2/test_server.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ def get_flavor(cls):
3737

3838
@classmethod
3939
def get_image(cls):
40-
# NOTE(rtheis): Get cirros image since functional tests may
41-
# create other images.
42-
images = cls.openstack('image list -c Name -f value').split('\n')
40+
# NOTE(rtheis): Get first Cirros image since functional tests may
41+
# create other images. Image may be named '-uec' or
42+
# '-disk'.
43+
cmd_output = json.loads(cls.openstack(
44+
"image list -f json "
45+
))
4346
server_image = None
44-
for image in images:
45-
if image.startswith('cirros-') and image.endswith('-uec'):
46-
server_image = image
47+
for image in cmd_output:
48+
if (image['Name'].startswith('cirros-') and
49+
(image['Name'].endswith('-uec') or
50+
image['Name'].endswith('-disk'))):
51+
server_image = image['Name']
4752
break
4853
return server_image
4954

0 commit comments

Comments
 (0)