Fix image name iteration 53/35053/2
authorCatalina Focsa <catalina.focsa@enea.com>
Fri, 19 May 2017 12:12:49 +0000 (14:12 +0200)
committerCatalina Focsa <catalina.focsa@enea.com>
Fri, 19 May 2017 12:25:16 +0000 (14:25 +0200)
Create a promise image depending on the glance image path.
Due to glance image listing returning image names, looking
for an image based on an image path is always false, thus
its relevant to only look for the glance image name and if it exists
to use its ID, if not to create a new image given the promise
image name.

JIRA: ARMBAND-223

Change-Id: I2d1347807335f2c7e9d62f1a6c75fb48de6cf448
Signed-off-by: Catalina Focsa <catalina.focsa@enea.com>
promise/test/functest/run_tests.py

index 17f915b..448231c 100644 (file)
@@ -143,19 +143,17 @@ def main():
 
     logger.info("Upload some OS images if it doesn't exist")
 
-    images = {"image_name": GLANCE_IMAGE_NAME, "image_url": GLANCE_IMAGE_PATH}
-    for image_name, image_url in images.iteritems():
-        image_id = os_utils.get_image_id(glance_client, image_name)
-
-        if image_id == '':
-            logger.info("%s image doesn't exist on glance repo" % image_name)
-            logger.info("Try downloading this image and upload on glance !")
-            image_id = os_utils.create_glance_image(
-                glance_client, GLANCE_IMAGE_NAME, GLANCE_IMAGE_PATH)
-
-        if image_id == '':
-            logger.error("Failed to create the Glance image...")
-            return return_code
+    image_id = os_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
+
+    if image_id == '':
+        logger.info("%s image doesn't exist on glance repo" % GLANCE_IMAGE_NAME)
+        logger.info("Try downloading this image and upload on glance !")
+        image_id = os_utils.create_glance_image(
+            glance_client, GLANCE_IMAGE_NAME, GLANCE_IMAGE_PATH)
+
+    if image_id == '':
+        logger.error("Failed to create the Glance image...")
+        return return_code
 
     logger.debug("Image '%s' with ID '%s' created successfully."
                  % (PROMISE_IMAGE_NAME, image_id))