README moves to markdown
[nepi.git] / nepi / resources / linux / ns3 / ccn / ns3ccnrdceapplication.py
1 #
2 #    NEPI, a framework to manage network experiments
3 #    Copyright (C) 2014 INRIA
4 #
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;
8 #
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.
13 #
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/>.
16 #
17 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
18
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
22
23 @clsinit_copy
24 class LinuxNS3DceCCNR(LinuxNS3CCNDceApplication):
25     _rtype = "linux::ns3::dce::CCNR"
26
27     @classmethod
28     def _register_attributes(cls):
29         max_fanout = Attribute("maxFanout",
30             "Sets the CCNR_BTREE_MAX_FANOUT environmental variable. ",
31             flags = Flags.Design)
32
33         max_leaf_entries = Attribute("maxLeafEntries",
34             "Sets the CCNR_BTREE_MAX_LEAF_ENTRIES environmental variable. ",
35             flags = Flags.Design)
36
37         max_node_bytes = Attribute("maxNodeBytes",
38             "Sets the CCNR_BTREE_MAX_NODE_BYTES environmental variable. ",
39             flags = Flags.Design)
40
41         max_node_pool = Attribute("maxNodePool",
42             "Sets the CCNR_BTREE_MAX_NODE_POOL environmental variable. ",
43             flags = Flags.Design)
44
45         content_cache = Attribute("contentCache",
46             "Sets the CCNR_CONTENT_CACHE environmental variable. ",
47             flags = Flags.Design)
48
49         debug = Attribute("debug",
50             "Sets the CCNR_DEBUG environmental variable. "
51             "Logging level for ccnr. Defaults to WARNING.",
52             type = Types.Enumerate,
53             allowed = [
54                     "NONE",
55                     "SEVERE",
56                     "ERROR",
57                     "WARNING",
58                     "INFO",
59                     "FINE, FINER, FINEST"],
60             flags = Flags.Design)
61
62         directory = Attribute("directory",
63             "Sets the CCNR_DIRECTORY environmental variable. ",
64             flags = Flags.Design)
65
66         global_prefix = Attribute("globalPrefix",
67             "Sets the CCNR_GLOBAL_PREFIX environmental variable. ",
68             flags = Flags.Design)
69
70         listen_on = Attribute("listenOn",
71             "Sets the CCNR_LISTEN_ON environmental variable. ",
72             flags = Flags.Design)
73
74         min_send_bufsize = Attribute("minSendBufsize",
75             "Sets the CCNR_MIN_SEND_BUFSIZE environmental variable. ",
76             flags = Flags.Design)
77
78         proto = Attribute("proto",
79             "Sets the CCNR_PROTO environmental variable. ",
80             flags = Flags.Design)
81
82         status_port = Attribute("statusPort",
83             "Sets the CCNR_STATUS_PORT environmental variable. ",
84             flags = Flags.Design)
85
86         start_write_scope_limit = Attribute("startWriteScopeLimit",
87             "Sets the CCNR_START_WRITE_SCOPE_LIMIT environmental variable. ",
88             flags = Flags.Design)
89
90         ccns_debug = Attribute("ccnsDebug",
91             "Sets the CCNS_DEBUG environmental variable. ",
92             flags = Flags.Design)
93
94         ccns_enable = Attribute("ccnsEnable",
95             "Sets the CCNS_ENABLE environmental variable. ",
96             flags = Flags.Design)
97
98         ccns_faux_error = Attribute("ccnsFauxError",
99             "Sets the CCNS_FAUX_ERROR environmental variable. ",
100             flags = Flags.Design)
101
102         ccns_heartbeat_micros = Attribute("ccnsHeartBeatMicros",
103             "Sets the CCNS_HEART_BEAT_MICROS environmental variable. ",
104             flags = Flags.Design)
105
106         ccns_max_compares_busy = Attribute("ccnsMaxComparesBusy",
107             "Sets the CCNS_MAX_COMPARES_BUSY environmental variable. ",
108             flags = Flags.Design)
109
110         ccns_max_fetch_busy = Attribute("ccnsMaxFetchBusy",
111             "Sets the CCNS_MAX_FETCH_BUSY environmental variable. ",
112             flags = Flags.Design)
113
114         ccns_node_fetch_lifetime = Attribute("ccnsNodeFetchLifetime",
115             "Sets the CCNS_NODE_FETCH_LIFETIME environmental variable. ",
116             flags = Flags.Design)
117
118         ccns_note_err = Attribute("ccnsNoteErr",
119             "Sets the CCNS_NOTE_ERR environmental variable. ",
120             flags = Flags.Design)
121
122         ccns_repo_store = Attribute("ccnsRepoStore",
123             "Sets the CCNS_REPO_STORE environmental variable. ",
124             flags = Flags.Design)
125
126         ccns_root_advise_fresh = Attribute("ccnsRootAdviseFresh",
127             "Sets the CCNS_ROOT_ADVISE_FRESH environmental variable. ",
128             flags = Flags.Design)
129
130         ccns_root_advise_lifetime = Attribute("ccnsRootAdviseLifetime",
131             "Sets the CCNS_ROOT_ADVISE_LIFETIME environmental variable. ",
132             flags = Flags.Design)
133
134         ccns_stable_enabled = Attribute("ccnsStableEnabled",
135             "Sets the CCNS_STABLE_ENABLED environmental variable. ",
136             flags = Flags.Design)
137
138         ccns_sync_scope = Attribute("ccnsSyncScope",
139             "Sets the CCNS_SYNC_SCOPE environmental variable. ",
140             flags = Flags.Design)
141
142         repo_file = Attribute("repoFile1",
143             "The Repository uses $CCNR_DIRECTORY/repoFile1 for "
144             "persistent storage of CCN Content Objects",
145             flags = Flags.Design)
146
147         cls._register_attribute(max_fanout)
148         cls._register_attribute(max_leaf_entries)
149         cls._register_attribute(max_node_bytes)
150         cls._register_attribute(max_node_pool)
151         cls._register_attribute(content_cache)
152         cls._register_attribute(debug)
153         cls._register_attribute(directory)
154         cls._register_attribute(global_prefix)
155         cls._register_attribute(listen_on)
156         cls._register_attribute(min_send_bufsize)
157         cls._register_attribute(proto)
158         cls._register_attribute(status_port)
159         cls._register_attribute(start_write_scope_limit)
160         cls._register_attribute(ccns_debug)
161         cls._register_attribute(ccns_enable)
162         cls._register_attribute(ccns_faux_error)
163         cls._register_attribute(ccns_heartbeat_micros)
164         cls._register_attribute(ccns_max_compares_busy)
165         cls._register_attribute(ccns_max_fetch_busy)
166         cls._register_attribute(ccns_node_fetch_lifetime)
167         cls._register_attribute(ccns_note_err)
168         cls._register_attribute(ccns_repo_store)
169         cls._register_attribute(ccns_root_advise_fresh)
170         cls._register_attribute(ccns_root_advise_lifetime)
171         cls._register_attribute(ccns_stable_enabled)
172         cls._register_attribute(ccns_sync_scope)
173         cls._register_attribute(repo_file)
174
175     def _instantiate_object(self):
176         if not self.get("binary"):
177             self.set("binary", "ccnr")
178
179         if not self.get("environment"):
180             self.set("environment", self._environment)
181        
182         repoFile1 = self.get("repoFile1")
183         if repoFile1:
184             env = "CCNR_DIRECTORY=/REPO/" 
185             environment = self.get("environment")
186             if environment:
187                 env += ";" + environment
188             self.set("environment", env)
189             self.set("files", "%s=/REPO/repoFile1" % repoFile1) 
190
191         super(LinuxNS3DceCCNR, self)._instantiate_object()
192
193     @property
194     def _environment(self):
195         envs = dict({
196             "maxFanout": "CCNR_BTREE_MAX_FANOUT",
197             "maxLeafEntries": "CCNR_BTREE_MAX_LEAF_ENTRIES",
198             "maxNodeBytes": "CCNR_BTREE_MAX_NODE_BYTES",
199             "maxNodePool": "CCNR_BTREE_MAX_NODE_POOL",
200             "contentCache": "CCNR_CONTENT_CACHE",
201             "debug": "CCNR_DEBUG",
202             "directory": "CCNR_DIRECTORY",
203             "globalPrefix": "CCNR_GLOBAL_PREFIX",
204             "listenOn": "CCNR_LISTEN_ON",
205             "minSendBufsize": "CCNR_MIN_SEND_BUFSIZE",
206             "proto": "CCNR_PROTO",
207             "statusPort": "CCNR_STATUS_PORT",
208             "startWriteScopeLimit": "CCNR_START_WRITE_SCOPE_LIMIT",
209             "ccnsDebug": "CCNS_DEBUG",
210             "ccnsEnable": "CCNS_ENABLE",
211             "ccnsFauxError": "CCNS_FAUX_ERROR",
212             "ccnsHeartBeatMicros": "CCNS_HEART_BEAT_MICROS",
213             "ccnsMaxComparesBusy": "CCNS_MAX_COMPARES_BUSY",
214             "ccnsMaxFetchBusy": "CCNS_MAX_FETCH_BUSY",
215             "ccnsNodeFetchLifetime": "CCNS_NODE_FETCH_LIFETIME",
216             "ccnsNoteErr": "CCNS_NOTE_ERR",
217             "ccnsRepoStore": "CCNS_REPO_STORE",
218             "ccnsRootAdviseFresh": "CCNS_ROOT_ADVISE_FRESH",
219             "ccnsRootAdviseLifetime": "CCNS_ROOT_ADVISE_LIFETIME",
220             "ccnsStableEnabled": "CCNS_STABLE_ENABLED",
221             "ccnsSyncScope": "CCNS_SYNC_SCOPE",
222             })
223
224         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)]])
225
226         return env
227
228