Modifications release Pl node
authorLucia Guevgeozian Odizzio <lucia.guevgeozian_odizzio@inria.fr>
Thu, 12 Jun 2014 12:25:09 +0000 (14:25 +0200)
committerLucia Guevgeozian Odizzio <lucia.guevgeozian_odizzio@inria.fr>
Thu, 12 Jun 2014 12:25:09 +0000 (14:25 +0200)
src/nepi/resources/planetlab/plcapi.py
src/nepi/resources/planetlab/sfa_node.py

index 4f4bf5c..86385b7 100644 (file)
@@ -493,19 +493,24 @@ class PLCAPI(object):
 
     def release(self):
         self.count -= 1
-        if self._ecobj.get_global('PlanetlabNode', 'persist_blacklist') and self.count == 0:
-            if self._blacklist:
-                to_blacklist = list()
-                hostnames = self.get_nodes(list(self._blacklist), ['hostname'])
-                for hostname in hostnames:
-                    to_blacklist.append(hostname['hostname'])
-
-                nepi_home = os.path.join(os.path.expanduser("~"), ".nepi")
-                plblacklist_file = os.path.join(nepi_home, "plblacklist.txt")
-
-                with open(plblacklist_file, 'w') as f:
-                    for host in to_blacklist:
-                        f.write("%s\n" % host)
+        if self.count == 0:
+            blacklist = self._blacklist
+            self._blacklist = set()
+            self._reserved = set()
+            if self._ecobj.get_global('PlanetlabNode', 'persist_blacklist'):
+                if blacklist:
+                    to_blacklist = list()
+                    hostnames = self.get_nodes(list(blacklist), ['hostname'])
+                    for hostname in hostnames:
+                        to_blacklist.append(hostname['hostname'])
+    
+                    nepi_home = os.path.join(os.path.expanduser("~"), ".nepi")
+                    plblacklist_file = os.path.join(nepi_home, "plblacklist.txt")
+    
+                    with open(plblacklist_file, 'w') as f:
+                        for host in to_blacklist:
+                            f.write("%s\n" % host)
+    
 
 class PLCAPIFactory(object):
     """ 
index ca7ba36..d18d248 100644 (file)
@@ -369,6 +369,12 @@ class PlanetlabSfaNode(LinuxNode):
             
         super(PlanetlabSfaNode, self).do_provision()
 
+    def do_release(self):
+        super(PlanetlabSfaNode, self).do_release()
+        if self.state == ResourceState.RELEASED and not self._skip_provision():
+            self.debug(" Releasing SFA API ")
+            self.sfaapi.release()
+
 #    def _filter_based_on_attributes(self):
 #        """
 #        Retrive the list of nodes hrn that match user's constraints