+ raise RuntimeError(msg)
+
+ return self.wait_file(connection_run_home, "local_port")
+
+ def establish_udp_connection(self, remote_endpoint,
+ connection_app_home, connection_run_home, port):
+ # upload remote port number to file
+ rem_port = "%s\n" % port
+ self.node.upload(rem_port,
+ os.path.join(connection_run_home, "remote_port"),
+ text = True,
+ overwrite = False)
+
+ def verify_connection(self, remote_endpoint,
+ connection_app_home, connection_run_home):
+
+ return self.wait_file(connection_run_home, "ret_file")
+
+ def terminate_connection(self, remote_endpoint,
+ connection_app_home, connection_run_home):
+ if self._pid and self._ppid:
+ (out, err), proc = self.node.kill(self._pid, self._ppid,
+ sudo = True)
+
+ # check if execution errors occurred
+ if proc.poll() and err:
+ msg = " Failed to Kill the Tap"
+ self.error(msg, out, err)
+ raise RuntimeError(msg)
+
+ def check_status(self):
+ return self.node.status(self._pid, self._ppid)
+
+ def wait_file(self, home, filename):
+ """ Waits until file on endpoint is generated """
+ result = None
+ delay = 1.0
+
+ for i in xrange(20):
+ (out, err), proc = self.node.check_output(home, filename)
+ if out:
+ result = out.strip()
+ break
+ else:
+ time.sleep(delay)
+ delay = delay * 1.5
+ else:
+ msg = "Couldn't retrieve %s" % filename
+ self.error(msg, out, err)
+ raise RuntimeError(msg)
+
+ return result
+
+ @property
+ def _start_command(self):
+ if self.gre_enabled:
+ command = []
+ else:
+ command = ["sudo -S "]
+ command.append("PYTHONPATH=$PYTHONPATH:${SRC}")
+ command.append("python ${SRC}/linux-tap-create.py")
+ command.append("-t %s" % self.vif_type)
+ command.append("-a %s" % self.get("ip"))
+ command.append("-n %s" % self.get("prefix"))
+ command.append("-N %s " % self.get("deviceName"))
+ command.append("-S %s " % self.sock_name)
+ if self.get("pi"):
+ command.append("-p")
+
+ return " ".join(command)
+
+ @property
+ def _stop_command(self):
+ if self.gre_enabled:
+ command = self._stop_gre_command
+ else:
+ command = ["sudo -S "]
+ command.append("PYTHONPATH=$PYTHONPATH:${SRC}")
+ command.append("python ${SRC}/linux-tap-delete.py")
+ command.append("-N %s " % self.get("deviceName"))
+ command.append("-S %s " % self.sock_name)
+ command = " ".join(command)
+
+ return command