Improvements to UdpTunnel
[nepi.git] / src / nepi / resources / linux / interface.py
index 4708477..f5f7025 100644 (file)
@@ -18,7 +18,8 @@
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
 from nepi.execution.attribute import Attribute, Types, Flags
-from nepi.execution.resource import ResourceManager, clsinit, ResourceState
+from nepi.execution.resource import ResourceManager, clsinit, ResourceState, \
+        reschedule_delay
 from nepi.resources.linux.node import LinuxNode
 from nepi.resources.linux.channel import LinuxChannel
 
@@ -31,7 +32,6 @@ import time
 
 # TODO: UP, MTU attributes!
 
-reschedule_delay = "0.5s"
 
 @clsinit
 class LinuxInterface(ResourceManager):
@@ -40,7 +40,7 @@ class LinuxInterface(ResourceManager):
     @classmethod
     def _register_attributes(cls):
         ip4 = Attribute("ip4", "IPv4 Address",
-                flags = Flags.ExecReadOnly)
+              flags = Flags.ExecReadOnly)
 
         ip6 = Attribute("ip6", "IPv6 Address",
                 flags = Flags.ExecReadOnly)
@@ -56,7 +56,7 @@ class LinuxInterface(ResourceManager):
                 flags = Flags.ExecReadOnly)
 
         mtu = Attribute("mtu", "Maximum transmition unit for device",
-            type = Types.Integer)
+                type = Types.Integer)
 
         devname = Attribute("deviceName", 
                 "Name of the network interface (e.g. eth0, wlan0, etc)",
@@ -110,7 +110,7 @@ class LinuxInterface(ResourceManager):
         mtu = self.get("mtu")
 
         # Get current interfaces information
-        (out, err), proc = self.node.execute("ifconfig", sudo = True)
+        (out, err), proc = self.node.execute("ifconfig", sudo = True, tty = True)
 
         if err and proc.poll():
             msg = " Error retrieving interface information "
@@ -240,7 +240,7 @@ class LinuxInterface(ResourceManager):
                 self.discover()
                 self.provision()
             except:
-                self._state = ResourceState.FAILED
+                self.fail()
                 raise
 
             super(LinuxInterface, self).deploy()