Changing ResourceManager naming for platform::ResourceName
[nepi.git] / src / nepi / resources / omf / node.py
index 166249b..cfd0e51 100644 (file)
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 #         Julien Tribino <julien.tribino@inria.fr>
 
+from nepi.util.timefuncs import tnow
 from nepi.execution.resource import ResourceManager, clsinit_copy, \
-        ResourceState, reschedule_delay
+        ResourceState
 from nepi.execution.attribute import Attribute, Flags 
 from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
 from nepi.resources.omf.omf_api_factory import OMFAPIFactory
 
 import time
 
-confirmation_counter = 600
+reschedule_check = "1s"
+confirmation_counter = 3600
 
 @clsinit_copy
 class OMFNode(OMFResource):
@@ -41,8 +43,8 @@ class OMFNode(OMFResource):
         :type creds: dict
 
     """
-    _rtype = "OMFNode"
-    _authorized_connections = ["OMFApplication" , "OMFWifiInterface"]
+    _rtype = "omf::Node"
+    _authorized_connections = ["omf::Application" , "omf::WifiInterface"]
 
     @classmethod
     def _register_attributes(cls):
@@ -67,6 +69,11 @@ class OMFNode(OMFResource):
 
         self._omf_api = None 
 
+        # For performance tests
+        self.perf = True
+        self.begin_deploy_time = None
+
+
     @property
     def exp_id(self):
         return self.ec.exp_id
@@ -96,9 +103,13 @@ class OMFNode(OMFResource):
     def do_deploy(self):
         """ Deploy the RM. It means : Send Xmpp Message Using OMF protocol 
             to enroll the node into the experiment.
-            It becomes DEPLOYED after sending messages to enroll the node
 
         """ 
+      ## For performance test
+        if self.perf:
+            self.begin_deploy_time = tnow()
+            self.perf = False
+
         if not self.get('xmppServer'):
             msg = "XmppServer is not initialzed. XMPP Connections impossible"
             self.error(msg)
@@ -132,7 +143,8 @@ class OMFNode(OMFResource):
         super(OMFNode, self).do_deploy()
 
     def do_release(self):
-        """ Clean the RM at the end of the experiment
+        """ Clean the RM at the end of the experiment by unenrolling
+        the node from the topic
 
         """
         from nepi.resources.omf.application import OMFApplication
@@ -140,7 +152,7 @@ class OMFNode(OMFResource):
         if rm_list:
             for rm in rm_list:
                 if rm.state < ResourceState.RELEASED:
-                    self.ec.schedule(reschedule_delay, self.release)
+                    self.ec.schedule(self.reschedule_delay, self.release)
                     return 
 
         from nepi.resources.omf.interface import OMFWifiInterface
@@ -148,7 +160,7 @@ class OMFNode(OMFResource):
         if rm_list:
             for rm in rm_list:
                 if rm.state < ResourceState.RELEASED:
-                    self.ec.schedule(reschedule_delay, self.release)
+                    self.ec.schedule(self.reschedule_delay, self.release)
                     return 
 
         if self._omf_api: