1
|
|
|
# encoding: utf-8 |
2
|
|
|
""" |
3
|
|
|
setup.py |
4
|
|
|
|
5
|
|
|
Created by Thomas Mangin on 2014-12-23. |
6
|
|
|
Copyright (c) 2014-2017 Exa Networks. All rights reserved. |
7
|
|
|
License: 3-clause BSD. (See the COPYRIGHT file) |
8
|
|
|
""" |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
from exabgp.environment import parsing |
12
|
|
|
from exabgp.environment.environment import Env |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
_SPACE = {'space': ' ' * 33} |
16
|
|
|
|
17
|
|
|
LOGGING_HELP_STDOUT = ( |
18
|
|
|
"""\ |
19
|
|
|
where logging should log |
20
|
|
|
%(space)s syslog (or no setting) sends the data to the local syslog syslog |
21
|
|
|
%(space)s host:<location> sends the data to a remote syslog server |
22
|
|
|
%(space)s stdout sends the data to stdout |
23
|
|
|
%(space)s stderr sends the data to stderr |
24
|
|
|
%(space)s <filename> send the data to a file""" |
25
|
|
|
% _SPACE |
26
|
|
|
) |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
CONFIGURATION = { |
30
|
|
|
'profile': { |
31
|
|
|
'enable': { |
32
|
|
|
'read': parsing.boolean, |
33
|
|
|
'write': parsing.lower, |
34
|
|
|
'value': 'false', |
35
|
|
|
'help': 'toggle profiling of the code', |
36
|
|
|
}, |
37
|
|
|
'file': { |
38
|
|
|
'read': parsing.unquote, |
39
|
|
|
'write': parsing.quote, |
40
|
|
|
'value': '', |
41
|
|
|
'help': 'profiling result file, none means stdout, no overwriting', |
42
|
|
|
}, |
43
|
|
|
}, |
44
|
|
|
'pdb': { |
45
|
|
|
'enable': { |
46
|
|
|
'read': parsing.boolean, |
47
|
|
|
'write': parsing.lower, |
48
|
|
|
'value': 'false', |
49
|
|
|
'help': 'on program fault, start pdb the python interactive debugger', |
50
|
|
|
} |
51
|
|
|
}, |
52
|
|
|
'daemon': { |
53
|
|
|
'pid': { |
54
|
|
|
'read': parsing.unquote, |
55
|
|
|
'write': parsing.quote, |
56
|
|
|
'value': '', |
57
|
|
|
'help': 'where to save the pid if we manage it', |
58
|
|
|
}, |
59
|
|
|
'user': { |
60
|
|
|
'read': parsing.user, |
61
|
|
|
'write': parsing.quote, |
62
|
|
|
'value': 'nobody', |
63
|
|
|
'help': 'user to run the program as', |
64
|
|
|
}, |
65
|
|
|
'daemonize': { |
66
|
|
|
'read': parsing.boolean, |
67
|
|
|
'write': parsing.lower, |
68
|
|
|
'value': 'false', |
69
|
|
|
'help': 'should we run in the background', |
70
|
|
|
}, |
71
|
|
|
'drop': { |
72
|
|
|
'read': parsing.boolean, |
73
|
|
|
'write': parsing.lower, |
74
|
|
|
'value': 'true', |
75
|
|
|
'help': 'drop privileges before forking processes', |
76
|
|
|
}, |
77
|
|
|
'umask': { |
78
|
|
|
'read': parsing.umask_read, |
79
|
|
|
'write': parsing.umask_write, |
80
|
|
|
'value': '0137', |
81
|
|
|
'help': 'run daemon with this umask, governs perms of logfiles etc.', |
82
|
|
|
}, |
83
|
|
|
}, |
84
|
|
|
'log': { |
85
|
|
|
'enable': { |
86
|
|
|
'read': parsing.boolean, |
87
|
|
|
'write': parsing.lower, |
88
|
|
|
'value': 'true', |
89
|
|
|
'help': 'enable logging to file or syslog', |
90
|
|
|
}, |
91
|
|
|
'level': { |
92
|
|
|
'read': parsing.syslog_value, |
93
|
|
|
'write': parsing.syslog_name, |
94
|
|
|
'value': 'INFO', |
95
|
|
|
'help': 'log message with at least the priority SYSLOG.<level>', |
96
|
|
|
}, |
97
|
|
|
'destination': { |
98
|
|
|
'read': parsing.unquote, |
99
|
|
|
'write': parsing.quote, |
100
|
|
|
'value': 'stdout', |
101
|
|
|
'help': LOGGING_HELP_STDOUT, |
102
|
|
|
}, |
103
|
|
|
'all': { |
104
|
|
|
'read': parsing.boolean, |
105
|
|
|
'write': parsing.lower, |
106
|
|
|
'value': 'false', |
107
|
|
|
'help': 'report debug information for everything', |
108
|
|
|
}, |
109
|
|
|
'configuration': { |
110
|
|
|
'read': parsing.boolean, |
111
|
|
|
'write': parsing.lower, |
112
|
|
|
'value': 'true', |
113
|
|
|
'help': 'report command parsing', |
114
|
|
|
}, |
115
|
|
|
'reactor': { |
116
|
|
|
'read': parsing.boolean, |
117
|
|
|
'write': parsing.lower, |
118
|
|
|
'value': 'true', |
119
|
|
|
'help': 'report signal received, command reload', |
120
|
|
|
}, |
121
|
|
|
'daemon': { |
122
|
|
|
'read': parsing.boolean, |
123
|
|
|
'write': parsing.lower, |
124
|
|
|
'value': 'true', |
125
|
|
|
'help': 'report pid change, forking, ...', |
126
|
|
|
}, |
127
|
|
|
'processes': { |
128
|
|
|
'read': parsing.boolean, |
129
|
|
|
'write': parsing.lower, |
130
|
|
|
'value': 'true', |
131
|
|
|
'help': 'report handling of forked processes', |
132
|
|
|
}, |
133
|
|
|
'network': { |
134
|
|
|
'read': parsing.boolean, |
135
|
|
|
'write': parsing.lower, |
136
|
|
|
'value': 'true', |
137
|
|
|
'help': 'report networking information (TCP/IP, network state,...)', |
138
|
|
|
}, |
139
|
|
|
'packets': { |
140
|
|
|
'read': parsing.boolean, |
141
|
|
|
'write': parsing.lower, |
142
|
|
|
'value': 'false', |
143
|
|
|
'help': 'report BGP packets sent and received', |
144
|
|
|
}, |
145
|
|
|
'rib': { |
146
|
|
|
'read': parsing.boolean, |
147
|
|
|
'write': parsing.lower, |
148
|
|
|
'value': 'false', |
149
|
|
|
'help': 'report change in locally configured routes', |
150
|
|
|
}, |
151
|
|
|
'message': { |
152
|
|
|
'read': parsing.boolean, |
153
|
|
|
'write': parsing.lower, |
154
|
|
|
'value': 'false', |
155
|
|
|
'help': 'report changes in route announcement on config reload', |
156
|
|
|
}, |
157
|
|
|
'timers': { |
158
|
|
|
'read': parsing.boolean, |
159
|
|
|
'write': parsing.lower, |
160
|
|
|
'value': 'false', |
161
|
|
|
'help': 'report keepalives timers', |
162
|
|
|
}, |
163
|
|
|
'routes': { |
164
|
|
|
'read': parsing.boolean, |
165
|
|
|
'write': parsing.lower, |
166
|
|
|
'value': 'false', |
167
|
|
|
'help': 'report received routes', |
168
|
|
|
}, |
169
|
|
|
'parser': { |
170
|
|
|
'read': parsing.boolean, |
171
|
|
|
'write': parsing.lower, |
172
|
|
|
'value': 'false', |
173
|
|
|
'help': 'report BGP message parsing details', |
174
|
|
|
}, |
175
|
|
|
'short': { |
176
|
|
|
'read': parsing.boolean, |
177
|
|
|
'write': parsing.lower, |
178
|
|
|
'value': 'false', |
179
|
|
|
'help': 'use short log format (not prepended with time,level,pid and source)', |
180
|
|
|
}, |
181
|
|
|
}, |
182
|
|
|
'tcp': { |
183
|
|
|
'once': { |
184
|
|
|
'read': parsing.boolean, |
185
|
|
|
'write': parsing.lower, |
186
|
|
|
'value': 'false', |
187
|
|
|
'help': 'only one tcp connection attempt per peer (for debuging scripts)', |
188
|
|
|
}, |
189
|
|
|
'delay': { |
190
|
|
|
'read': parsing.integer, |
191
|
|
|
'write': parsing.nop, |
192
|
|
|
'value': '0', |
193
|
|
|
'help': 'start to announce route when the minutes in the hours is a modulo of this number', |
194
|
|
|
}, |
195
|
|
|
'bind': { |
196
|
|
|
'read': parsing.ip_list, |
197
|
|
|
'write': parsing.quote_list, |
198
|
|
|
'value': '', |
199
|
|
|
'help': 'Space separated list of IPs to bind on when listening (no ip to disable)', |
200
|
|
|
}, |
201
|
|
|
'port': { |
202
|
|
|
'read': parsing.integer, |
203
|
|
|
'write': parsing.nop, |
204
|
|
|
'value': '179', |
205
|
|
|
'help': 'port to bind on when listening', |
206
|
|
|
}, |
207
|
|
|
'acl': { |
208
|
|
|
'read': parsing.boolean, |
209
|
|
|
'write': parsing.lower, |
210
|
|
|
'value': '', |
211
|
|
|
'help': '(experimental please do not use) unimplemented', |
212
|
|
|
}, |
213
|
|
|
}, |
214
|
|
|
'bgp': { |
215
|
|
|
'openwait': { |
216
|
|
|
'read': parsing.integer, |
217
|
|
|
'write': parsing.nop, |
218
|
|
|
'value': '60', |
219
|
|
|
'help': 'how many second we wait for an open once the TCP session is established', |
220
|
|
|
}, |
221
|
|
|
}, |
222
|
|
|
'cache': { |
223
|
|
|
'attributes': { |
224
|
|
|
'read': parsing.boolean, |
225
|
|
|
'write': parsing.lower, |
226
|
|
|
'value': 'true', |
227
|
|
|
'help': 'cache all attributes (configuration and wire) for faster parsing', |
228
|
|
|
}, |
229
|
|
|
'nexthops': { |
230
|
|
|
'read': parsing.boolean, |
231
|
|
|
'write': parsing.lower, |
232
|
|
|
'value': 'true', |
233
|
|
|
'help': 'cache routes next-hops (deprecated: next-hops are always cached)', |
234
|
|
|
}, |
235
|
|
|
}, |
236
|
|
|
'api': { |
237
|
|
|
'ack': { |
238
|
|
|
'read': parsing.boolean, |
239
|
|
|
'write': parsing.lower, |
240
|
|
|
'value': 'true', |
241
|
|
|
'help': 'acknowledge api command(s) and report issues', |
242
|
|
|
}, |
243
|
|
|
'chunk': { |
244
|
|
|
'read': parsing.integer, |
245
|
|
|
'write': parsing.nop, |
246
|
|
|
'value': '1', |
247
|
|
|
'help': 'maximum lines to print before yielding in show routes api', |
248
|
|
|
}, |
249
|
|
|
'encoder': { |
250
|
|
|
'read': parsing.api, |
251
|
|
|
'write': parsing.lower, |
252
|
|
|
'value': 'json', |
253
|
|
|
'help': '(experimental) default encoder to use with with external API (text or json)', |
254
|
|
|
}, |
255
|
|
|
'compact': { |
256
|
|
|
'read': parsing.boolean, |
257
|
|
|
'write': parsing.lower, |
258
|
|
|
'value': 'false', |
259
|
|
|
'help': 'shorter JSON encoding for IPv4/IPv6 Unicast NLRI', |
260
|
|
|
}, |
261
|
|
|
'respawn': { |
262
|
|
|
'read': parsing.boolean, |
263
|
|
|
'write': parsing.lower, |
264
|
|
|
'value': 'true', |
265
|
|
|
'help': 'should we try to respawn helper processes if they dies', |
266
|
|
|
}, |
267
|
|
|
'terminate': { |
268
|
|
|
'read': parsing.boolean, |
269
|
|
|
'write': parsing.lower, |
270
|
|
|
'value': 'false', |
271
|
|
|
'help': 'should we terminate ExaBGP if any helper process dies', |
272
|
|
|
}, |
273
|
|
|
'cli': { |
274
|
|
|
'read': parsing.boolean, |
275
|
|
|
'write': parsing.lower, |
276
|
|
|
'value': 'true', |
277
|
|
|
'help': 'should we create a named pipe for the cli', |
278
|
|
|
}, |
279
|
|
|
'pipename': { |
280
|
|
|
'read': parsing.unquote, |
281
|
|
|
'write': parsing.quote, |
282
|
|
|
'value': 'exabgp', |
283
|
|
|
'help': 'name to be used for the exabgp pipe', |
284
|
|
|
}, |
285
|
|
|
}, |
286
|
|
|
'reactor': { |
287
|
|
|
'speed': { |
288
|
|
|
'read': parsing.real, |
289
|
|
|
'write': parsing.nop, |
290
|
|
|
'value': '1.0', |
291
|
|
|
'help': 'reactor loop time\n%(space)s use only if you understand the code.' % _SPACE, |
292
|
|
|
}, |
293
|
|
|
}, |
294
|
|
|
# Here for internal use |
295
|
|
|
'debug': { |
296
|
|
|
'pdb': { |
297
|
|
|
'read': parsing.boolean, |
298
|
|
|
'write': parsing.lower, |
299
|
|
|
'value': 'false', |
300
|
|
|
'help': 'enable python debugger on errors', |
301
|
|
|
}, |
302
|
|
|
'memory': { |
303
|
|
|
'read': parsing.boolean, |
304
|
|
|
'write': parsing.lower, |
305
|
|
|
'value': 'false', |
306
|
|
|
'help': 'command line option --memory', |
307
|
|
|
}, |
308
|
|
|
'configuration': { |
309
|
|
|
'read': parsing.boolean, |
310
|
|
|
'write': parsing.lower, |
311
|
|
|
'value': 'false', |
312
|
|
|
'help': 'undocumented option: raise when parsing configuration errors', |
313
|
|
|
}, |
314
|
|
|
'selfcheck': { |
315
|
|
|
'read': parsing.boolean, |
316
|
|
|
'write': parsing.lower, |
317
|
|
|
'value': 'false', |
318
|
|
|
'help': 'does a self check on the configuration file', |
319
|
|
|
}, |
320
|
|
|
'route': { |
321
|
|
|
'read': parsing.unquote, |
322
|
|
|
'write': parsing.quote, |
323
|
|
|
'value': '', |
324
|
|
|
'help': 'decode the route using the configuration', |
325
|
|
|
}, |
326
|
|
|
'defensive': { |
327
|
|
|
'read': parsing.boolean, |
328
|
|
|
'write': parsing.lower, |
329
|
|
|
'value': 'false', |
330
|
|
|
'help': 'generate random fault in the code in purpose', |
331
|
|
|
}, |
332
|
|
|
'rotate': { |
333
|
|
|
'read': parsing.boolean, |
334
|
|
|
'write': parsing.lower, |
335
|
|
|
'value': 'false', |
336
|
|
|
'help': 'rotate configurations file on reload (signal)', |
337
|
|
|
}, |
338
|
|
|
}, |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
# load the environment |
342
|
|
|
Env.setup(CONFIGURATION) |
343
|
|
|
|