Fixing RM.DEPLOY being executed after/during RM.RELEASE by adding a release_lock...
[nepi.git] / src / nepi / resources / linux / interface.py
index a170f41..59bbe2a 100644 (file)
@@ -18,8 +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, \
-        reschedule_delay
+from nepi.execution.resource import ResourceManager, clsinit_copy, \
+        ResourceState, reschedule_delay
 from nepi.resources.linux.node import LinuxNode
 from nepi.resources.linux.channel import LinuxChannel
 
@@ -33,7 +33,7 @@ import time
 # TODO: UP, MTU attributes!
 
 
-@clsinit
+@clsinit_copy
 class LinuxInterface(ResourceManager):
     _rtype = "LinuxInterface"
     _help = "Controls network devices on Linux hosts through the ifconfig tool"
@@ -102,7 +102,7 @@ class LinuxInterface(ResourceManager):
         if chan: return chan[0]
         return None
 
-    def discover(self):
+    def do_discover(self):
         devname = self.get("deviceName")
         ip4 = self.get("ip4")
         ip6 = self.get("ip4")
@@ -181,9 +181,9 @@ class LinuxInterface(ResourceManager):
             self.error(msg)
             raise RuntimeError, msg
 
-        super(LinuxInterface, self).discover()
+        super(LinuxInterface, self).do_discover()
 
-    def provision(self):
+    def do_provision(self):
         devname = self.get("deviceName")
         ip4 = self.get("ip4")
         ip6 = self.get("ip4")
@@ -224,9 +224,9 @@ class LinuxInterface(ResourceManager):
                 self.error(msg, out, err)
                 raise RuntimeError, "%s - %s - %s" % (msg, out, err)
 
-        super(LinuxInterface, self).provision()
+        super(LinuxInterface, self).do_provision()
 
-    def deploy(self):
+    def do_deploy(self):
         # Wait until node is provisioned
         node = self.node
         chan = self.channel
@@ -238,21 +238,17 @@ class LinuxInterface(ResourceManager):
         else:
             # Verify if the interface exists in node. If not, configue
             # if yes, load existing configuration
-            try:
-                self.discover()
-                self.provision()
-            except:
-                self.fail()
-                return 
+            self.do_discover()
+            self.do_provision()
 
-            super(LinuxInterface, self).deploy()
+            super(LinuxInterface, self).do_deploy()
 
-    def release(self):
+    def do_release(self):
         tear_down = self.get("tearDown")
-        if tear_down:
+        if tear_down:   
             self.execute(tear_down)
 
-        super(LinuxInterface, self).release()
+        super(LinuxInterface, self).do_release()
 
     def valid_connection(self, guid):
         # TODO: Validate!