+ def gre_connect(self, remote_endpoint, connection_app_home,
+ connection_run_home):
+ gre_connect_command = self._gre_connect_command(
+ remote_endpoint, connection_run_home)
+
+ # upload command to connect.sh script
+ shfile = os.path.join(connection_app_home, "gre-connect.sh")
+ self.node.upload_command(gre_connect_command,
+ shfile = shfile,
+ overwrite = False)
+
+ # invoke connect script
+ cmd = "bash %s" % shfile
+ (out, err), proc = self.node.run(cmd, connection_run_home)
+
+ # check if execution errors occurred
+ msg = " Failed to connect endpoints "
+
+ if proc.poll() or err:
+ self.error(msg, out, err)
+ raise RuntimeError, msg
+
+ # Wait for pid file to be generated
+ pid, ppid = self.node.wait_pid(connection_run_home)
+
+ # If the process is not running, check for error information
+ # on the remote machine
+ if not pid or not ppid:
+ (out, err), proc = self.node.check_errors(connection_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
+
+ # After creating the TAP, the pl-vif-create.py script
+ # will write the name of the TAP to a file. We wait until
+ # we can read the interface name from the file.
+ vif_name = self.wait_vif_name(exec_run_home = connection_run_home)
+ self.set("deviceName", vif_name)
+
+ return True
+
+ def udp_connect(self, remote_endpoint, connection_app_home,
+ connection_run_home, cipher, cipher_key, bwlimit, txqueuelen):
+ udp_connect_command = self._udp_connect_command(
+ remote_endpoint, connection_run_home,
+ cipher, cipher_key, bwlimit, txqueuelen)
+
+ # upload command to connect.sh script
+ shfile = os.path.join(connection_app_home, "udp-connect.sh")
+ self.node.upload_command(udp_connect_command,
+ shfile = shfile,
+ overwrite = False)
+
+ # invoke connect script
+ cmd = "bash %s" % shfile
+ (out, err), proc = self.node.run(cmd, connection_run_home)
+
+ # 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
+ pid, ppid = self.node.wait_pid(connection_run_home)
+
+ # If the process is not running, check for error information
+ # on the remote machine
+ if not pid or not ppid:
+ (out, err), proc = self.node.check_errors(connection_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
+
+ return pid, ppid
+
+ def _udp_connect_command(self, remote_endpoint, connection_run_home,
+ cipher, cipher_key, bwlimit, txqueuelen):
+
+ # Set the remote endpoint
+ self.set("pointopoint", remote_endpoint.get("endpoint_ip"))
+
+ remote_ip = remote_endpoint.node.get("ip")
+
+ local_port_file = os.path.join(connection_run_home,
+ "local_port")
+
+ remote_port_file = os.path.join(connection_run_home,
+ "remote_port")
+
+ ret_file = os.path.join(connection_run_home,
+ "ret_file")
+
+ # Generate UDP connect command
+ # Use pl-vif-up.py script to configure TAP with peer info
+ vif_up_command = self._vif_up_command
+
+ command = ["( "]
+ command.append(vif_up_command)
+
+ # Use pl-vid-udp-connect.py to stablish the tunnel between endpoints
+ command.append(") & (")
+ command.append("sudo -S")