FdNetDevice working with PlanetLab TAPs
[nepi.git] / src / nepi / resources / planetlab / vroute.py
index 699c639..fe9c952 100644 (file)
@@ -39,12 +39,21 @@ class PlanetlabVroute(LinuxApplication):
     def _register_attributes(cls):
         action = Attribute("action", "Either add or del",
               allowed = ["add", "del"],
+              default = "add",
+              flags = Flags.Design)
+
+        prefix = Attribute("prefix", "IPv4 Prefix",
+              flags = Flags.Design)
+
+        nexthop = Attribute("nexthop", "IPv4 Address of the next hop",
               flags = Flags.Design)
 
         network = Attribute("network", "IPv4 Network Address",
               flags = Flags.Design)
 
         cls._register_attribute(action)
+        cls._register_attribute(prefix)
+        cls._register_attribute(nexthop)
         cls._register_attribute(network)
 
     def __init__(self, ec, guid):
@@ -65,7 +74,8 @@ class PlanetlabVroute(LinuxApplication):
 
     def upload_sources(self):
         # upload vif-creation python script
-        pl_vroute = os.path.join(os.path.dirname(__file__), "scripts",
+        pl_vroute = os.path.join(os.path.dirname(__file__), 
+                "scripts",
                 "pl-vroute.py")
 
         self.node.upload(pl_vroute,
@@ -86,10 +96,12 @@ class PlanetlabVroute(LinuxApplication):
         # Overwrite file every time. 
         # The stop.sh has the path to the socket, wich should change
         # on every experiment run.
-        super(PlanetlabVroute, self).upload_start_command(overwrite = True)
-
-        (out, err), proc = self.execute_command(self.get("command"), blocking = True)
+        command = self.get("command")
+        shfile = os.path.join(self.app_home, "start.sh")
+        self.node.run_and_wait(command, self.run_home,
+                shfile=shfile,
+                overwrite=True)
+  
     def do_deploy(self):
         if not self.tap or self.tap.state < ResourceState.PROVISIONED:
             self.ec.schedule(self.reschedule_delay, self.deploy)
@@ -147,20 +159,26 @@ class PlanetlabVroute(LinuxApplication):
         command = ["sudo -S python ${SRC}/pl-vroute.py"]
         command.append("-a %s" % self.get("action"))
         command.append("-n %s" % self.get("network"))
-        command.append("-p %s" % self.tap.get("prefix"))
+        command.append("-p %s" % self.get("prefix"))
         command.append("-g %s" % self.tap.get("pointopoint"))
         command.append("-f %s" % self.tap.get("deviceName"))
-        return " ".join(command)
+        command = " ".join(command)
+
+        command = self.replace_paths(command)
+        return command
 
     @property
     def _stop_command(self):
         command = ["sudo -S python ${SRC}/pl-vroute.py"]
         command.append("-a %s" % "del")
         command.append("-n %s" % self.get("network"))
-        command.append("-p %s" % self.tap.get("prefix"))
-        command.append("-g %s" % self.tap.get("pointopoint"))
+        command.append("-p %s" % self.get("prefix"))
+        command.append("-g %s" % self.get("nexthop"))
         command.append("-f %s" % self.tap.get("deviceName"))
-        return " ".join(command)
+        command = " ".join(command)
+        
+        command = self.replace_paths(command)
+        return command
 
     def valid_connection(self, guid):
         # TODO: Validate!