diff options
author | tomsou <soth@intracom-telecom.com> | 2017-02-07 10:28:45 +0000 |
---|---|---|
committer | tomsou <soth@intracom-telecom.com> | 2017-02-08 12:33:53 +0000 |
commit | a3d2b6df1fc22c05f2cccd6e2c7ab225899be109 (patch) | |
tree | 4a6b55e142bd6d109c1d3afc2e97774d39358421 | |
parent | ec94112aa52507727425005458264335352ac6e8 (diff) |
Refactor configure_tempest() function
Create two new functions: configure_tempest_update_params and
configure_verifier, distinguishing between tempest.conf
configure verification and add/updating parameters into it
this update is useful and it will be used by sdnvpn/tempest
Change-Id: I76e0bc00e33492252cdecab224380ecca2ce275a
Signed-off-by: tomsou <soth@intracom-telecom.com>
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/conf_utils.py | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index 91a5bb4b0..f013b4421 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -110,24 +110,23 @@ def get_verifier_deployment_dir(verifier_id, deployment_id): def configure_tempest(deployment_dir, IMAGE_ID=None, FLAVOR_ID=None): """ - Add/update needed parameters into tempest.conf file generated by Rally + Calls rally verify and updates the generated tempest.conf with + given parameters """ - tempest_conf_file = os.path.join(deployment_dir, "tempest.conf") - if os.path.isfile(tempest_conf_file): - logger.debug("Verifier is already configured.") - logger.debug("Reconfiguring the current verifier...") - cmd = "rally verify configure-verifier --reconfigure" + conf_verifier_result = configure_verifier(deployment_dir) + if conf_verifier_result == releng_constants.EXIT_RUN_ERROR: + return releng_constants.EXIT_RUN_ERROR else: - logger.info("Configuring the verifier...") - cmd = "rally verify configure-verifier" - ft_utils.execute_command(cmd) + configure_tempest_update_params(conf_verifier_result, + IMAGE_ID, FLAVOR_ID) + return releng_constants.EXIT_OK - logger.debug("Looking for tempest.conf file...") - if not os.path.isfile(tempest_conf_file): - logger.error("Tempest configuration file %s NOT found." - % tempest_conf_file) - return releng_constants.EXIT_RUN_ERROR +def configure_tempest_update_params(tempest_conf_file, + IMAGE_ID=None, FLAVOR_ID=None): + """ + Add/update needed parameters into tempest.conf file + """ logger.debug("Updating selected tempest.conf parameters...") config = ConfigParser.RawConfigParser() config.read(tempest_conf_file) @@ -178,7 +177,29 @@ def configure_tempest(deployment_dir, IMAGE_ID=None, FLAVOR_ID=None): shutil.copyfile(tempest_conf_file, os.path.join(TEMPEST_RESULTS_DIR, 'tempest.conf')) - return releng_constants.EXIT_OK + +def configure_verifier(deployment_dir): + """ + Execute rally verify configure-verifier, which generates tempest.conf + """ + tempest_conf_file = os.path.join(deployment_dir, "tempest.conf") + if os.path.isfile(tempest_conf_file): + logger.debug("Verifier is already configured.") + logger.debug("Reconfiguring the current verifier...") + cmd = "rally verify configure-verifier --reconfigure" + else: + logger.info("Configuring the verifier...") + cmd = "rally verify configure-verifier" + ft_utils.execute_command(cmd) + logger.debug("Looking for tempest.conf file...") + + if not os.path.isfile(tempest_conf_file): + logger.error("Tempest configuration file %s NOT found." + % tempest_conf_file) + return releng_constants.EXIT_RUN_ERROR + + else: + return tempest_conf_file def configure_tempest_multisite(deployment_dir): |