def test_network_basic_dnat_fip(self):
     server_details = self.servers_and_keys[0]
     hops = [(server_details["FIP"].floating_ip_address, server_details["keypair"]["private_key"])]
     # the access_point server should be the last one in the list
     client = self.setup_tunnel(hops)
     get_ip = client.exec_command("netstat | grep ssh | awk '{print $5}'").split(":")[0]
     http_server = http.myHTTPServer(port=8098, ip=get_ip)
     p = Process(target=http_server.start)
     p.daemon = True
     p.start()
     process = self.netcat_local(get_ip, "6666")
     resp = client.exec_command("curl http://{0}:8098/".format(get_ip))
     self.assertEqual("Hello world!", resp)
     self.assertTrue(self._check_remote_connectivity(client, get_ip, True))
     resp = client.exec_command("echo ping | nc -u -w 2 %s 6666" % get_ip).rstrip()
     process.kill()
     self.kill_me("nc")
     self.assertEqual("pong", resp)
     self._clean_netcat_local()
     LOG.info("test finished, tearing down now ....")
Exemple #2
0
 def test_network_basic_dnat(self):
     ap_details = self.servers_and_keys[-1]
     access_point = ap_details['server']
     networks = access_point['addresses']
     hops = [(ap_details['FIP'].floating_ip_address,
              ap_details['keypair']['private_key'])]
     # the access_point server should be the last one in the list
     ap_client = self.setup_tunnel(hops)
     get_ip = ap_client.exec_command(
         "netstat | grep ssh | awk '{print $5}'").split(':')[0]
     http_server = http.myHTTPServer(port=8089, ip=get_ip)
     p = Process(target=http_server.start)
     p.daemon = True
     p.start()
     process = self.netcat_local(get_ip, '50000')
     element = self.servers_and_keys[0]
     server = element['server']
     name = server['addresses'].keys()[0]
     if any(i in networks.keys() for i in server['addresses'].keys()):
         remote_ip = server['addresses'][name][0]['addr']
         keypair = element['keypair']
         privatekey = keypair['private_key']
         hops.append((remote_ip, privatekey))
         ssh_client = self.setup_tunnel(hops)
         resp = ssh_client.exec_command(
             'curl http://{0}:8089/'.format(get_ip))
         self.assertEqual('Hello world!', resp)
         self._ping_through_gateway(hops, [get_ip])
         resp = ssh_client.exec_command("echo ping | nc -u -w 2 %s 50000" %
                                        get_ip).rstrip()
         self.kill_me('nc')
         process.kill()
         self.assertEqual('pong', resp)
         self._clean_netcat_local()
     else:
         LOG.info("FAIL - No ip connectivity to the server ip: %s" %
                  server.networks[name][0])
         raise Exception("FAIL - No ip for this network : %s" %
                         server.networks)
     LOG.info("test finished, tearing down now ....")
 def test_network_basic_dnat_fip(self):
     server_details = self.servers_and_keys[0]
     hops = [(server_details['FIP'].floating_ip_address,
              server_details['keypair']['private_key'])]
     # the access_point server should be the last one in the list
     client = self.setup_tunnel(hops)
     get_ip = client.exec_command(
         "netstat | grep ssh | awk '{print $5}'").split(':')[0]
     http_server = http.myHTTPServer(port=8098, ip=get_ip)
     p = Process(target=http_server.start)
     p.daemon = True
     p.start()
     process = self.netcat_local(get_ip, '6666')
     resp = client.exec_command('curl http://{0}:8098/'.format(get_ip))
     self.assertEqual('Hello world!', resp)
     self.assertTrue(self._check_remote_connectivity(client, get_ip, True))
     resp = client.exec_command("echo ping | nc -u -w 2 %s 6666" %
                                get_ip).rstrip()
     process.kill()
     self.kill_me('nc')
     self.assertEqual('pong', resp)
     self._clean_netcat_local()
     LOG.info("test finished, tearing down now ....")