diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/functest_utils.py | 11 | ||||
-rwxr-xr-x | utils/openstack_utils.py | 12 |
2 files changed, 19 insertions, 4 deletions
diff --git a/utils/functest_utils.py b/utils/functest_utils.py index ef865bed..41b6485d 100644 --- a/utils/functest_utils.py +++ b/utils/functest_utils.py @@ -341,19 +341,26 @@ def get_deployment_dir(): return deployment_dir -def get_criteria_by_test(testname): +def get_dict_by_test(testname): with open(get_testcases_file()) as f: testcases_yaml = yaml.safe_load(f) for dic_tier in testcases_yaml.get("tiers"): for dic_testcase in dic_tier['testcases']: if dic_testcase['name'] == testname: - return dic_testcase['criteria'] + return dic_testcase logger.error('Project %s is not defined in testcases.yaml' % testname) return None +def get_criteria_by_test(testname): + dict = get_dict_by_test(testname) + if dict: + return dict['criteria'] + return None + + # ---------------------------------------------------------- # # YAML UTILS diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py index e0da7d97..39594a2a 100755 --- a/utils/openstack_utils.py +++ b/utils/openstack_utils.py @@ -28,6 +28,15 @@ logger = ft_logger.Logger("openstack_utils").getLogger() # ********************************************* # CREDENTIALS # ********************************************* +class MissingEnvVar(Exception): + + def __init__(self, var): + self.var = var + + def __str__(self): + return str.format("Please set the mandatory env var: {}", self.var) + + def check_credentials(): """ Check if the OpenStack credentials (openrc) are sourced @@ -51,8 +60,7 @@ def get_credentials(service): envvars = ('OS_USERNAME', 'OS_PASSWORD', 'OS_AUTH_URL', 'OS_TENANT_NAME') for envvar in envvars: if os.getenv(envvar) is None: - logger.error("'%s' is not exported as an env variable." % envvar) - exit(-1) + raise MissingEnvVar(envvar) # Unfortunately, each of the OpenStack client will request slightly # different entries in their credentials dict. |