Changed the endpoint_ip and endpoint_prefix attributes of TAP/TUN endpoints for ip...
[nepi.git] / src / nepi / resources / planetlab / tap.py
index e59e94a..2f2975a 100644 (file)
@@ -36,7 +36,7 @@ class PlanetlabTap(LinuxApplication):
 
     @classmethod
     def _register_attributes(cls):
-        endpoint_ip = Attribute("endpoint_ip", "IP of the endpoint. This is the attribute " 
+        ip = Attribute("ip", "IP of the endpoint. This is the attribute " 
                                 "you should use to establish a tunnel or a remote "
                                 "connection between endpoint",
               flags = Flags.Design)
@@ -44,8 +44,7 @@ class PlanetlabTap(LinuxApplication):
         mac = Attribute("mac", "MAC Address",
                 flags = Flags.Design)
 
-        endpoint_prefix = Attribute("endpoint_prefix", "IPv4 network prefix of the endpoint",
-                type = Types.Integer,
+        prefix = Attribute("prefix", "IPv4 network prefix of the endpoint",
                 flags = Flags.Design)
 
         mtu = Attribute("mtu", "Maximum transmition unit for device",
@@ -84,9 +83,9 @@ class PlanetlabTap(LinuxApplication):
                 "Bash script to be executed before releasing the resource",
                 flags = Flags.Design)
 
-        cls._register_attribute(endpoint_ip)
+        cls._register_attribute(ip)
         cls._register_attribute(mac)
-        cls._register_attribute(endpoint_prefix)
+        cls._register_attribute(prefix)
         cls._register_attribute(mtu)
         cls._register_attribute(devname)
         cls._register_attribute(up)
@@ -342,14 +341,12 @@ class PlanetlabTap(LinuxApplication):
 
         return True
 
-
     def initiate_udp_connection(self, remote_endpoint, connection_app_home, 
             connection_run_home, cipher, cipher_key, bwlimit, txqueuelen):
         port = self.udp_connect(remote_endpoint, connection_app_home, 
             connection_run_home, cipher, cipher_key, bwlimit, txqueuelen)
         return port
 
-
     def udp_connect(self, remote_endpoint, connection_app_home, 
             connection_run_home, cipher, cipher_key, bwlimit, txqueuelen):
         udp_connect_command = self._udp_connect_command(
@@ -393,9 +390,10 @@ class PlanetlabTap(LinuxApplication):
     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"))
+        # Set the remote endpoint, (private) IP of the device
+        self.set("pointopoint", remote_endpoint.get("ip"))
 
+        # Public IP of the node
         remote_ip = remote_endpoint.node.get("ip")
 
         local_port_file = os.path.join(self.run_home, 
@@ -500,11 +498,10 @@ class PlanetlabTap(LinuxApplication):
 
         return result
 
-
-
     def _gre_connect_command(self, remote_endpoint, connection_run_home): 
-        # Set the remote endpoint
-        self.set("pointopoint", remote_endpoint.get("endpoint_ip"))
+        # Set the remote endpoint, (private) IP of the device
+        self.set("pointopoint", remote_endpoint.get("ip"))
+        # Public IP of the node
         self.set("greRemote", remote_endpoint.node.get("ip"))
 
         # Generate GRE connect command
@@ -526,7 +523,6 @@ class PlanetlabTap(LinuxApplication):
 
         return command
 
-
     @property
     def _start_command(self):
         if self.gre_enabled:
@@ -535,8 +531,8 @@ class PlanetlabTap(LinuxApplication):
             command = ["sudo -S python ${SRC}/pl-vif-create.py"]
             
             command.append("-t %s" % self.vif_type)
-            command.append("-a %s" % self.get("endpoint_ip"))
-            command.append("-n %d" % self.get("endpoint_prefix"))
+            command.append("-a %s" % self.get("ip"))
+            command.append("-n %s" % self.get("prefix"))
             command.append("-f %s " % self.vif_name_file)
             command.append("-S %s " % self.sock_name)
 
@@ -578,8 +574,8 @@ class PlanetlabTap(LinuxApplication):
         command.append("-u %s" % self.node.get("username"))
         command.append("-N %s" % device_name)
         command.append("-t %s" % self.vif_type)
-        command.append("-a %s" % self.get("endpoint_ip"))
-        command.append("-n %d" % self.get("endpoint_prefix"))
+        command.append("-a %s" % self.get("ip"))
+        command.append("-n %s" % self.get("prefix"))
 
         if self.get("snat") == True:
             command.append("-s")