Before making XOS rest api calls, get the xos credentials from ONOS network cfg.
Change-Id: I094bd98983171d8562c15c4a2c3f26145d07af01
diff --git a/src/test/vsg/vsgTest.py b/src/test/vsg/vsgTest.py
index 1f9aafe..1b1e1ff 100644
--- a/src/test/vsg/vsgTest.py
+++ b/src/test/vsg/vsgTest.py
@@ -24,6 +24,7 @@
from CordLogger import CordLogger
from VSGAccess import VSGAccess
from CordTestUtils import log_test as log
+from OnosCtrl import OnosCtrl
log.setLevel('INFO')
@@ -43,6 +44,27 @@
subscriber_account_num_base = 200
@classmethod
+ def getXosCredentials(cls):
+ onos_cfg = OnosCtrl.get_config()
+ if onos_cfg is None:
+ return None
+ if 'apps' in onos_cfg and \
+ 'org.opencord.vtn' in onos_cfg['apps'] and \
+ 'cordvtn' in onos_cfg['apps']['org.opencord.vtn'] and \
+ 'xos' in onos_cfg['apps']['org.opencord.vtn']['cordvtn']:
+ xos_cfg = onos_cfg['apps']['org.opencord.vtn']['cordvtn']['xos']
+ endpoint = xos_cfg['endpoint']
+ user = xos_cfg['user']
+ password = xos_cfg['password']
+ xos_endpoints = endpoint.split(':')
+ xos_host = xos_endpoints[1][len('//'):]
+ xos_port = xos_endpoints[2][:-1]
+ #log.info('xos_host: %s, port: %s, user: %s, password: %s' %(xos_host, xos_port, user, password))
+ return dict(host = xos_host, port = xos_port, user = user, password = password)
+
+ return None
+
+ @classmethod
def setUpCordApi(cls):
our_path = os.path.dirname(os.path.realpath(__file__))
cord_api_path = os.path.join(our_path, '..', 'cord-api')
@@ -75,7 +97,15 @@
sys.path.append(framework_path)
from restApi import restApi
restApiXos = restApi()
- restApiXos.controllerIP = cls.HEAD_NODE
+ xos_credentials = cls.getXosCredentials()
+ if xos_credentials is None:
+ restApiXos.controllerIP = cls.HEAD_NODE
+ restApiXos.controllerPort = '9000'
+ else:
+ restApiXos.controllerIP = xos_credentials['host']
+ restApiXos.controllerPort = xos_credentials['port']
+ restApiXos.user = xos_credentials['user']
+ restApiXos.password = xos_credentials['password']
cls.restApiXos = restApiXos
@classmethod