Allow vping to use existing glance image 93/13493/1
authorCiprian Barbu <ciprian.barbu@enea.com>
Wed, 30 Mar 2016 13:49:34 +0000 (16:49 +0300)
committerJose Lausuch <jose.lausuch@ericsson.com>
Mon, 2 May 2016 12:18:52 +0000 (12:18 +0000)
This allows to use a prebuilt glance image without deleting it after the test.
For ARM platforms this is especially helpful because the test image is
three-part and can be created before running any tests.

Change-Id: I3bc16eab592b9ad629693c402466755b6fa6db8a
Signed-off-by: Ciprian Barbu <ciprian.barbu@enea.com>
(cherry picked from commit 4830cbe462c1081906292b027073644904e42970)

testcases/config_functest.yaml
testcases/vPing/CI/libraries/vPing_ssh.py
testcases/vPing/CI/libraries/vPing_userdata.py

index 120294e..1a4084e 100644 (file)
@@ -66,6 +66,7 @@ vping:
     vm_flavor: m1.small #adapt to your environment
     vm_name_1: opnfv-vping-1
     vm_name_2: opnfv-vping-2
+    image_name: functest-vping
     vping_private_net_name: vping-net
     vping_private_subnet_name: vping-subnet
     vping_private_subnet_cidr: 192.168.130.0/24
index e3b2ec5..036f0d9 100644 (file)
@@ -33,6 +33,7 @@ from glanceclient import client as glanceclient
 pp = pprint.PrettyPrinter(indent=4)
 
 parser = argparse.ArgumentParser()
+image_exists = False
 
 parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
 parser.add_argument("-r", "--report",
@@ -82,9 +83,7 @@ PING_TIMEOUT = functest_yaml.get("vping").get("ping_timeout")
 TEST_DB = functest_yaml.get("results").get("test_db_url")
 NAME_VM_1 = functest_yaml.get("vping").get("vm_name_1")
 NAME_VM_2 = functest_yaml.get("vping").get("vm_name_2")
-# GLANCE_IMAGE_NAME = functest_yaml.get("general"). \
-#    get("openstack").get("image_name")
-GLANCE_IMAGE_NAME = "functest-vping"
+GLANCE_IMAGE_NAME = functest_yaml.get("vping").get("image_name")
 GLANCE_IMAGE_FILENAME = functest_yaml.get("general"). \
     get("openstack").get("image_file_name")
 GLANCE_IMAGE_FORMAT = functest_yaml.get("general"). \
@@ -251,9 +250,10 @@ def cleanup(nova, neutron, image_id, network_dic, sg_id, floatingip):
 
     # delete both VMs
     logger.info("Cleaning up...")
-    logger.debug("Deleting image...")
-    if not functest_utils.delete_glance_image(nova, image_id):
-        logger.error("Error deleting the glance image")
+    if not image_exists:
+        logger.debug("Deleting image...")
+        if not functest_utils.delete_glance_image(nova, image_id):
+            logger.error("Error deleting the glance image")
 
     vm1 = functest_utils.get_instance_by_name(nova, NAME_VM_1)
     if vm1:
@@ -366,6 +366,8 @@ def main():
     image_id = functest_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
     if image_id != '':
         logger.info("Using existing image '%s'..." % GLANCE_IMAGE_NAME)
+        global image_exists
+        image_exists = True
     else:
         logger.info("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME,
                                                        GLANCE_IMAGE_PATH))
index a71e766..52d6dac 100644 (file)
@@ -30,6 +30,7 @@ from glanceclient import client as glanceclient
 pp = pprint.PrettyPrinter(indent=4)
 
 parser = argparse.ArgumentParser()
+image_exists = False
 
 parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
 parser.add_argument("-r", "--report",
@@ -78,9 +79,7 @@ PING_TIMEOUT = functest_yaml.get("vping").get("ping_timeout")
 TEST_DB = functest_yaml.get("results").get("test_db_url")
 NAME_VM_1 = functest_yaml.get("vping").get("vm_name_1")
 NAME_VM_2 = functest_yaml.get("vping").get("vm_name_2")
-# GLANCE_IMAGE_NAME = functest_yaml.get("general"). \
-#    get("openstack").get("image_name")
-GLANCE_IMAGE_NAME = "functest-vping"
+GLANCE_IMAGE_NAME = functest_yaml.get("vping").get("image_name")
 GLANCE_IMAGE_FILENAME = functest_yaml.get("general"). \
     get("openstack").get("image_file_name")
 GLANCE_IMAGE_FORMAT = functest_yaml.get("general"). \
@@ -246,9 +245,10 @@ def cleanup(nova, neutron, image_id, network_dic):
 
     # delete both VMs
     logger.info("Cleaning up...")
-    logger.debug("Deleting image...")
-    if not functest_utils.delete_glance_image(nova, image_id):
-        logger.error("Error deleting the glance image")
+    if not image_exists:
+        logger.debug("Deleting image...")
+        if not functest_utils.delete_glance_image(nova, image_id):
+            logger.error("Error deleting the glance image")
 
     vm1 = functest_utils.get_instance_by_name(nova, NAME_VM_1)
     if vm1:
@@ -348,6 +348,8 @@ def main():
     image_id = functest_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
     if image_id != '':
         logger.info("Using existing image '%s'..." % GLANCE_IMAGE_NAME)
+        global image_exists
+        image_exists = True
     else:
         logger.info("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME,
                                                        GLANCE_IMAGE_PATH))