From 3e3c96b2aa15d7757f281ce00518a67e2a1225a9 Mon Sep 17 00:00:00 2001 From: helenyao Date: Mon, 21 Nov 2016 06:50:06 -0500 Subject: Extracted all global parameters into functest_constants.py JIRA: FUNCTEST-533 1. Extracted all global variables into functest_constants.py and updated all affected areas accordingly 2. Used os.path.join to replace '/' to come up with the path for better cross-platform support and improve the path accuracy 3. Removed unused variables 4. Updated the hardcoded path in Dockerfile by using variable reference 5. Removed "/" ending from all path variables 6. Updated the unit test Change-Id: Ib30a81d1f0c83fbaef042d63c187c27bd18301bb Signed-off-by: helenyao --- .../ONOS/Teston/adapters/environment.py | 4 +- .../Controllers/ONOS/Teston/adapters/foundation.py | 46 ++++++++++------------ 2 files changed, 22 insertions(+), 28 deletions(-) (limited to 'functest/opnfv_tests/Controllers/ONOS/Teston/adapters') diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py index f2755b66..01f70b85 100644 --- a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py +++ b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py @@ -141,8 +141,8 @@ class environment(connection): result = self.CheckSshNoPasswd(host) if not result: self.logger.info( - "ssh login failed,try to copy master publickey" + - "to agent " + str(host)) + "ssh login failed,try to copy master publickey" + + "to agent " + str(host)) self.CopyPublicKey(host) self.OnosPushKeys(handle, "onos-push-keys " + self.OCT, masterpass) self.OnosPushKeys(handle, "onos-push-keys " + self.OC1, agentpass) diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py index 603e9933..6f7a40ff 100644 --- a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py +++ b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py @@ -17,6 +17,7 @@ import os import re import time +import functest.utils.functest_constants as ft_constants import functest.utils.functest_utils as ft_utils @@ -25,8 +26,8 @@ class foundation: def __init__(self): # currentpath = os.getcwd() - REPO_PATH = ft_utils.FUNCTEST_REPO + '/' - currentpath = REPO_PATH + 'opnfv_tests/Controllers/ONOS/Teston/CI' + currentpath = \ + ft_constants.FUNCTEST_TEST_DIR + '/Controllers/ONOS/Teston/CI' self.cipath = currentpath self.logdir = os.path.join(currentpath, 'log') self.workhome = currentpath[0: currentpath.rfind('opnfv_tests') - 1] @@ -54,30 +55,23 @@ class foundation: """ Get Default Parameters value """ - self.Result_DB = str( - ft_utils.get_functest_config('results.test_db_url')) - self.masterusername = str( - ft_utils.get_functest_config('ONOS.general.onosbench_username')) - self.masterpassword = str( - ft_utils.get_functest_config('ONOS.general.onosbench_password')) - self.agentusername = str( - ft_utils.get_functest_config('ONOS.general.onoscli_username')) - self.agentpassword = str( - ft_utils.get_functest_config('ONOS.general.onoscli_password')) - self.runtimeout = \ - ft_utils.get_functest_config('ONOS.general.runtimeout') - self.OCT = str(ft_utils.get_functest_config('ONOS.environment.OCT')) - self.OC1 = str(ft_utils.get_functest_config('ONOS.environment.OC1')) - self.OC2 = str(ft_utils.get_functest_config('ONOS.environment.OC2')) - self.OC3 = str(ft_utils.get_functest_config('ONOS.environment.OC3')) - self.OCN = str(ft_utils.get_functest_config('ONOS.environment.OCN')) - self.OCN2 = str(ft_utils.get_functest_config('ONOS.environment.OCN2')) - self.installer_master = str( - ft_utils.get_functest_config('ONOS.environment.installer_master')) - self.installer_master_username = str(ft_utils.get_functest_config( - 'ONOS.environment.installer_master_username')) - self.installer_master_password = str(ft_utils.get_functest_config( - 'ONOS.environment.installer_master_password')) + self.Result_DB = str(ft_utils.get_db_url()) + self.masterusername = str(ft_constants.ONOSBENCH_USERNAME) + self.masterpassword = str(ft_constants.ONOSBENCH_PASSWORD) + self.agentusername = str(ft_constants.ONOSCLI_USERNAME) + self.agentpassword = str(ft_constants.ONOSCLI_PASSWORD) + self.runtimeout = ft_constants.ONOS_RUNTIMEOUT + self.OCT = str(ft_constants.ONOS_OCT) + self.OC1 = str(ft_constants.ONOS_OC1) + self.OC2 = str(ft_constants.ONOS_OC2) + self.OC3 = str(ft_constants.ONOS_OC3) + self.OCN = str(ft_constants.ONOS_OCN) + self.OCN2 = str(ft_constants.ONOS_OCN2) + self.installer_master = str(ft_constants.ONOS_INSTALLER_MASTER) + self.installer_master_username = \ + str(ft_constants.ONOS_INSTALLER_MASTER_USERNAME) + self.installer_master_password = \ + ft_constants.ONOS_INSTALLER_MASTER_PASSWORD self.hosts = [self.OC1, self.OCN, self.OCN2] self.localhost = self.OCT -- cgit 1.2.3-korg