From 8f0e67da2e8ec7d145ba8c09e7f5ceb33677d46a Mon Sep 17 00:00:00 2001 From: Shachar Snapiri Date: Tue, 5 Feb 2019 15:10:53 +0200 Subject: [PATCH] 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 --- dragonflow/tests/fullstack/test_objects.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dragonflow/tests/fullstack/test_objects.py b/dragonflow/tests/fullstack/test_objects.py index 95aee2004..6c6e89be3 100644 --- a/dragonflow/tests/fullstack/test_objects.py +++ b/dragonflow/tests/fullstack/test_objects.py @@ -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)