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
This commit is contained in:
Dean Troyer 2017-02-17 12:14:33 -06:00
parent 3b562ffa90
commit ef1a86a802

View File

@ -37,13 +37,18 @@ class ServerTests(base.TestCase):
@classmethod @classmethod
def get_image(cls): def get_image(cls):
# NOTE(rtheis): Get cirros image since functional tests may # NOTE(rtheis): Get first Cirros image since functional tests may
# create other images. # create other images. Image may be named '-uec' or
images = cls.openstack('image list -c Name -f value').split('\n') # '-disk'.
cmd_output = json.loads(cls.openstack(
"image list -f json "
))
server_image = None server_image = None
for image in images: for image in cmd_output:
if image.startswith('cirros-') and image.endswith('-uec'): if (image['Name'].startswith('cirros-') and
server_image = image (image['Name'].endswith('-uec') or
image['Name'].endswith('-disk'))):
server_image = image['Name']
break break
return server_image return server_image