LinuxApplication: Changed directory structure to store experiment files in the Linux...
[nepi.git] / src / nepi / resources / linux / ccn / ccnd.py
index 6ebe5e3..7c150ea 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 tnow, tdiff
+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"
@@ -124,13 +126,14 @@ class LinuxCCND(LinuxApplication):
     def __init__(self, ec, guid):
         super(LinuxCCND, self).__init__(ec, guid)
         self._home = "ccnd-%s" % self.guid
+        self._version = None
+        self._environment = None
 
     def deploy(self):
         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"):
@@ -238,7 +241,7 @@ class LinuxCCND(LinuxApplication):
         # First check if the ccnd has failed
         state_check_delay = 0.5
         if self._state == ResourceState.STARTED and \
-                tdiff(tnow(), self._last_state_check) > state_check_delay:
+                tdiffsec(tnow(), self._last_state_check) > state_check_delay:
             (out, err), proc = self._ccndstatus
 
             retcode = proc.poll()
@@ -271,11 +274,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 ")
@@ -293,15 +296,15 @@ class LinuxCCND(LinuxApplication):
         return (
             # Evaluate if ccnx binaries are already installed
             " ( "
-                " test -f ${EXP_HOME}/ccnx/bin/ccnd && "
+                " test -f ${STORE}/ccnx/bin/ccnd && "
                 " echo 'sources found, nothing to do' "
             " ) || ( "
             # If not, untar and build
                 " ( "
-                    " mkdir -p ${SOURCES}/ccnx && "
-                    " tar xf ${SOURCES}/%(sources)s --strip-components=1 -C ${SOURCES}/ccnx "
+                    " mkdir -p ${STORE}/ccnx && "
+                    " tar xf ${STORE}/%(sources)s --strip-components=1 -C ${STORE}/ccnx "
                  " ) && "
-                    "cd ${SOURCES}/ccnx && "
+                    "cd ${STORE}/ccnx && "
                     # Just execute and silence warnings...
                     " ( ./configure && make ) "
              " )") % ({ 'sources': sources })
@@ -311,12 +314,12 @@ class LinuxCCND(LinuxApplication):
         return (
             # Evaluate if ccnx binaries are already installed
             " ( "
-                " test -f ${EXP_HOME}/ccnx/bin/ccnd && "
+                " test -f ${SOURCES}/ccnx/bin/ccnd && "
                 " echo 'sources found, nothing to do' "
             " ) || ( "
             # If not, install
-                "  mkdir -p ${EXP_HOME}/ccnx/bin && "
-                "  cp -r ${SOURCES}/ccnx ${EXP_HOME}"
+                "  mkdir -p ${SOURCES}/ccnx/bin && "
+                "  cp -r ${}/ccnx ${STORE}"
             " )"
             )
 
@@ -338,7 +341,7 @@ class LinuxCCND(LinuxApplication):
             "prefix" : "CCND_PREFIX",
             })
 
-        env = "PATH=$PATH:${EXP_HOME}/ccnx/bin "
+        env = "PATH=$PATH:${SOURCES}/ccnx/bin "
         env += " ".join(map(lambda k: "%s=%s" % (envs.get(k), str(self.get(k))) \
             if self.get(k) else "", envs.keys()))