Adding trace Collector RM
[nepi.git] / src / nepi / resources / linux / ccn / ccnd.py
index bd001b4..44c1afb 100644 (file)
 
 from nepi.execution.attribute import Attribute, Flags, Types
 from nepi.execution.trace import Trace, TraceAttr
-from nepi.execution.resource import ResourceManager, clsinit_copy, ResourceState
+from nepi.execution.resource import ResourceManager, clsinit_copy, ResourceState, \
+    reschedule_delay
 from nepi.resources.linux.application import LinuxApplication
 from nepi.resources.linux.node import OSType
-from nepi.util.timefuncs import strfnow, strfdiff
+from nepi.util.timefuncs import tnow, tdiffsec
 
 import os
 
 # TODO: use ccndlogging to dynamically change the logging level
 
+
 @clsinit_copy
 class LinuxCCND(LinuxApplication):
     _rtype = "LinuxCCND"
@@ -129,8 +131,7 @@ class LinuxCCND(LinuxApplication):
         if not self.node or self.node.state < ResourceState.READY:
             self.debug("---- RESCHEDULING DEPLOY ---- node state %s " % self.node.state )
             
-            reschedule_delay = "0.5s"
-            # ccnr needs to wait until ccnd is deployed and running
+            # ccnd needs to wait until node is deployed and running
             self.ec.schedule(reschedule_delay, self.deploy)
         else:
             if not self.get("command"):
@@ -191,7 +192,7 @@ class LinuxCCND(LinuxApplication):
                     raise_on_error = True)
     
             self.debug("----- READY ---- ")
-            self._ready_time = strfnow()
+            self._ready_time = tnow()
             self._state = ResourceState.READY
 
     def start(self):
@@ -199,7 +200,7 @@ class LinuxCCND(LinuxApplication):
             command = self.get("command")
             self.info("Starting command '%s'" % command)
 
-            self._start_time = strfnow()
+            self._start_time = tnow()
             self._state = ResourceState.STARTED
         else:
             msg = " Failed to execute command '%s'" % command
@@ -230,7 +231,7 @@ class LinuxCCND(LinuxApplication):
                         stdout = "ccndstop_stdout", 
                         stderr = "ccndstop_stderr")
 
-            self._stop_time = strfnow()
+            self._stop_time = tnow()
             self._state = ResourceState.STOPPED
     
     @property
@@ -238,7 +239,7 @@ class LinuxCCND(LinuxApplication):
         # First check if the ccnd has failed
         state_check_delay = 0.5
         if self._state == ResourceState.STARTED and \
-                strfdiff(strfnow(), self._last_state_check) > state_check_delay:
+                tdiffsec(tnow(), self._last_state_check) > state_check_delay:
             (out, err), proc = self._ccndstatus
 
             retcode = proc.poll()
@@ -252,7 +253,7 @@ class LinuxCCND(LinuxApplication):
                 self.error(msg, out, err)
                 self._state = ResourceState.FAILED
 
-            self._last_state_check = strfnow()
+            self._last_state_check = tnow()
 
         return self._state
 
@@ -271,11 +272,11 @@ class LinuxCCND(LinuxApplication):
 
     @property
     def _dependencies(self):
-        if self.node.os in [ OSType.FEDORA_12 , OSType.FEDORA_14 ]:
+        if self.node.use_rpm:
             return ( " autoconf openssl-devel  expat-devel libpcap-devel "
                 " ecryptfs-utils-devel libxml2-devel automake gawk " 
                 " gcc gcc-c++ git pcre-devel make ")
-        elif self.node.os in [ OSType.UBUNTU , OSType.DEBIAN]:
+        elif self.node.use_deb:
             return ( " autoconf libssl-dev libexpat-dev libpcap-dev "
                 " libecryptfs0 libxml2-utils automake gawk gcc g++ "
                 " git-core pkg-config libpcre3-dev make ")