diff options
Diffstat (limited to 'testcases')
-rwxr-xr-x | testcases/config_functest.py | 43 | ||||
-rw-r--r-- | testcases/vPing/CI/libraries/vPing.py | 36 |
2 files changed, 35 insertions, 44 deletions
diff --git a/testcases/config_functest.py b/testcases/config_functest.py index 8523a77f4..e66240eed 100755 --- a/testcases/config_functest.py +++ b/testcases/config_functest.py @@ -64,10 +64,8 @@ DATA_DIR = functest_yaml.get("general").get("directories").get("dir_functest_dat DEPLOYMENT_MAME = "opnfv-rally" RALLY_COMMIT = functest_yaml.get("general").get("openstack").get("rally_stable_commit") -#GLANCE image parameters +#Image (cirros) IMAGE_FILE_NAME = functest_yaml.get("general").get("openstack").get("image_file_name") -IMAGE_DISK_FORMAT = functest_yaml.get("general").get("openstack").get("image_disk_format") -IMAGE_NAME = functest_yaml.get("general").get("openstack").get("image_name") IMAGE_PATH = DATA_DIR + "/" + IMAGE_FILE_NAME @@ -105,12 +103,6 @@ def action_start(): if not os.path.exists(RALLY_RESULT_DIR): os.makedirs(RALLY_RESULT_DIR) - logger.info("Creating Glance image: %s ..." %IMAGE_NAME) - if not create_glance_image(IMAGE_PATH,IMAGE_NAME,IMAGE_DISK_FORMAT): - logger.error("There has been a problem while creating the Glance image.") - action_clean() - exit(-1) - exit(0) @@ -155,18 +147,6 @@ def action_check(): else: logger.debug(" Image file found in %s" % IMAGE_PATH) - cmd="glance image-list | grep " + IMAGE_NAME - FNULL = open(os.devnull, 'w'); - logger.debug(' Executing command : {}'.format(cmd)) - p=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=FNULL); - #if the command does not exist or there is no glance image - line = p.stdout.readline() - if line == "": - logger.debug(" Glance image NOT found.") - errors = True - errors_all = True - else: - logger.debug(" Glance image found.") if not errors: logger.debug("...OK") @@ -187,14 +167,6 @@ def action_clean(): logger.debug("Removing Rally installation directory %s" % RALLY_INSTALLATION_DIR) shutil.rmtree(RALLY_INSTALLATION_DIR,ignore_errors=True) - cmd = "glance image-list | grep "+IMAGE_NAME+" | cut -c3-38" - p = os.popen(cmd,"r") - - #while image_id = p.readline() - for image_id in p.readlines(): - cmd = "glance image-delete " + image_id - functest_utils.execute_command(cmd,logger) - if os.path.exists(RALLY_RESULT_DIR): logger.debug("Removing Result directory") shutil.rmtree(RALLY_RESULT_DIR,ignore_errors=True) @@ -290,19 +262,6 @@ def check_rally(): return False - -def create_glance_image(path,name,disk_format): - """ - Create a glance image given the absolute path of the image, its name and the disk format - """ - cmd = ("glance image-create --name "+name+" --visibility public " - "--disk-format "+disk_format+" --container-format bare --file "+path) - functest_utils.execute_command(cmd,logger) - return True - - - - def main(): if not (args.action in actions): logger.error('argument not valid') diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py index 14671b66d..fbe134cb8 100644 --- a/testcases/vPing/CI/libraries/vPing.py +++ b/testcases/vPing/CI/libraries/vPing.py @@ -76,8 +76,17 @@ NAME_VM_1 = functest_yaml.get("vping").get("vm_name_1") NAME_VM_2 = functest_yaml.get("vping").get("vm_name_2") IP_1 = functest_yaml.get("vping").get("ip_1") IP_2 = functest_yaml.get("vping").get("ip_2") -GLANCE_IMAGE_NAME = functest_yaml.get("general"). \ - get("openstack").get("image_name") +#GLANCE_IMAGE_NAME = functest_yaml.get("general"). \ +# get("openstack").get("image_name") +GLANCE_IMAGE_NAME="functest-vping" +GLANCE_IMAGE_FILENAME = functest_yaml.get("general"). \ + get("openstack").get("image_file_name") +GLANCE_IMAGE_FORMAT = functest_yaml.get("general"). \ + get("openstack").get("image_disk_format") +GLANCE_IMAGE_PATH = functest_yaml.get("general"). \ + get("directories").get("dir_functest_data") +"/"+GLANCE_IMAGE_FILENAME + + FLAVOR = functest_yaml.get("vping").get("vm_flavor") # NEUTRON Private Network parameters @@ -177,11 +186,29 @@ def create_private_neutron_net(neutron): 'router_id': router_id} return network_dic +def create_glance_image(path,name,disk_format): + """ + Create a glance image given the absolute path of the image, its name and the disk format + """ + cmd = ("glance image-create --name "+name+" --visibility public " + "--disk-format "+disk_format+" --container-format bare --file "+path) + functest_utils.execute_command(cmd,logger) + return True + +def delete_glance_image(name): + cmd = ("glance image-delete $(glance image-list | grep %s " + "| awk '{print $2}' | head -1)" %name) + functest_utils.execute_command(cmd,logger) + return True + def cleanup(nova, neutron, network_dic): # delete both VMs logger.info("Cleaning up...") + logger.debug("Deleting image...") + delete_glance_image(GLANCE_IMAGE_NAME) + vm1 = functest_utils.get_instance_by_name(nova, NAME_VM_1) if vm1: logger.debug("Deleting '%s'..." % NAME_VM_1) @@ -240,8 +267,10 @@ def cleanup(nova, neutron, network_dic): logger.debug( "Network '%s' deleted successfully" % NEUTRON_PRIVATE_NET_NAME) + return True + def main(): creds_nova = functest_utils.get_credentials("nova") @@ -253,6 +282,9 @@ def main(): image = None flavor = None + logger.debug("Creating image '%s' from '%s'..." %(GLANCE_IMAGE_NAME,GLANCE_IMAGE_PATH)) + create_glance_image(GLANCE_IMAGE_PATH,GLANCE_IMAGE_NAME,GLANCE_IMAGE_FORMAT) + # Check if the given image exists try: image = nova_client.images.find(name=GLANCE_IMAGE_NAME) |