update test and examples for OMF6 in OMF section
[nepi.git] / src / nepi / resources / omf / node.py
index 6658f62..c0e10f9 100644 (file)
@@ -26,6 +26,9 @@ from nepi.resources.omf.omf_api_factory import OMFAPIFactory
 
 import time
 
+reschedule_check = "0.3s"
+confirmation_counter = 300
+
 @clsinit_copy
 class OMFNode(OMFResource):
     """
@@ -94,7 +97,6 @@ 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
 
         """ 
         if not self.get('xmppServer'):
@@ -130,7 +132,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
@@ -141,6 +144,14 @@ class OMFNode(OMFResource):
                     self.ec.schedule(reschedule_delay, self.release)
                     return 
 
+        from nepi.resources.omf.interface import OMFWifiInterface
+        rm_list = self.get_connected(OMFWifiInterface.get_rtype())
+        if rm_list:
+            for rm in rm_list:
+                if rm.state < ResourceState.RELEASED:
+                    self.ec.schedule(reschedule_delay, self.release)
+                    return 
+
         if self._omf_api:
             if self.get('version') == "5":
                 self._omf_api.release(self.get('hostname'))