LinuxApplication: Changed directory structure to store experiment files in the Linux...
[nepi.git] / src / nepi / resources / linux / ccn / ccncontent.py
index 3b08171..8b79974 100644 (file)
 
 from nepi.execution.attribute import Attribute, Flags, Types
 from nepi.execution.resource import clsinit_copy, ResourceState, \
-    ResourceAction
+    ResourceAction, reschedule_delay
 from nepi.resources.linux.ccn.ccnapplication import LinuxCCNApplication
 from nepi.resources.linux.ccn.ccnr import LinuxCCNR
-from nepi.util.timefuncs import strfnow, strfdiff
+from nepi.util.timefuncs import tnow
 
 import os
 
@@ -62,7 +62,6 @@ class LinuxCCNContent(LinuxCCNApplication):
         if not self.ccnr or self.ccnr.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
             self.ec.schedule(reschedule_delay, self.deploy)
         else:
@@ -88,10 +87,16 @@ class LinuxCCNContent(LinuxCCNApplication):
             # Run the command as a bash script in the background, 
             # in the host ( but wait until the command has
             # finished to continue )
-            self.execute_command(command, env)
+            (out, err), proc = self.execute_command(command, env)
+
+            if proc.poll():
+                self._state = ResourceState.FAILED
+                msg = "Failed to execute command"
+                self.error(msg, out, err)
+                raise RuntimeError, msg
 
             self.debug("----- READY ---- ")
-            self._ready_time = strfnow()
+            self._ready_time = tnow()
             self._state = ResourceState.READY
 
     def start(self):
@@ -99,7 +104,7 @@ class LinuxCCNContent(LinuxCCNApplication):
             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