From b5c8c8e7a782099cc9f0c53324ae16f321203e16 Mon Sep 17 00:00:00 2001 From: Panagiotis Karalis Date: Fri, 5 Apr 2019 19:29:50 +0300 Subject: Allow TCs to consume config info from user's file The SFC TCs are bound by the installers. This means that the SFC TCs could not run on server or VM which all components (e.g. OS, ODL, etc) are deployed manually and not by an installer, because some information are retrieved directly from installer through deploy factory module. A new yaml file is created by user in order for the important information to be consumed by the respective test scenario during test execution. JIRA: SFC-142 Change-Id: I051bb6406b8aa433c19e4df10396b4789448d42b Signed-off-by: Panagiotis Karalis --- sfc/lib/config.py | 74 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 26 deletions(-) (limited to 'sfc/lib/config.py') diff --git a/sfc/lib/config.py b/sfc/lib/config.py index 507142c9..bf9864a5 100644 --- a/sfc/lib/config.py +++ b/sfc/lib/config.py @@ -46,33 +46,55 @@ class CommonConfig(object): self.config_file = os.path.join(self.sfc_test_dir, "config.yaml") self.vim_file = os.path.join(self.sfc_test_dir, "register-vim.json") - self.installer_type = env.get('INSTALLER_TYPE') - - self.installer_fields = test_utils.fill_installer_dict( - self.installer_type) - - self.installer_ip = env.get('INSTALLER_IP') - - self.installer_user = ft_utils.get_parameter_from_yaml( - self.installer_fields['user'], self.config_file) - - try: - self.installer_password = ft_utils.get_parameter_from_yaml( - self.installer_fields['password'], self.config_file) - except Exception: - self.installer_password = None - - try: - self.installer_key_file = ft_utils.get_parameter_from_yaml( - self.installer_fields['pkey_file'], self.config_file) - except Exception: - self.installer_key_file = None - - try: - self.installer_cluster = ft_utils.get_parameter_from_yaml( - self.installer_fields['cluster'], self.config_file) - except Exception: + pod_yaml_exists = os.path.isfile(self.sfc_test_dir + "/pod.yaml") + + if pod_yaml_exists: + self.pod_file = os.path.join(self.sfc_test_dir, "pod.yaml") + self.nodes_pod = ft_utils.get_parameter_from_yaml( + "nodes", self.pod_file) + self.host_ip = self.nodes_pod[0]['ip'] + self.host_user = self.nodes_pod[0]['user'] + + self.installer_type = 'configByUser' + self.installer_ip = self.host_ip + self.installer_user = self.host_user self.installer_cluster = None + try: + self.installer_password = self.host_ip[0]['password'] + except Exception: + self.installer_password = None + + try: + self.installer_key_file = self.host_ip[0]['key_filename'] + except Exception: + self.installer_key_file = None + else: + self.nodes_pod = None + self.host_ip = None + self.installer_type = env.get('INSTALLER_TYPE') + self.installer_fields = test_utils.fill_installer_dict( + self.installer_type) + self.installer_ip = env.get('INSTALLER_IP') + self.installer_user = ft_utils.get_parameter_from_yaml( + self.installer_fields['user'], self.config_file) + + try: + self.installer_password = ft_utils.get_parameter_from_yaml( + self.installer_fields['password'], self.config_file) + except Exception: + self.installer_password = None + + try: + self.installer_key_file = ft_utils.get_parameter_from_yaml( + self.installer_fields['pkey_file'], self.config_file) + except Exception: + self.installer_key_file = None + + try: + self.installer_cluster = ft_utils.get_parameter_from_yaml( + self.installer_fields['cluster'], self.config_file) + except Exception: + self.installer_cluster = None self.flavor = ft_utils.get_parameter_from_yaml( "defaults.flavor", self.config_file) -- cgit 1.2.3-korg