# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
from nepi.execution.attribute import Attribute, Flags, Types
-from nepi.execution.resource import clsinit_copy, ResourceState, \
- reschedule_delay
+from nepi.execution.resource import clsinit_copy, ResourceState
from nepi.resources.linux.application import LinuxApplication
from nepi.resources.planetlab.node import PlanetlabNode
from nepi.util.timefuncs import tnow, tdiffsec
@clsinit_copy
class PlanetlabTap(LinuxApplication):
- _rtype = "PlanetlabTap"
+ _rtype = "planetlab::Tap"
_help = "Creates a TAP device on a PlanetLab host"
_backend = "planetlab"
@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)
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",
"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)
def do_deploy(self):
if not self.node or self.node.state < ResourceState.PROVISIONED:
- self.ec.schedule(reschedule_delay, self.deploy)
+ self.ec.schedule(self.reschedule_delay, self.deploy)
else:
if not self.get("command"):
self.set("command", self._start_command)
for rm in rms:
if rm.state < ResourceState.STOPPED:
- self.ec.schedule(reschedule_delay, self.release)
+ self.ec.schedule(self.reschedule_delay, self.release)
return
super(PlanetlabTap, self).do_release()
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(
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,
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
return command
-
@property
def _start_command(self):
if self.gre_enabled:
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)
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")