+ def establish_udp_connection(self, remote_endpoint, port):
+ # upload remote port number to file
+ rem_port = "%s\n" % port
+ self.node.upload(rem_port,
+ os.path.join(self.run_home, "remote_port"),
+ text = True,
+ overwrite = False)
+
+ def verify_connection(self):
+ self.wait_result()
+
+ def terminate_connection(self):
+ 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_local_port(self):
+ """ Waits until the local_port file for the endpoint is generated,
+ and returns the port number
+
+ """
+ return self.wait_file("local_port")
+
+ def wait_result(self):
+ """ Waits until the return code file for the endpoint is generated
+
+ """
+ return self.wait_file("ret_file")
+
+ def wait_file(self, 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(
+ self.run_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
+
+
+