X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=functest%2Fopnfv_tests%2Fsdn%2Fodl%2Fodl.py;h=21c879efb710b16b314720a7ae31123ae190ffad;hb=06b9ace7a0333d723972502ab3ce5784b6cba689;hp=25cc758eab0c4c8b4b376fef4ae632296f2c309e;hpb=81775c2aae62f1f96a54c27eed59cea9f9722de9;p=functest.git diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py index 25cc758ea..21c879efb 100644 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -25,12 +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.core import robotframework -from functest.opnfv_tests.openstack.snaps import snaps_utils -from functest.utils import constants +from functest.utils import config +from functest.utils import env __author__ = "Cedric Ollivier " @@ -38,7 +38,7 @@ __author__ = "Cedric Ollivier " class ODLTests(robotframework.RobotFramework): """ODL test runner.""" - odl_test_repo = constants.CONST.__getattribute__('dir_repo_odl_test') + odl_test_repo = getattr(config.CONF, 'dir_repo_odl_test') neutron_suite_dir = os.path.join( odl_test_repo, "csit/suites/openstack/neutron") basic_suite_dir = os.path.join( @@ -51,7 +51,7 @@ class ODLTests(robotframework.RobotFramework): def __init__(self, **kwargs): super(ODLTests, self).__init__(**kwargs) self.res_dir = os.path.join( - constants.CONST.__getattribute__('dir_results'), 'odl') + getattr(config.CONF, 'dir_results'), 'odl') self.xml_file = os.path.join(self.res_dir, 'output.xml') @classmethod @@ -156,18 +156,20 @@ 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')} - kwargs['odlip'] = urllib.parse.urlparse( - kwargs['neutronurl']).hostname + 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 = None - if 'INSTALLER_TYPE' in os.environ: - installer_type = os.environ['INSTALLER_TYPE'] + installer_type = env.get('INSTALLER_TYPE') kwargs['osusername'] = os.environ['OS_USERNAME'] kwargs['osuserdomainname'] = os.environ.get( 'OS_USER_DOMAIN_NAME', 'Default') @@ -177,26 +179,20 @@ class ODLTests(robotframework.RobotFramework): kwargs['osauthurl'] = os.environ['OS_AUTH_URL'] kwargs['ospassword'] = os.environ['OS_PASSWORD'] if installer_type == 'fuel': - kwargs['odlwebport'] = '8181' + kwargs['odlwebport'] = '8282' kwargs['odlrestconfport'] = '8282' elif installer_type == 'apex' or installer_type == 'netvirt': - kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP'] kwargs['odlwebport'] = '8081' kwargs['odlrestconfport'] = '8081' - elif installer_type == 'joid': - kwargs['odlip'] = os.environ['SDN_CONTROLLER'] elif installer_type == 'compass': kwargs['odlrestconfport'] = '8080' elif installer_type == 'daisy': - kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP'] kwargs['odlwebport'] = '8181' kwargs['odlrestconfport'] = '8087' - else: - kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP'] + 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.")