Adding ccnpeek linux example
[nepi.git] / src / nepi / resources / linux / ccn / ccnapplication.py
index 740d366..49b2bdc 100644 (file)
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
-from nepi.execution.resource import ResourceManager, clsinit_copy, ResourceState, \
+from nepi.execution.resource import clsinit_copy, ResourceState, \
     reschedule_delay
 from nepi.resources.linux.application import LinuxApplication
 from nepi.resources.linux.ccn.ccnd import LinuxCCND
-from nepi.util.timefuncs import tnow, tdiffsec
 
 import os
 
@@ -35,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
 
@@ -44,40 +43,27 @@ class LinuxCCNApplication(LinuxApplication):
         if self.ccnd: return self.ccnd.node
         return None
 
-    def deploy(self):
+    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:
-            try:
-                command = self.get("command") or ""
+            command = self.get("command") or ""
 
-                self.info("Deploying command '%s' " % command)
-                
-                if not self.get("env"):
-                    self.set("env", self._environment)
+            self.info("Deploying command '%s' " % command)
+            
+            if not self.get("env"):
+                self.set("env", self._environment)
 
-                self.discover()
-                self.provision()
-            except:
-                self.fail()
-                raise
-            self.debug("----- READY ---- ")
-            self._ready_time = tnow()
-            self._state = ResourceState.READY
+            self.do_discover()
+            self.do_provision()
+
+            self.set_ready()
 
     @property
     def _environment(self):
         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