+ Implemented option to cleanup directories on PlanetLab slivers.
[nepi.git] / src / nepi / testbeds / planetlab / application.py
index c460265..da4748a 100644 (file)
@@ -567,7 +567,7 @@ class Dependency(object):
     def _do_install(self):
         if self.install:
             self._logger.info("Installing %s at %s", self, self.node.hostname)
-            
+           
             # Install application
             try:
                 self._popen_ssh_command(
@@ -1105,48 +1105,87 @@ class CCNxDaemon(Application):
         super(CCNxDaemon,self).__init__(api)
         
         # Attributes
-        self.command = None
-        self.routes = None
-         
-        self.buildDepends = 'make gcc development-tools openssl-devel expat-devel libpcap-devel libxml2-devel'
+        self.ccnroutes = None
+        self.ccnsources = None
+        self.ccnxversion = "ccnx-0.6.0"
         
-        # We have to download the sources, untar, build...
-        ccnx_source_url = "http://www.ccnx.org/releases/ccnx-0.5.1.tar.gz"
+        self.ccnx_0_5_1_sources = "http://www.ccnx.org/releases/ccnx-0.5.1.tar.gz"
+        self.ccnx_0_6_0_sources = "http://www.ccnx.org/releases/ccnx-0.6.0.tar.gz"
+        self.buildDepends = 'make gcc development-tools openssl-devel expat-devel libpcap-devel libxml2-devel'
 
-        self.build = (
+        self.ccnx_0_5_1_build = (
             " ( "
             "  cd .. && "
-            "  test -d ccnx-src/build/bin "
+            "  test -d ccnx-0.5.1-src/build/bin "
             " ) || ( "
                 # Not working, rebuild
-                     "wget -q -c -O ccnx-src.tar.gz %(ccnx_source_url)s &&"
-                     "mkdir -p ccnx-src && "
-                     "tar xzf ccnx-src.tar.gz --strip-components=1 -C ccnx-src && "
-                     "cd ccnx-src && "
+                "("
+                     " mkdir -p ccnx-0.5.1-src && "
+                     " wget -q -c -O ccnx-0.5.1-src.tar.gz %(ccnx_source_url)s &&"
+                     " tar xf ccnx-0.5.1-src.tar.gz --strip-components=1 -C ccnx-0.5.1-src "
+                ") && "
+                     "cd ccnx-0.5.1-src && "
                      "mkdir -p build/include &&"
                      "mkdir -p build/lib &&"
                      "mkdir -p build/bin &&"
                      "I=$PWD/build && "
                      "INSTALL_BASE=$I ./configure &&"
                      "make && make install"
-             " )"  % dict(
-                     ccnx_source_url = server.shell_escape(ccnx_source_url),
-                 ))
+             " )") % dict(
+                     ccnx_source_url = server.shell_escape(self.ccnx_0_5_1_sources),
+                )
 
-        self.install = (
+        self.ccnx_0_5_1_install = (
+            " ( "
+            "  test -d ${BUILD}/ccnx-0.5.1-src/build/bin && "
+            "  cp -r ${BUILD}/ccnx-0.5.1-src/build/bin ${SOURCES}"
+            " )"
+        )
+
+        self.ccnx_0_6_0_build = (
             " ( "
             "  cd .. && "
-            "  test -d ${SOURCES}/bin "
+            "  test -d ccnx-0.6.0-src/build/bin "
             " ) || ( "
-            "  test -d ${BUILD}/ccnx-src/build/bin && "
-            "  cp -r ${BUILD}/ccnx-src/build/bin ${SOURCES}"
+                # Not working, rebuild
+                "("
+                     " mkdir -p ccnx-0.6.0-src && "
+                     " wget -q -c -O ccnx-0.6.0-src.tar.gz %(ccnx_source_url)s &&"
+                     " tar xf ccnx-0.6.0-src.tar.gz --strip-components=1 -C ccnx-0.6.0-src "
+                ") && "
+                     "cd ccnx-0.6.0-src && "
+                     "./configure && make"
+             " )") % dict(
+                     ccnx_source_url = server.shell_escape(self.ccnx_0_6_0_sources),
+                )
+
+        self.ccnx_0_6_0_install = (
+            " ( "
+            "  test -d ${BUILD}/ccnx-0.6.0-src/bin && "
+            "  cp -r ${BUILD}/ccnx-0.6.0-src/bin ${SOURCES}"
             " )"
         )
 
         self.env['PATH'] = "$PATH:${SOURCES}/bin"
-    
+
+    def setup(self):
+        # setting ccn sources
+        if not self.build:
+            if self.ccnxversion == 'ccnx-0.6.0':
+                self.build = self.ccnx_0_6_0_build
+            elif self.ccnxversion == 'ccnx-0.5.1':
+                self.build = self.ccnx_0_5_1_build
+
+        if not self.install:
+            if self.ccnxversion == 'ccnx-0.6.0':
+                self.install = self.ccnx_0_6_0_install
+            elif self.ccnxversion == 'ccnx-0.5.1':
+                self.install = self.ccnx_0_5_1_install
+
+        super(CCNxDaemon, self).setup()
+
     def start(self):
-        # Start will be invoked in prestart step
+        # configure ccn routes
         routes = ""
         if self.ccnroutes:
             routes = map(lambda route: "ccndc add ccnx:/ %s" % route, 
@@ -1154,6 +1193,7 @@ class CCNxDaemon(Application):
             routes = "; " + " ; ".join(routes)
         self.command = "ccndstart %s" % routes
 
+        # Start will be invoked in prestart step
         super(CCNxDaemon, self).start()
             
     def kill(self):