Removing ResourceState.FINISHED beacuse it is redundant with STOPPED
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Fri, 22 Nov 2013 12:53:51 +0000 (13:53 +0100)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Fri, 22 Nov 2013 12:53:51 +0000 (13:53 +0100)
src/nepi/execution/ec.py
src/nepi/execution/resource.py
src/nepi/resources/linux/application.py
src/nepi/resources/linux/ccn/ccnd.py
src/nepi/resources/linux/udptunnel.py

index aa83517..0d0e477 100644 (file)
@@ -238,7 +238,7 @@ class ExperimentController(object):
 
     def wait_finished(self, guids):
         """ Blocking method that wait until all RMs in the 'guid' list 
-            reach a state >= STOPPED (i.e. FINISHED, STOPPED, FAILED or 
+            reach a state >= STOPPED (i.e. STOPPED, FAILED or 
             RELEASED ) or until a System Failure occurs (e.g. Task Failure) 
 
         :param guids: List of guids
index a6238b1..e1679a8 100644 (file)
@@ -51,9 +51,8 @@ class ResourceState:
     READY = 3
     STARTED = 4
     STOPPED = 5
-    FINISHED = 6
-    FAILED = 7
-    RELEASED = 8
+    FAILED = 6
+    RELEASED = 7
 
 ResourceState2str = dict({
     ResourceState.NEW : "NEW",
@@ -62,7 +61,6 @@ ResourceState2str = dict({
     ResourceState.READY : "READY",
     ResourceState.STARTED : "STARTED",
     ResourceState.STOPPED : "STOPPED",
-    ResourceState.FINISHED : "FINISHED",
     ResourceState.FAILED : "FAILED",
     ResourceState.RELEASED : "RELEASED",
     })
@@ -108,7 +106,7 @@ def clsinit_copy(cls):
 def failtrap(func):
     """ Decorator function for instance methods that should set the 
     RM state to FAILED when an error is raised. The methods that must be
-    decorated are: discover, provision, deploy, start, stop and finish.
+    decorated are: discover, provision, deploy, start, stop.
 
     """
     def wrapped(self, *args, **kwargs):
@@ -307,7 +305,6 @@ class ResourceManager(Logger):
         self._provision_time = None
         self._ready_time = None
         self._release_time = None
-        self._finish_time = None
         self._failed_time = None
 
         self._state = ResourceState.NEW
@@ -372,11 +369,6 @@ class ResourceManager(Logger):
         """ Returns the release time of the RM as a timestamp """
         return self._release_time
 
-    @property
-    def finish_time(self):
-        """ Returns the finalization time of the RM as a timestamp """
-        return self._finish_time
-
     @property
     def failed_time(self):
         """ Returns the time failure occured for the RM as a timestamp """
@@ -535,23 +527,6 @@ class ResourceManager(Logger):
             self.set_released()
             self.debug("----- RELEASED ---- ")
 
-    @failtrap
-    def finish(self):
-        """ Sets the RM to state FINISHED. 
-     
-        The FINISHED state is different from STOPPED state in that it 
-        should not be directly invoked by the user.
-        STOPPED indicates that the user interrupted the RM, FINISHED means
-        that the RM concluded normally the actions it was supposed to perform.
-    
-        This method should not be overriden directly. Specific functionality
-        should be added in the do_finish method.
-        
-        """
-        with self._release_lock:
-            if self._state != ResourceState.RELEASED:
-                self.do_finish()
-
     def fail(self):
         """ Sets the RM to state FAILED.
 
@@ -748,8 +723,6 @@ class ResourceManager(Logger):
                     t = rm.start_time
                 elif state == ResourceState.STOPPED:
                     t = rm.stop_time
-                elif state == ResourceState.FINISHED:
-                    t = rm.finish_time
                 elif state == ResourceState.RELEASED:
                     t = rm.release_time
                 else:
@@ -965,14 +938,6 @@ class ResourceManager(Logger):
     def do_release(self):
         pass
 
-    def do_finish(self):
-        # In case the RM passed from STARTED directly to FINISHED,
-        # we set the stop_time for consistency
-        if self.stop_time == None:
-            self.set_stopped()
-
-        self.set_finished()
-
     def do_fail(self):
         self.set_failed()
 
@@ -992,10 +957,6 @@ class ResourceManager(Logger):
         """ Mark ResourceManager as REALEASED """
         self.set_state(ResourceState.RELEASED, "_release_time")
 
-    def set_finished(self):
-        """ Mark ResourceManager as FINISHED """
-        self.set_state(ResourceState.FINISHED, "_finish_time")
-
     def set_failed(self):
         """ Mark ResourceManager as FAILED """
         self.set_state(ResourceState.FAILED, "_failed_time")
index 8cac699..50cb205 100644 (file)
@@ -491,8 +491,8 @@ class LinuxApplication(ResourceManager):
 
         if not command:
             # If no command was given (i.e. Application was used for dependency
-            # installation), then the application is directly marked as FINISHED
-            super(LinuxApplication, self).do_finish()
+            # installation), then the application is directly marked as STOPPED
+            super(LinuxApplication, self).set_stopped()
         else:
             if self.in_foreground:
                 self._run_in_foreground()
@@ -636,7 +636,7 @@ class LinuxApplication(ResourceManager):
                     self.do_fail()
 
                 elif retcode == 0:
-                    self.do_finish()
+                    self.set_stopped()
             else:
                 # We need to query the status of the command we launched in 
                 # background. In order to avoid overwhelming the remote host and
@@ -660,7 +660,7 @@ class LinuxApplication(ResourceManager):
                                 self.error(msg, out, err)
                                 self.do_fail()
                             else:
-                                self.do_finish()
+                                self.set_stopped()
 
                     self._last_state_check = tnow()
 
index 081435c..d8a3fc3 100644 (file)
@@ -247,7 +247,7 @@ class LinuxCCND(LinuxApplication):
 
             if retcode == 1 and err.find("No such file or directory") > -1:
                 # ccnd is not running (socket not found)
-                self.set_finished()
+                self.set_stopped()
             elif retcode:
                 # other errors ...
                 msg = " Failed to execute command '%s'" % self.get("command")
index 3cfefbe..6372729 100644 (file)
@@ -266,7 +266,7 @@ class UdpTunnel(LinuxApplication):
                             self.error(msg, err1, err2)
                             self.fail()
                         else:
-                            self.set_finished()
+                            self.set_stopped()
 
                 self._last_state_check = tnow()