# Alexandros Kouvakas <alexandros.kouvakas@gmail.com>
from nepi.execution.attribute import Attribute, Flags, Types
-from nepi.execution.resource import ResourceManager, clsinit_copy, ResourceState
+from nepi.execution.resource import ResourceManager, clsinit_copy, \
+ ResourceState
from nepi.resources.linux.application import LinuxApplication
from nepi.resources.planetlab.node import PlanetlabNode
from nepi.resources.planetlab.openvswitch.ovs import OVSWitch
import time
import socket
-
reschedule_delay = "0.5s"
@clsinit_copy
-class Tunnel(LinuxApplication):
+class OVSTunnel(LinuxApplication):
"""
.. class:: Class Args :
"""
- _rtype = "Tunnel"
+ _rtype = "OVSTunnel"
_authorized_connections = ["OVSPort", "PlanetlabTap"]
@classmethod
:type guid: int
"""
- super(Tunnel, self).__init__(ec, guid)
+ super(OVSTunnel, self).__init__(ec, guid)
self._home = "tunnel-%s" % self.guid
self.port_info_tunl = []
self._nodes = []
msg = "Failed to connect endpoints"
if proc.poll():
- self.fail()
self.error(msg, out, err)
raise RuntimeError, msg
+
msg = "Connection on host %s configured" \
% self.node.get("hostname")
self.info(msg)
(out, err), proc = self.node.check_errors(self.run_home(self.node))
# Out is what was written in the stderr file
if err:
- self.fail()
msg = " Failed to start command '%s' " % command
self.error(msg, out, err)
raise RuntimeError, msg
msg = "Failed to connect endpoints"
if proc.poll():
- self.fail()
self.error(msg, out, err)
raise RuntimeError, msg
else:
msg = "Failed to connect endpoints"
if proc.poll():
- self.fail()
self.error(msg, out, err)
raise RuntimeError, msg
else:
self.info(msg)
return
- def provision(self):
+ def do_provision(self):
""" Provision the tunnel
"""
# Create folders
(self._pid, self._ppid) = self.udp_connect(self.endpoint2, self.endpoint1)
switch_connect = self.sw_host_connect(self.endpoint1, self.endpoint2)
- self.debug("------- READY -------")
- self._provision_time = tnow()
- self._state = ResourceState.PROVISIONED
-
- def discover(self):
- """ Discover the tunnel
+ super(OVSTunnel, self).do_provision()
- """
- pass
-
- def deploy(self):
+ def do_deploy(self):
if (not self.endpoint1 or self.endpoint1.state < ResourceState.READY) or \
(not self.endpoint2 or self.endpoint2.state < ResourceState.READY):
self.ec.schedule(reschedule_delay, self.deploy)
else:
- try:
- self.discover()
- self.provision()
- except:
- self.fail()
- raise
-
- self.debug("----- READY ---- ")
- self._ready_time = tnow()
- self._state = ResourceState.READY
+ self.do_discover()
+ self.do_provision()
- def start(self):
- """ Start the RM. It means nothing special for
- ovsport for now.
- """
- pass
-
-
- def stop(self):
- """ Stop the RM. It means nothing special for
- ovsport for now.
- """
- pass
-
- def release(self):
+ super(OVSTunnel, self).do_deploy()
+
+ def do_release(self):
""" Release the udp_tunnel on endpoint2.
On endpoint1 means nothing special.
"""
# check if execution errors occurred
msg = " Failed to delete TAP device"
self.error(msg, err, err)
- self.fail()
-
- self._state = ResourceState.RELEASED
-
-
-
-
-
-
+ super(OVSTunnel, self).do_release()