From d36a76e6425c914a8243033175c3233e449e624b Mon Sep 17 00:00:00 2001 From: vitikkan Date: Mon, 25 Apr 2016 10:43:29 +0300 Subject: ConfigParser is used for tempest.conf updating Bash commands are replaced with python's ConfigParser routines for configuration file reading/updating. Removed updating of ssh_user_regex parameter since it is now into upstream Rally code. JIRA: FUNCTEST-198 Change-Id: I95f926948a395993e28e993bf7ea2872d6b5c969 Signed-off-by: vitikkan --- .../VIM/OpenStack/CI/libraries/run_tempest.py | 29 ++++++++-------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'testcases/VIM/OpenStack/CI') diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py index b2240c9c2..8407da2c6 100644 --- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py @@ -23,6 +23,7 @@ import shutil import subprocess import time import yaml +import ConfigParser import keystoneclient.v2_0.client as ksclient from neutronclient.v2_0 import client as neutronclient @@ -217,7 +218,9 @@ def configure_tempest(mode): cmd += "testr list-tests >" + TEMPEST_LIST_FILE + ";cd" functest_utils.execute_command(cmd, logger) - logger.debug(" Updating fixed_network_name...") + logger.debug("Updating selected tempest.conf parameters...") + config = ConfigParser.RawConfigParser() + config.read(tempest_conf_file) private_net_name = "" creds_neutron = openstack_utils.get_credentials("neutron") neutron_client = neutronclient.Client(**creds_neutron) @@ -226,24 +229,12 @@ def configure_tempest(mode): logger.error("No shared private networks found.") else: private_net_name = private_net['name'] - cmd = "crudini --set " + tempest_conf_file + \ - " compute fixed_network_name " + \ - private_net_name - functest_utils.execute_command(cmd, logger) - - logger.debug(" Updating non-admin credentials...") - cmd = "crudini --set " + tempest_conf_file + " identity tenant_name " \ - + TENANT_NAME - functest_utils.execute_command(cmd, logger) - cmd = "crudini --set " + tempest_conf_file + " identity username " \ - + USER_NAME - functest_utils.execute_command(cmd, logger) - cmd = "crudini --set " + tempest_conf_file + " identity password " \ - + USER_PASSWORD - functest_utils.execute_command(cmd, logger) - cmd = "sed -i 's/.*ssh_user_regex.*/ssh_user_regex = " + SSH_USER_REGEX + \ - "/' " + tempest_conf_file - functest_utils.execute_command(cmd, logger) + config.set('compute', 'fixed_network_name', private_net_name) + config.set('identity', 'tenant_name', TENANT_NAME) + config.set('identity', 'username', USER_NAME) + config.set('identity', 'password', USER_PASSWORD) + with open(tempest_conf_file, 'wb') as config_file: + config.write(config_file) # Copy tempest.conf to /home/opnfv/functest/results/tempest/ shutil.copyfile(tempest_conf_file, TEMPEST_RESULTS_DIR + '/tempest.conf') -- cgit 1.2.3-korg