aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtestcases/Controllers/ODL/OpenDaylightTesting.py27
-rwxr-xr-xutils/openstack_utils.py12
2 files changed, 25 insertions, 14 deletions
diff --git a/testcases/Controllers/ODL/OpenDaylightTesting.py b/testcases/Controllers/ODL/OpenDaylightTesting.py
index 0ee37b64b..591faac5c 100755
--- a/testcases/Controllers/ODL/OpenDaylightTesting.py
+++ b/testcases/Controllers/ODL/OpenDaylightTesting.py
@@ -143,19 +143,19 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
return self.EX_RUN_ERROR
def run(self):
- kclient = op_utils.get_keystone_client()
- keystone_url = kclient.service_catalog.url_for(
- service_type='identity', endpoint_type='publicURL')
- neutron_url = kclient.service_catalog.url_for(
- service_type='network', endpoint_type='publicURL')
- kwargs = {'keystoneip': urlparse.urlparse(keystone_url).hostname}
- kwargs['neutronip'] = urlparse.urlparse(neutron_url).hostname
- kwargs['odlip'] = kwargs['neutronip']
- kwargs['odlwebport'] = '8080'
- kwargs['odlrestconfport'] = '8181'
- kwargs['odlusername'] = 'admin'
- kwargs['odlpassword'] = 'admin'
try:
+ kclient = op_utils.get_keystone_client()
+ keystone_url = kclient.service_catalog.url_for(
+ service_type='identity', endpoint_type='publicURL')
+ neutron_url = kclient.service_catalog.url_for(
+ service_type='network', endpoint_type='publicURL')
+ kwargs = {'keystoneip': urlparse.urlparse(keystone_url).hostname}
+ kwargs['neutronip'] = urlparse.urlparse(neutron_url).hostname
+ kwargs['odlip'] = kwargs['neutronip']
+ kwargs['odlwebport'] = '8080'
+ kwargs['odlrestconfport'] = '8181'
+ kwargs['odlusername'] = 'admin'
+ kwargs['odlpassword'] = 'admin'
installer_type = os.environ['INSTALLER_TYPE']
kwargs['osusername'] = os.environ['OS_USERNAME']
kwargs['ostenantname'] = os.environ['OS_TENANT_NAME']
@@ -176,6 +176,9 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
"Please check env var: "
"%s" % str(e))
return self.EX_RUN_ERROR
+ except Exception:
+ self.logger.exception("Cannot run ODL testcases.")
+ return self.EX_RUN_ERROR
return self.main(**kwargs)
diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py
index e0da7d97d..39594a2a9 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.