Adding ccnpeek linux example
[nepi.git] / src / nepi / resources / linux / ccn / ccnapplication.py
index 39ac2a9..49b2bdc 100644 (file)
@@ -18,7 +18,7 @@
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
 from nepi.execution.resource import clsinit_copy, ResourceState, \
-    ResourceAction
+    reschedule_delay
 from nepi.resources.linux.application import LinuxApplication
 from nepi.resources.linux.ccn.ccnd import LinuxCCND
 
@@ -34,7 +34,7 @@ class LinuxCCNApplication(LinuxApplication):
 
     @property
     def ccnd(self):
-        ccnd = self.get_connected(LinuxCCND.rtype())
+        ccnd = self.get_connected(LinuxCCND.get_rtype())
         if ccnd: return ccnd[0]
         return None
 
@@ -43,24 +43,27 @@ class LinuxCCNApplication(LinuxApplication):
         if self.ccnd: return self.ccnd.node
         return None
 
-    def deploy(self):
-        if not self.get("env"):
-            self.set("env", self._environment)
+    def do_deploy(self):
+        if not self.ccnd or self.ccnd.state < ResourceState.READY:
+            self.debug("---- RESCHEDULING DEPLOY ---- node state %s " % self.node.state )
+            self.ec.schedule(reschedule_delay, self.deploy)
+        else:
+            command = self.get("command") or ""
 
-        super(LinuxCCNApplication, self).deploy()
+            self.info("Deploying command '%s' " % command)
+            
+            if not self.get("env"):
+                self.set("env", self._environment)
+
+            self.do_discover()
+            self.do_provision()
+
+            self.set_ready()
 
     @property
     def _environment(self):
-        env = "PATH=$PATH:${STORE}/ccnx/bin "
-        return env            
+        return self.ccnd.path
        
-    def execute_command(self, command, env):
-        environ = self.node.format_environment(env, inline = True)
-        command = environ + command
-        command = self.replace_paths(command)
-
-        return self.node.execute(command)
-
     def valid_connection(self, guid):
         # TODO: Validate!
         return True