Delete the OVSTunnel to use the UdpTunnel instead. Just need to fix an issue with...
[nepi.git] / src / nepi / resources / linux / udptunnel.py
index 63ae086..1643b90 100644 (file)
@@ -84,7 +84,7 @@ class LinuxUdpTunnel(LinuxTunnel):
         connected = []
         for guid in self.connections:
             rm = self.ec.get_resource(guid)
-            if hasattr(rm, "udp_connect"):
+            if hasattr(rm, "initiate_udp_connection"):
                 connected.append(rm)
         return connected
 
@@ -93,51 +93,33 @@ class LinuxUdpTunnel(LinuxTunnel):
         cipher_key = self.get("cipherKey")
         bwlimit = self.get("bwLimit")
         txqueuelen = self.get("txQueueLen")
-       
-        # Return the command to execute to initiate the connection to the
-        # other endpoint
         connection_app_home = self.app_home(endpoint)
         connection_run_home = self.run_home(endpoint)
-        pid, ppid = endpoint.udp_connect(
+
+        port = endpoint.initiate_udp_connection(
                 remote_endpoint, 
                 connection_app_home,
                 connection_run_home, 
                 cipher, cipher_key, bwlimit, txqueuelen)
 
-        port = self.wait_local_port(endpoint)
-
-        self._pids[endpoint] = (pid, ppid)
-
         return port
 
     def establish_connection(self, endpoint, remote_endpoint, port):
-        self.upload_remote_port(endpoint, port)
+        endpoint.establish_udp_connection(remote_endpoint, port)
 
     def verify_connection(self, endpoint, remote_endpoint):
-        self.wait_result(endpoint)
+        endpoint.verify_connection()
 
     def terminate_connection(self, endpoint, remote_endpoint):
-        pid, ppid = self._pids[endpoint]
-
-        if pid and ppid:
-            (out, err), proc = endpoint.node.kill(pid, ppid, 
-                    sudo = True) 
-
-            # check if execution errors occurred
-            if proc.poll() and err:
-                msg = " Failed to STOP tunnel"
-                self.error(msg, out, err)
-                raise RuntimeError, msg
+        endpoint.terminate_connection()
 
     def check_state_connection(self):
         # Make sure the process is still running in background
         # No execution errors occurred. Make sure the background
         # process with the recorded pid is still running.
-        pid1, ppid1 = self._pids[self.endpoint1]
-        pid2, ppid2 = self._pids[self.endpoint2]
 
-        status1 = self.endpoint1.node.status(pid1, ppid1)
-        status2 = self.endpoint2.node.status(pid2, ppid2)
+        status1 = self.endpoint1.check_status()
+        status2 = self.endpoint2.check_status()
 
         if status1 == ProcStatus.FINISHED and \
                 status2 == ProcStatus.FINISHED:
@@ -191,11 +173,3 @@ class LinuxUdpTunnel(LinuxTunnel):
 
         return result
 
-    def upload_remote_port(self, endpoint, port):
-        # upload remote port number to file
-        port = "%s\n" % port
-        endpoint.node.upload(port,
-                os.path.join(self.run_home(endpoint), "remote_port"),
-                text = True, 
-                overwrite = False)
-