From 8189727b8c146583e1af5dceabae4d3a530dced9 Mon Sep 17 00:00:00 2001 From: Viktor Tikkanen Date: Fri, 2 Oct 2015 08:55:59 +0300 Subject: Added configure_tempest() function Currently there is a need to add and/or update some parameters into Tempest configuration file (tempest.conf) generated by Rally. This version of the function updates fixed_network_name parameter. JIRA: FUNCTEST-70 Change-Id: I182b687b02a4f124b6289e3cdae6f5817914d2ca Signed-off-by: Viktor Tikkanen --- testcases/config_functest.py | 49 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) mode change 100644 => 100755 testcases/config_functest.py (limited to 'testcases') diff --git a/testcases/config_functest.py b/testcases/config_functest.py old mode 100644 new mode 100755 index 7fbd06042..e209a3b94 --- a/testcases/config_functest.py +++ b/testcases/config_functest.py @@ -13,6 +13,7 @@ import functest_utils from git import Repo from os import stat from pwd import getpwuid +from neutronclient.v2_0 import client as neutronclient actions = ['start', 'check', 'clean'] parser = argparse.ArgumentParser() @@ -59,6 +60,8 @@ RALLY_RESULT_DIR = HOME + functest_yaml.get("general").get("directories").get("d VPING_DIR = REPO_PATH + functest_yaml.get("general").get("directories").get("dir_vping") ODL_DIR = REPO_PATH + functest_yaml.get("general").get("directories").get("dir_odl") +# Tempest/Rally configuration details +DEPLOYMENT_MAME = "opnfv-rally" #GLANCE image parameters IMAGE_URL = functest_yaml.get("general").get("openstack").get("image_url") @@ -91,7 +94,7 @@ def action_start(): action_clean() logger.info("Installing needed libraries on the host") - cmd = "sudo yum -y install gcc libffi-devel python-devel openssl-devel gmp-devel libxml2-devel libxslt-devel postgresql-devel git wget" + cmd = "sudo yum -y install gcc libffi-devel python-devel openssl-devel gmp-devel libxml2-devel libxslt-devel postgresql-devel git wget crudini" if not functest_utils.execute_command(cmd, logger): logger.error("There has been a problem while installing software packages.") exit(-1) @@ -109,6 +112,12 @@ def action_start(): action_clean() exit(-1) + logger.info("Configuring Tempest...") + if not configure_tempest(): + logger.error("There has been a problem while configuring Tempest.") + action_clean() + exit(-1) + # Create result folder under functest if necessary if not os.path.exists(RALLY_RESULT_DIR): os.makedirs(RALLY_RESULT_DIR) @@ -259,7 +268,7 @@ def install_rally(): functest_utils.execute_command(cmd,logger) logger.debug("Creating Rally environment...") - cmd = "rally deployment create --fromenv --name=opnfv-arno-rally" + cmd = "rally deployment create --fromenv --name="+DEPLOYMENT_MAME functest_utils.execute_command(cmd,logger) logger.debug("Installing tempest...") @@ -279,6 +288,40 @@ def install_rally(): return True +def configure_tempest(): + """ + Add/update needed parameters into tempest.conf file generated by Rally + """ + + creds_neutron = functest_utils.get_credentials("neutron") + neutron_client = neutronclient.Client(**creds_neutron) + + logger.debug("Generating tempest.conf file...") + cmd = "rally verify genconfig" + functest_utils.execute_command(cmd,logger) + + logger.debug("Resolving deployment UUID...") + cmd = "rally deployment list | awk '/"+DEPLOYMENT_MAME+"/ {print $2}'" + p = subprocess.Popen(cmd, shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT); + deployment_uuid = p.stdout.readline().rstrip() + if deployment_uuid == "": + logger.debug(" Rally deployment NOT found") + return False + + logger.debug("Finding tempest.conf file...") + tempest_conf_file = RALLY_INSTALLATION_DIR+"tempest/for-deployment-" \ + +deployment_uuid+"/tempest.conf" + + logger.debug(" Updating fixed_network_name...") + fixed_network = functest_utils.get_network_list(neutron_client)[0]['name'] + if fixed_network != None: + cmd = "crudini --set "+tempest_conf_file+" compute fixed_network_name "+fixed_network + functest_utils.execute_command(cmd,logger) + + return True + def check_rally(): """ @@ -287,7 +330,7 @@ def check_rally(): if os.path.exists(RALLY_INSTALLATION_DIR): logger.debug(" Rally installation directory found in %s" % RALLY_INSTALLATION_DIR) FNULL = open(os.devnull, 'w'); - cmd="rally deployment list | grep opnfv"; + cmd="rally deployment list | grep "+DEPLOYMENT_MAME 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 deployment -- cgit 1.2.3-korg