Stop using a hardcoded cirros image name

In the tests we have the cirros image name hard-coded.
This requires us to update it every time the test image is updated.
Instead, now we list the images and take the first one (which is safe enough for
the circumstances).
Anyway, if a specific image is required, it may still be requested in the
'vm_image' argument.

Change-Id: I0aae2a01ca5fd67bd828bb8daf6df466c60acff2
This commit is contained in:
Shachar Snapiri 2019-02-05 15:10:53 +02:00 committed by Shachar Snapiri
parent f1788f3ac6
commit 8f0e67da2e
1 changed files with 10 additions and 2 deletions

View File

@ -289,8 +289,16 @@ class VMTestObj(object):
self.nova = clients.get_nova_client_from_cloud_config()
def create(self, network=None, script=None, security_groups=None,
net_address=None):
image = self.nova.glance.find_image("cirros-0.4.0-x86_64-disk")
net_address=None, vm_image=None):
if vm_image:
image = self.nova.glance.find_image(vm_image)
else:
# As we are running in test environment, it would be safe to assume
# we only have one image, which is the image we want to use.
# Taking the first image is safe enough in this case
images = self.nova.glance.list()
assert images
image = images[0]
self.parent.assertIsNotNone(image)
flavor = self.nova.flavors.find(name="m1.tiny")
self.parent.assertIsNotNone(flavor)