-
- def establish_udp_connection(self,remote_endpoint, port):
- establish_connection_command = self._establish_connection_command(port)
-
- # upload command to connect.sh script
- shfile = os.path.join(self.app_home, "sw-connect.sh")
- self.node.upload_command(establish_connection_command,
- shfile = shfile,
- overwrite = False)
-
- # invoke connect script
- cmd = "bash %s" % shfile
- (out, err), proc = self.node.run(cmd, self.run_home,
- sudo = True,
- stdout = "sw_stdout",
- stderr = "sw_stderr")
-
- # check if execution errors occurred
- msg = "Failed to connect endpoints "
- if proc.poll():
- self.error(msg, out, err)
- raise RuntimeError, msg
-
- # Wait for pid file to be generated
- self._pid, self._ppid = self.node.wait_pid(self.run_home)
-
- # If the process is not running, check for error information
- # on the remote machine
- if not self._pid or not self._ppid:
- (out, err), proc = self.node.check_errors(self.run_home)
- # Out is what was written in the stderr file
- if err:
- msg = " Failed to start command '%s' " % command
- self.error(msg, out, err)
- raise RuntimeError, msg
+ def establish_udp_connection(self, remote_endpoint,
+ connection_app_home,
+ connection_run_home,
+ port):
+ remote_ip = remote_endpoint.node.get("ip")
+ command = self._establish_connection_command(port, remote_ip)
+
+ shfile = os.path.join(connection_app_home, "connect_port.sh")
+ (out, err), proc = self.node.run_and_wait(command, connection_run_home,
+ shfile=shfile,
+ sudo=True,
+ overwrite = True,
+ pidfile="connect_port_pidfile",
+ ecodefile="connect_port_exitcode",
+ stdout="connect_port_stdout",
+ stderr="connect_port_stderr")