From 904377462f58464937d4cafeb8c432f024a85bd4 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Sun, 14 Oct 2018 12:08:03 +0200 Subject: Fix image properties parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It removes useless spaces and now conforms with oslo.conf dict. New helpers and unit tests are available. Change-Id: I20335c5e5c3840cc872e158c6072d97a3f2cb98c Signed-off-by: Cédric Ollivier --- functest/opnfv_tests/openstack/tempest/conf_utils.py | 19 +++---------------- functest/opnfv_tests/openstack/tempest/tempest.py | 8 ++++---- 2 files changed, 7 insertions(+), 20 deletions(-) (limited to 'functest/opnfv_tests/openstack/tempest') diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index fc36a72ed..60d7f3218 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -19,12 +19,12 @@ import os import subprocess import pkg_resources -import six from six.moves import configparser import yaml from functest.utils import config from functest.utils import env +from functest.utils import functest_utils RALLY_CONF_PATH = "/etc/rally/rally.conf" @@ -201,13 +201,13 @@ def configure_tempest_update_params( 'ServerGroupAntiAffinityFilter', 'ServerGroupAffinityFilter'] rconfig.set( 'compute-feature-enabled', 'scheduler_available_filters', - convert_list_to_ini(filters)) + functest_utils.convert_list_to_ini(filters)) if os.environ.get('OS_REGION_NAME'): rconfig.set('identity', 'region', os.environ.get('OS_REGION_NAME')) if env.get("NEW_USER_ROLE").lower() != "member": rconfig.set( 'auth', 'tempest_roles', - convert_list_to_ini([env.get("NEW_USER_ROLE")])) + functest_utils.convert_list_to_ini([env.get("NEW_USER_ROLE")])) if not json.loads(env.get("USE_DYNAMIC_CREDENTIALS").lower()): rconfig.set('auth', 'use_dynamic_credentials', False) account_file = os.path.join( @@ -269,16 +269,3 @@ def configure_verifier(deployment_dir): tempest_conf_file) return None return tempest_conf_file - - -def convert_dict_to_ini(value): - "Convert dict to oslo.conf input" - assert isinstance(value, dict) - return ",".join("{}:{}".format( - key, val) for (key, val) in six.iteritems(value)) - - -def convert_list_to_ini(value): - "Convert list to oslo.conf input" - assert isinstance(value, list) - return ",".join("{}".format(val) for val in value) diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index c2ff98f6c..910b54615 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -27,6 +27,7 @@ from functest.core import singlevm from functest.opnfv_tests.openstack.tempest import conf_utils from functest.utils import config from functest.utils import env +from functest.utils import functest_utils LOGGER = logging.getLogger(__name__) @@ -384,15 +385,14 @@ class TempestCommon(singlevm.VmReady2): extra_properties = self.extra_properties.copy() if env.get('IMAGE_PROPERTIES'): extra_properties.update( - dict((k.strip(), v.strip()) for k, v in ( - item.split(': ') for item in env.get( - 'IMAGE_PROPERTIES').split(',')))) + functest_utils.convert_ini_to_dict( + env.get('IMAGE_PROPERTIES'))) extra_properties.update( getattr(config.CONF, '{}_extra_properties'.format( self.case_name), {})) rconfig.set( 'scenario', 'img_properties', - conf_utils.convert_dict_to_ini(extra_properties)) + functest_utils.convert_dict_to_ini(extra_properties)) with open(self.conf_file, 'wb') as config_file: rconfig.write(config_file) -- cgit 1.2.3-korg