- self._port_number = None
- self._port_number = int(out)
- self.port_info.append(self._port_number)
- self.info("The number of the %s is %s" % (self.get('port_name'), self._port_number))
-
- def switch_connect_command(self, local_port_name,
- remote_ip, remote_port_num):
- """ Script for switch links
+ if out:
+ self._port_number = int(out)
+
+ self.info("The number of the %s is %s" % (self.get('port_name'),
+ self.port_number))
+
+ if remote_endpoint.is_rm_instance("PlanetlabTap"):
+ self._vroute = self.ec.register_resource("PlanetlabVroute")
+ self.ec.set(self._vroute, "action", "add")
+ self.ec.set(self._vroute, "network", self.get("network"))
+
+ print "Vroute Guid :" + str(self._vroute)
+
+ self.ec.register_connection(self._vroute, remote_endpoint.guid)
+ self.ec.deploy(guids=[self._vroute], group = self.deployment_group)
+
+ # For debugging
+ msg = "Route for the tap configured"
+ self.debug(msg)
+
+ return self.port_number
+
+
+ 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
+
+ # For debugging
+ msg = "Connection on port configured"
+ self.debug(msg)
+
+
+ def _establish_connection_command(self, port):
+ """ Script to create the connection from a switch to a
+ remote endpoint