X-Git-Url: http://git.onelab.eu/?p=nepi.git;a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Flinux%2Ftap.py;h=685db9eeb38916963346a1f907b1f7d28f550ee8;hp=636e4710d0dfe5d1aa34593c044374beec072b8f;hb=b6c4948fd994223cff257cbdae7146da1339b58d;hpb=fb002d754908edf9b3dbc11c2cd9111220cf402c diff --git a/src/nepi/resources/linux/tap.py b/src/nepi/resources/linux/tap.py index 636e4710..685db9ee 100644 --- a/src/nepi/resources/linux/tap.py +++ b/src/nepi/resources/linux/tap.py @@ -39,14 +39,13 @@ class LinuxTap(LinuxApplication): @classmethod def _register_attributes(cls): - endpoint_ip = Attribute("endpoint_ip", "IPv4 Address", + ip = Attribute("ip", "IPv4 Address", flags = Flags.Design) mac = Attribute("mac", "MAC Address", flags = Flags.Design) - endpoint_prefix = Attribute("endpoint_prefix", "IPv4 network prefix", - type = Types.Integer, + prefix = Attribute("prefix", "IPv4 network prefix", flags = Flags.Design) mtu = Attribute("mtu", "Maximum transmition unit for device", @@ -85,9 +84,9 @@ class LinuxTap(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) @@ -334,14 +333,15 @@ class LinuxTap(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 to the IP of the device + self.set("pointopoint", remote_endpoint.get("ip")) # Planetlab TAPs always use PI headers from nepi.resources.planetlab.tap import PlanetlabTap if self.is_rm_instance(PlanetlabTap.get_rtype()): self.set("pi", True) + # Public IP of the remote NODE to stablish tunnel remote_ip = remote_endpoint.node.get("ip") local_port_file = os.path.join(self.run_home, @@ -390,8 +390,9 @@ class LinuxTap(LinuxApplication): return command 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 to (private) device IP + self.set("pointopoint", remote_endpoint.get("ip")) + ## public node IP self.set("greRemote", remote_endpoint.node.get("ip")) # Generate GRE connect command @@ -478,9 +479,9 @@ class LinuxTap(LinuxApplication): self.vif_prefix, "pi" if self.get("pi") else "")) start_command.append("sudo -S ip link set %s up" % self.get("deviceName")) - start_command.append("sudo -S ip addr add %s/%d dev %s" % ( - self.get("endpoint_ip"), - self.get("endpoint_prefix"), + start_command.append("sudo -S ip addr add %s/%s dev %s" % ( + self.get("ip"), + self.get("prefix"), self.get("deviceName"), )) @@ -512,11 +513,11 @@ class LinuxTap(LinuxApplication): self.node.get("ip"), self.get("greKey") )) - command.append("sudo -S ip addr add %s/%d peer %s/%d dev %s" % ( - self.get("endpoint_ip"), - self.get("endpoint_prefix"), + command.append("sudo -S ip addr add %s/%s peer %s/%s dev %s" % ( + self.get("ip"), + self.get("prefix"), self.get("pointopoint"), - self.get("endpoint_prefix"), + self.get("prefix"), self.get("deviceName"), )) command.append("sudo -S ip link set %s up " % self.get("deviceName"))