2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2014 INRIA
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation;
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
19 from nepi.execution.attribute import Attribute, Flags, Types
20 from nepi.execution.resource import clsinit_copy, ResourceState
21 from nepi.resources.linux.ns3.ccn.ns3ccndceapplication import LinuxNS3CCNDceApplication
26 class LinuxNS3DceCCND(LinuxNS3CCNDceApplication):
27 _rtype = "linux::ns3::dce::CCND"
30 def _register_attributes(cls):
31 debug = Attribute("debug", "Sets the CCND_DEBUG environmental variable. "
32 " Allowed values are : \n"
34 " 1 - basic messages (any non-zero value gets these) \n"
35 " 2 - interest messages \n"
36 " 4 - content messages \n"
37 " 8 - matching details \n"
38 " 16 - interest details \n"
39 " 32 - gory interest details \n"
40 " 64 - log occasional human-readable timestamps \n"
41 " 128 - face registration debugging \n"
42 " -1 - max logging \n"
43 " Or apply bitwise OR to these values to get combinations of them",
47 port = Attribute("port", "Sets the CCN_LOCAL_PORT environmental variable. "
51 sockname = Attribute("sockname",
52 "Sets the CCN_LOCAL_SCOKNAME environmental variable. "
53 "Defaults to /tmp/.ccnd.sock",
56 capacity = Attribute("capacity",
57 "Sets the CCND_CAP environmental variable. "
58 "Capacity limit in terms of ContentObjects",
61 mtu = Attribute("mtu", "Sets the CCND_MTU environmental variable. ",
64 data_pause = Attribute("dataPauseMicrosec",
65 "Sets the CCND_DATA_PAUSE_MICROSEC environmental variable. ",
68 default_stale = Attribute("defaultTimeToStale",
69 "Sets the CCND_DEFAULT_TIME_TO_STALE environmental variable. ",
72 max_stale = Attribute("maxTimeToStale",
73 "Sets the CCND_MAX_TIME_TO_STALE environmental variable. ",
76 max_rte = Attribute("maxRteMicrosec",
77 "Sets the CCND_MAX_RTE_MICROSEC environmental variable. ",
80 keystore = Attribute("keyStoreDirectory",
81 "Sets the CCND_KEYSTORE_DIRECTORY environmental variable. ",
84 listen_on = Attribute("listenOn",
85 "Sets the CCND_LISTEN_ON environmental variable. ",
88 autoreg = Attribute("autoreg",
89 "Sets the CCND_AUTOREG environmental variable. ",
92 prefix = Attribute("prefix",
93 "Sets the CCND_PREFIX environmental variable. ",
96 cls._register_attribute(debug)
97 cls._register_attribute(port)
98 cls._register_attribute(sockname)
99 cls._register_attribute(capacity)
100 cls._register_attribute(mtu)
101 cls._register_attribute(data_pause)
102 cls._register_attribute(default_stale)
103 cls._register_attribute(max_stale)
104 cls._register_attribute(max_rte)
105 cls._register_attribute(keystore)
106 cls._register_attribute(listen_on)
107 cls._register_attribute(autoreg)
108 cls._register_attribute(prefix)
114 def _instantiate_object(self):
115 if not self.get("depends"):
116 self.set("depends", self._dependencies)
118 if not self.get("sources"):
119 self.set("sources", self._sources)
121 sources = self.get("sources")
122 source = sources.split(" ")[0]
123 basename = os.path.basename(source)
124 self._version = ( basename.strip().replace(".tar.gz", "")
127 .replace(".zip","") )
129 if not self.get("build"):
130 self.set("build", self._build)
132 if not self.get("binary"):
133 self.set("binary", "ccnd")
135 if not self.get("environment"):
136 self.set("environment", self._environment)
138 super(LinuxNS3DceCCND, self)._instantiate_object()
141 def _dependencies(self):
142 if self.simulation.node.use_rpm:
143 return ( " autoconf openssl-devel expat-devel libpcap-devel "
144 " ecryptfs-utils-devel libxml2-devel automake gawk "
145 " gcc gcc-c++ git pcre-devel make ")
146 elif self.simulation.node.use_deb:
147 return ( " autoconf libssl-dev libexpat1-dev libpcap-dev "
148 " libecryptfs0 libxml2-utils automake gawk gcc g++ "
149 " git-core pkg-config libpcre3-dev make ")
154 #return "http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz"
155 return "http://www.ccnx.org/releases/ccnx-0.8.2.tar.gz"
159 sources = self.get("sources")
160 source = sources.split(" ")[0]
161 tar = os.path.basename(source)
164 # Evaluate if ccnx binaries are already installed
166 " test -f ${BIN_DCE}/ccnd && "
167 " echo 'binaries found, nothing to do' "
169 # If not, untar and build
171 " tar zxf ${SRC}/%(tar)s && "
172 " cd %(version)s && "
173 " INSTALL_BASE=${BIN_DCE}/.. ./configure && "
174 " make MORE_LDLIBS='-pie -rdynamic' && "
176 " cp ${BIN_DCE}/../bin/ccn* ${BIN_DCE} && "
178 " )") % ({ 'tar': tar,
179 'version': self.version
183 def _environment(self):
185 "debug": "CCND_DEBUG",
186 "port": "CCN_LOCAL_PORT",
187 "sockname" : "CCN_LOCAL_SOCKNAME",
188 "capacity" : "CCND_CAP",
190 "dataPauseMicrosec" : "CCND_DATA_PAUSE_MICROSEC",
191 "defaultTimeToStale" : "CCND_DEFAULT_TIME_TO_STALE",
192 "maxTimeToStale" : "CCND_MAX_TIME_TO_STALE",
193 "maxRteMicrosec" : "CCND_MAX_RTE_MICROSEC",
194 "keyStoreDirectory" : "CCND_KEYSTORE_DIRECTORY",
195 "listenOn" : "CCND_LISTEN_ON",
196 "autoreg" : "CCND_AUTOREG",
197 "prefix" : "CCND_PREFIX",
200 env = ";".join(["%s=%s" % (envs.get(k), str(self.get(k))) for k in [k for k in list(envs.keys()) if self.get(k)]])