diff options
Diffstat (limited to 'sfc/lib')
-rw-r--r-- | sfc/lib/config.py | 74 | ||||
-rw-r--r-- | sfc/lib/odl_utils.py | 19 |
2 files changed, 67 insertions, 26 deletions
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) diff --git a/sfc/lib/odl_utils.py b/sfc/lib/odl_utils.py index 459c83ec..2c657a13 100644 --- a/sfc/lib/odl_utils.py +++ b/sfc/lib/odl_utils.py @@ -252,6 +252,25 @@ def get_odl_ip_port(nodes): return ip, port +def get_odl_ip_port_no_installer(nodes_pod): + node_index = 0 + for n in nodes_pod: + if n['role'] == 'Controller': + break + node_index += 1 + remote_ml2_conf_etc = '/etc/neutron/plugins/ml2/ml2_conf.ini' + os.system('scp {0}@{1}:{2} .'. + format(nodes_pod[node_index]['user'], + nodes_pod[node_index]['ip'], + remote_ml2_conf_etc)) + file = open('ml2_conf.ini', 'r') + string = re.findall(r'[0-9]+(?:\.[0-9]+){3}\:[0-9]+', file.read()) + file.close() + ip = string[0].split(':')[0] + port = string[0].split(':')[1] + return ip, port + + def get_odl_username_password(): local_ml2_conf_file = os.path.join(os.getcwd(), 'ml2_conf.ini') con_par = ConfigParser.RawConfigParser() |