def _verify_vpn_connection(self, local_index, peer_index): """Verifies the vpn connectivity between the endpoints :param local_index: parameter to point to the local end-point :param peer_index: parameter to point to the peer end-point :return: True or False """ qg = vpn_utils.get_interfaces(self.snat_namespaces[peer_index]) if qg: p = re.compile(r"qg-\w+-\w+") m = p.search(qg) if m: qg_interface = m.group() else: qg_interface = None if qg_interface: with concurrent.futures.ThreadPoolExecutor(max_workers=2) as e: tcpdump_future = e.submit(vpn_utils.start_tcpdump, self.snat_namespaces[peer_index], qg_interface) ssh_future = e.submit(vpn_utils.ssh_and_ping_server, self.server_private_ips[local_index], self.server_private_ips[peer_index], self.qrouter_namespaces[local_index], self.key_file_paths[local_index]) assert(ssh_future.result()), "SSH/Ping failed" lines = tcpdump_future.result().split('\n') for line in lines: if 'ESP' in line: return True return False
def _get_qg_interface(self, peer_index): """Get the qg- interface :param peer_index: parameter to point to the local end-point :return: qg-interface """ qg = vpn_utils.get_interfaces(self.ns_controller_tuples[peer_index], self.private_key_file) p = re.compile(r"qg-\w+-\w+") for line in qg: m = p.search(line) if m: return m.group() return None
def _get_qg_interface(self, peer_index): """Get the qg- interface :param peer_index: parameter to point to the local end-point :return: qg-interface """ qg = vpn_utils.get_interfaces( self.ns_controller_tuples[peer_index], self.private_key_file) p = re.compile(r"qg-\w+-\w+") for line in qg: m = p.search(line) if m: return m.group() return None