X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Flinux%2Ftap.py;h=91640dff1d0421a86bed7f560ccedc0029d74ca0;hb=38575a0f27f26511965771dde8320060b10252dd;hp=a0ec93a6ff67b0a528763070711589c536160595;hpb=dceafc553de152296b99e8c2f4b3fef1321bd7ef;p=nepi.git diff --git a/src/nepi/resources/linux/tap.py b/src/nepi/resources/linux/tap.py index a0ec93a6..91640dff 100644 --- a/src/nepi/resources/linux/tap.py +++ b/src/nepi/resources/linux/tap.py @@ -25,7 +25,6 @@ from nepi.resources.linux.node import LinuxNode from nepi.util.timefuncs import tnow, tdiffsec import os -import socket import time PYTHON_VSYS_VERSION = "1.0" @@ -38,13 +37,13 @@ class LinuxTap(LinuxApplication): @classmethod def _register_attributes(cls): - ip4 = Attribute("ip4", "IPv4 Address", + endpoint_ip = Attribute("endpoint_ip", "IPv4 Address", flags = Flags.Design) mac = Attribute("mac", "MAC Address", flags = Flags.Design) - prefix4 = Attribute("prefix4", "IPv4 network prefix", + endpoint_prefix = Attribute("endpoint_prefix", "IPv4 network prefix", type = Types.Integer, flags = Flags.Design) @@ -84,9 +83,9 @@ class LinuxTap(LinuxApplication): "Bash script to be executed before releasing the resource", flags = Flags.Design) - cls._register_attribute(ip4) + cls._register_attribute(endpoint_ip) cls._register_attribute(mac) - cls._register_attribute(prefix4) + cls._register_attribute(endpoint_prefix) cls._register_attribute(mtu) cls._register_attribute(devname) cls._register_attribute(up) @@ -327,15 +326,14 @@ class LinuxTap(LinuxApplication): cipher, cipher_key, bwlimit, txqueuelen): # Set the remote endpoint - self.set("pointopoint", remote_endpoint.get("ip4")) + self.set("pointopoint", remote_endpoint.get("endpoint_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) - remote_ip = socket.gethostbyname( - remote_endpoint.node.get("ip")) + remote_ip = remote_endpoint.node.get("ip") local_port_file = os.path.join(connection_run_home, "local_port") @@ -384,9 +382,8 @@ class LinuxTap(LinuxApplication): def _gre_connect_command(self, remote_endpoint, connection_run_home): # Set the remote endpoint - self.set("pointopoint", remote_endpoint.get("ip4")) - self.set("greRemote", socket.gethostbyname( - remote_endpoint.node.get("ip"))) + self.set("pointopoint", remote_endpoint.get("endpoint_ip")) + self.set("greRemote", remote_endpoint.node.get("ip")) # Generate GRE connect command command = ["("] @@ -414,8 +411,8 @@ class LinuxTap(LinuxApplication): "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("ip4"), - self.get("prefix4"), + self.get("endpoint_ip"), + self.get("endpoint_prefix"), self.get("deviceName"), )) @@ -444,14 +441,14 @@ class LinuxTap(LinuxApplication): command.append("sudo -S ip link add %s type gre remote %s local %s ttl 64 csum key %s" % ( self.get("deviceName"), self.get("greRemote"), - socket.gethostbyname(self.node.get("hostname")), + self.node.get("ip"), self.get("greKey") )) command.append("sudo -S ip addr add %s/%d peer %s/%d dev %s" % ( - self.get("ip4"), - self.get("prefix4"), + self.get("endpoint_ip"), + self.get("endpoint_prefix"), self.get("pointopoint"), - self.get("prefix4"), + self.get("endpoint_prefix"), self.get("deviceName"), )) command.append("sudo -S ip link set %s up " % self.get("deviceName"))