From: Alina Quereilhac Date: Tue, 10 Apr 2012 17:30:56 +0000 (+0200) Subject: Added an attribute to set user defined sources for PlanetLab CCNx daemon. X-Git-Tag: nepi-3.0.0~163^2~21 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=18173e8124ead11e35cc9151edc2e36c3d111da0;p=nepi.git Added an attribute to set user defined sources for PlanetLab CCNx daemon. --- diff --git a/src/nepi/testbeds/planetlab/application.py b/src/nepi/testbeds/planetlab/application.py index c460265b..dc69a51b 100644 --- a/src/nepi/testbeds/planetlab/application.py +++ b/src/nepi/testbeds/planetlab/application.py @@ -1105,23 +1105,27 @@ 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 - # We have to download the sources, untar, build... - ccnx_source_url = "http://www.ccnx.org/releases/ccnx-0.5.1.tar.gz" + self.default_ccnx_sources = "http://www.ccnx.org/releases/ccnx-0.5.1.tar.gz" + self.buildDepends = 'make gcc development-tools openssl-devel expat-devel libpcap-devel libxml2-devel' - self.build = ( + self.default_build = ( " ( " " cd .. && " " test -d ccnx-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 && " + "(" + " mkdir -p ccnx-src && " + " ( %(not_custom_source)s &&" + " wget -q -c -O ccnx-src.tar.gz %(ccnx_source_url)s &&" + " tar xf ccnx-src.tar.gz --strip-components=1 -C ccnx-src " + " ) || ( " + " tar xf %(user_ccnx_tar)s --strip-components=1 -C ccnx-src " + " ) " + ") && " "cd ccnx-src && " "mkdir -p build/include &&" "mkdir -p build/lib &&" @@ -1129,11 +1133,9 @@ class CCNxDaemon(Application): "I=$PWD/build && " "INSTALL_BASE=$I ./configure &&" "make && make install" - " )" % dict( - ccnx_source_url = server.shell_escape(ccnx_source_url), - )) + " )") - self.install = ( + self.default_install = ( " ( " " cd .. && " " test -d ${SOURCES}/bin " @@ -1144,16 +1146,37 @@ class CCNxDaemon(Application): ) self.env['PATH'] = "$PATH:${SOURCES}/bin" - + + def setup(self): + # setting ccn sources + not_custom_source = "true" + sources = "" + if self.ccnsources: + self.sources = self.ccnsources + sources = "${SOURCES}/%s" % os.path.basename(self.ccnsources) + not_custom_source = "false" + + if not self.build: + self.build = self.default_build % dict( + ccnx_source_url = server.shell_escape(self.default_ccnx_sources), + not_custom_source = server.shell_escape(not_custom_source), + user_ccnx_tar = sources + ) + + if not self.install: + self.install = self.default_install + + super(CCNxDaemon, self).setup() + def start(self): - # Start will be invoked in prestart step - routes = "" + # configure ccn routes if self.ccnroutes: routes = map(lambda route: "ccndc add ccnx:/ %s" % route, self.ccnroutes.split("|")) routes = "; " + " ; ".join(routes) self.command = "ccndstart %s" % routes + # Start will be invoked in prestart step super(CCNxDaemon, self).start() def kill(self): diff --git a/src/nepi/testbeds/planetlab/metadata.py b/src/nepi/testbeds/planetlab/metadata.py index 7b6e3f92..7c7c5302 100644 --- a/src/nepi/testbeds/planetlab/metadata.py +++ b/src/nepi/testbeds/planetlab/metadata.py @@ -1179,6 +1179,14 @@ attributes = dict({ "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable, "validation_function": validation.is_string }), + "ccnsources": dict({ + "name": "ccnsources", + "help": "Path to local tar with ccnx sources." + "Default source is http://www.ccnx.org/releases/ccnx-0.5.1.tar.gz", + "type": Attribute.STRING, + "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable, + "validation_function": validation.is_string + }), "build": dict({ "name": "build", "help": "Build commands to execute after deploying the sources. " @@ -1565,7 +1573,7 @@ factories_info = dict({ "status_function": status_application, "stop_function": stop_application, "configure_function": configure_application, - "box_attributes": ["ccnroutes"], + "box_attributes": ["ccnroutes", "ccnsources", "build", "install"], "connector_types": ["node"], "traces": ["stdout", "stderr", "buildlog", "output"], "tags": [tags.APPLICATION],