aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/sdn/odl/odl.py
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests/sdn/odl/odl.py')
-rw-r--r--functest/opnfv_tests/sdn/odl/odl.py60
1 files changed, 25 insertions, 35 deletions
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index 7c61e88df..72c38ce2c 100644
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -25,13 +25,12 @@ import os
import re
import sys
+import os_client_config
from six.moves import urllib
-from snaps.openstack.utils import keystone_utils
+from xtesting.core import robotframework
-from functest.opnfv_tests.openstack.snaps import snaps_utils
from functest.utils import config
from functest.utils import env
-from xtesting.core import robotframework
__author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
@@ -50,7 +49,7 @@ class ODLTests(robotframework.RobotFramework):
__logger = logging.getLogger(__name__)
def __init__(self, **kwargs):
- super(ODLTests, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.res_dir = os.path.join(
getattr(config.CONF, 'dir_results'), 'odl')
self.xml_file = os.path.join(self.res_dir, 'output.xml')
@@ -67,10 +66,10 @@ class ODLTests(robotframework.RobotFramework):
try:
for line in fileinput.input(cls.odl_variables_file,
inplace=True):
- print(re.sub("@{AUTH}.*",
- "@{{AUTH}} {} {}".format(
- odlusername, odlpassword),
- line.rstrip()))
+ print(re.sub(
+ "@{AUTH}.*",
+ f"@{{AUTH}} {odlusername} {odlpassword}",
+ line.rstrip()))
return True
except Exception: # pylint: disable=broad-except
cls.__logger.exception("Cannot set ODL creds:")
@@ -112,9 +111,8 @@ class ODLTests(robotframework.RobotFramework):
odlusername = kwargs['odlusername']
odlpassword = kwargs['odlpassword']
osauthurl = kwargs['osauthurl']
- keystoneurl = "{}://{}".format(
- urllib.parse.urlparse(osauthurl).scheme,
- urllib.parse.urlparse(osauthurl).netloc)
+ keystoneurl = (f"{urllib.parse.urlparse(osauthurl).scheme}://"
+ f"{urllib.parse.urlparse(osauthurl).netloc}")
variable = ['KEYSTONEURL:' + keystoneurl,
'NEUTRONURL:' + kwargs['neutronurl'],
'OS_AUTH_URL:"' + osauthurl + '"',
@@ -136,7 +134,7 @@ class ODLTests(robotframework.RobotFramework):
else:
if not self.set_robotframework_vars(odlusername, odlpassword):
return self.EX_RUN_ERROR
- return super(ODLTests, self).run(variable=variable, suites=suites)
+ return super().run(variable=variable, suites=suites)
def run(self, **kwargs):
"""Run suites in OPNFV environment
@@ -157,15 +155,19 @@ class ODLTests(robotframework.RobotFramework):
suites = kwargs["suites"]
except KeyError:
pass
- snaps_creds = snaps_utils.get_credentials()
- kwargs = {'neutronurl': keystone_utils.get_endpoint(
- snaps_creds, 'network')}
+ cloud = os_client_config.make_shade()
+ neutron_id = cloud.search_services('neutron')[0].id
+ endpoint = cloud.search_endpoints(
+ filters={
+ 'interface': os.environ.get(
+ 'OS_INTERFACE', 'public').replace('URL', ''),
+ 'service_id': neutron_id})[0].url
+ kwargs = {'neutronurl': endpoint}
kwargs['odlip'] = env.get('SDN_CONTROLLER_IP')
- kwargs['odlwebport'] = '8080'
- kwargs['odlrestconfport'] = '8181'
- kwargs['odlusername'] = 'admin'
- kwargs['odlpassword'] = 'admin'
- installer_type = env.get('INSTALLER_TYPE')
+ kwargs['odlwebport'] = env.get('SDN_CONTROLLER_WEBPORT')
+ kwargs['odlrestconfport'] = env.get('SDN_CONTROLLER_RESTCONFPORT')
+ kwargs['odlusername'] = env.get('SDN_CONTROLLER_USER')
+ kwargs['odlpassword'] = env.get('SDN_CONTROLLER_PASSWORD')
kwargs['osusername'] = os.environ['OS_USERNAME']
kwargs['osuserdomainname'] = os.environ.get(
'OS_USER_DOMAIN_NAME', 'Default')
@@ -174,22 +176,10 @@ class ODLTests(robotframework.RobotFramework):
'OS_PROJECT_DOMAIN_NAME', 'Default')
kwargs['osauthurl'] = os.environ['OS_AUTH_URL']
kwargs['ospassword'] = os.environ['OS_PASSWORD']
- if installer_type == 'fuel':
- kwargs['odlwebport'] = '8282'
- kwargs['odlrestconfport'] = '8282'
- elif installer_type == 'apex' or installer_type == 'netvirt':
- kwargs['odlwebport'] = '8081'
- kwargs['odlrestconfport'] = '8081'
- elif installer_type == 'compass':
- kwargs['odlrestconfport'] = '8080'
- elif installer_type == 'daisy':
- kwargs['odlwebport'] = '8181'
- kwargs['odlrestconfport'] = '8087'
assert kwargs['odlip']
except KeyError as ex:
- self.__logger.error("Cannot run ODL testcases. "
- "Please check env var: "
- "%s", str(ex))
+ self.__logger.error(
+ "Cannot run ODL testcases. Please check env var: %s", str(ex))
return self.EX_RUN_ERROR
except Exception: # pylint: disable=broad-except
self.__logger.exception("Cannot run ODL testcases.")
@@ -198,7 +188,7 @@ class ODLTests(robotframework.RobotFramework):
return self.run_suites(suites, **kwargs)
-class ODLParser(object): # pylint: disable=too-few-public-methods
+class ODLParser(): # pylint: disable=too-few-public-methods
"""Parser to run ODL test suites."""
def __init__(self):