oxidized 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +30 -4
- data/.github/ISSUE_TEMPLATE/feature_request.md +10 -3
- data/.github/ISSUE_TEMPLATE/support-request.md +30 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +3 -1
- data/.github/workflows/codeql.yml +4 -4
- data/.github/workflows/publishdocker.yml +2 -2
- data/.github/workflows/ruby.yml +10 -3
- data/.github/workflows/stale.yml +1 -1
- data/.rubocop_todo.yml +2 -8
- data/AGENTS.md +174 -0
- data/CHANGELOG.md +101 -0
- data/CONTRIBUTING.md +78 -44
- data/Dockerfile +8 -4
- data/README.md +8 -1
- data/docs/Creating-Models.md +5 -5
- data/docs/DeviceSimulation.md +80 -51
- data/docs/Docker.md +49 -0
- data/docs/Inputs.md +81 -5
- data/docs/Issues.md +49 -13
- data/docs/Model-Notes/FTD.md +64 -0
- data/docs/Model-Notes/HPEAruba.md +5 -0
- data/docs/Model-Notes/ITMGOS.md +40 -0
- data/docs/Model-Notes/PanOS_API.md +20 -1
- data/docs/Model-Notes/TPLink.md +75 -0
- data/docs/Outputs.md +1 -0
- data/docs/Release.md +43 -21
- data/docs/Ruby-API.md +231 -9
- data/docs/Supported-OS-Types.md +10 -5
- data/docs/Troubleshooting.md +8 -9
- data/extra/device2yaml.rb +21 -5
- data/extra/hooks/modelrulesadvanced.rb +2 -3
- data/extra/oxidized.service +0 -1
- data/extra/syslog.rb +1 -1
- data/lib/oxidized/cli/support.rb +4 -7
- data/lib/oxidized/config/vars.rb +2 -1
- data/lib/oxidized/core.rb +20 -0
- data/lib/oxidized/hook/ciscosparkdiff.rb +1 -1
- data/lib/oxidized/hook/slackdiff.rb +1 -1
- data/lib/oxidized/hook/xmppdiff.rb +2 -2
- data/lib/oxidized/input/cli.rb +14 -2
- data/lib/oxidized/input/http.rb +22 -7
- data/lib/oxidized/input/scp.rb +3 -1
- data/lib/oxidized/input/sshbase.rb +43 -12
- data/lib/oxidized/input/telnet.rb +2 -2
- data/lib/oxidized/model/acos.rb +2 -2
- data/lib/oxidized/model/acsw.rb +1 -1
- data/lib/oxidized/model/adtran.rb +1 -1
- data/lib/oxidized/model/aireos.rb +3 -3
- data/lib/oxidized/model/aoscx.rb +7 -3
- data/lib/oxidized/model/aosw.rb +8 -13
- data/lib/oxidized/model/arbos.rb +1 -1
- data/lib/oxidized/model/aricentiss.rb +1 -1
- data/lib/oxidized/model/asa.rb +1 -1
- data/lib/oxidized/model/asternos.rb +1 -1
- data/lib/oxidized/model/audiocodesmp.rb +1 -1
- data/lib/oxidized/model/awplus.rb +4 -3
- data/lib/oxidized/model/bdcom.rb +1 -1
- data/lib/oxidized/model/br6910.rb +1 -1
- data/lib/oxidized/model/c4cmts.rb +1 -1
- data/lib/oxidized/model/ciscosmb.rb +0 -1
- data/lib/oxidized/model/cnos.rb +10 -1
- data/lib/oxidized/model/comnetms.rb +1 -1
- data/lib/oxidized/model/coriantgroove.rb +1 -1
- data/lib/oxidized/model/dellx.rb +1 -1
- data/lib/oxidized/model/dlink.rb +1 -1
- data/lib/oxidized/model/dlinknextgen.rb +1 -1
- data/lib/oxidized/model/dnos.rb +2 -2
- data/lib/oxidized/model/eatonnetwork.rb +33 -32
- data/lib/oxidized/model/eciapollo.rb +1 -1
- data/lib/oxidized/model/edgeos.rb +3 -3
- data/lib/oxidized/model/enterasys.rb +1 -1
- data/lib/oxidized/model/eos.rb +1 -0
- data/lib/oxidized/model/fastiron.rb +10 -1
- data/lib/oxidized/model/fiberdriver.rb +1 -1
- data/lib/oxidized/model/firelinuxos.rb +1 -1
- data/lib/oxidized/model/fortigate.rb +15 -2
- data/lib/oxidized/model/fortios.rb +1 -1
- data/lib/oxidized/model/ftd.rb +183 -0
- data/lib/oxidized/model/ftos.rb +2 -2
- data/lib/oxidized/model/garderos.rb +16 -5
- data/lib/oxidized/model/hpebladesystem.rb +1 -1
- data/lib/oxidized/model/ibos.rb +1 -2
- data/lib/oxidized/model/ingate.rb +15 -1
- data/lib/oxidized/model/iosxr.rb +9 -3
- data/lib/oxidized/model/ironware.rb +1 -1
- data/lib/oxidized/model/itmgos.rb +74 -0
- data/lib/oxidized/model/junos.rb +8 -2
- data/lib/oxidized/model/kornfeldos.rb +2 -4
- data/lib/oxidized/model/lancom.rb +2 -2
- data/lib/oxidized/model/masteros.rb +1 -1
- data/lib/oxidized/model/mlnxos.rb +1 -1
- data/lib/oxidized/model/model.rb +5 -2
- data/lib/oxidized/model/mtrlrfs.rb +1 -1
- data/lib/oxidized/model/ndms.rb +1 -1
- data/lib/oxidized/model/necix.rb +1 -1
- data/lib/oxidized/model/netgear.rb +1 -1
- data/lib/oxidized/model/netscaler.rb +1 -1
- data/lib/oxidized/model/nxos.rb +11 -2
- data/lib/oxidized/model/ocnos.rb +1 -1
- data/lib/oxidized/model/onefinity.rb +1 -1
- data/lib/oxidized/model/oneos.rb +0 -1
- data/lib/oxidized/model/openbsd.rb +1 -1
- data/lib/oxidized/model/os10.rb +2 -2
- data/lib/oxidized/model/os6.rb +3 -2
- data/lib/oxidized/model/panos.rb +1 -1
- data/lib/oxidized/model/panos_api.rb +42 -14
- data/lib/oxidized/model/procurve.rb +63 -31
- data/lib/oxidized/model/routeros.rb +2 -1
- data/lib/oxidized/model/screenos.rb +2 -2
- data/lib/oxidized/model/sgos.rb +1 -1
- data/lib/oxidized/model/siklu.rb +2 -2
- data/lib/oxidized/model/slxos.rb +1 -1
- data/lib/oxidized/model/sonicos.rb +2 -2
- data/lib/oxidized/model/tdre.rb +2 -2
- data/lib/oxidized/model/telco.rb +1 -1
- data/lib/oxidized/model/tmos.rb +11 -2
- data/lib/oxidized/model/tplink.rb +4 -4
- data/lib/oxidized/model/viptela.rb +1 -1
- data/lib/oxidized/model/voltaire.rb +1 -1
- data/lib/oxidized/model/vrp.rb +14 -8
- data/lib/oxidized/model/vsololt.rb +93 -0
- data/lib/oxidized/model/vyatta.rb +3 -3
- data/lib/oxidized/model/vyos.rb +5 -1
- data/lib/oxidized/model/xos.rb +1 -1
- data/lib/oxidized/model/zhoneolt.rb +1 -1
- data/lib/oxidized/node.rb +9 -9
- data/lib/oxidized/nodes.rb +5 -13
- data/lib/oxidized/output/git.rb +72 -81
- data/lib/oxidized/output/gitcrypt.rb +13 -32
- data/lib/oxidized/redact.rb +18 -0
- data/lib/oxidized/signals.rb +2 -16
- data/lib/oxidized/source/source.rb +5 -1
- data/lib/oxidized/source/sql.rb +1 -0
- data/lib/oxidized/version.rb +2 -2
- data/lib/oxidized.rb +1 -0
- data/lib/refinements.rb +7 -3
- data/oxidized.gemspec +20 -11
- metadata +69 -29
data/docs/Ruby-API.md
CHANGED
|
@@ -35,6 +35,7 @@ The following objects exist in Oxidized.
|
|
|
35
35
|
- [cut_both](#cut_both)
|
|
36
36
|
- [keep_lines](#keep_lines)
|
|
37
37
|
- [reject_lines](#reject_lines)
|
|
38
|
+
- [rstrip_lines](#rstrip_lines)
|
|
38
39
|
|
|
39
40
|
## Input
|
|
40
41
|
|
|
@@ -91,6 +92,20 @@ it at least once is required for a model to work.
|
|
|
91
92
|
The block may contain commands to change some behaviour for the given methods
|
|
92
93
|
(e.g. calling `post_login` to disable the pager).
|
|
93
94
|
|
|
95
|
+
Example from [ios.rb](/lib/oxidized/model/ios.rb):
|
|
96
|
+
```ruby
|
|
97
|
+
cfg :telnet do
|
|
98
|
+
username /^Username:/i
|
|
99
|
+
password /^Password:/i
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
cfg :telnet, :ssh do
|
|
103
|
+
post_login 'terminal length 0'
|
|
104
|
+
post_login 'terminal width 0'
|
|
105
|
+
pre_logout 'exit'
|
|
106
|
+
end
|
|
107
|
+
```
|
|
108
|
+
|
|
94
109
|
Supports [monkey patching](#monkey-patching).
|
|
95
110
|
|
|
96
111
|
#### 'inputs'
|
|
@@ -165,10 +180,46 @@ significant changes only and will be used to
|
|
|
165
180
|
Execution order is `:all`, `:secret`, and lastly the command specific block, if
|
|
166
181
|
given.
|
|
167
182
|
|
|
183
|
+
Examples, mostly taken from [ios.rb](/lib/oxidized/model/ios.rb):
|
|
184
|
+
```ruby
|
|
185
|
+
# Emit the output as is
|
|
186
|
+
cmd 'show running-config'
|
|
187
|
+
|
|
188
|
+
# Emit the output as a comment
|
|
189
|
+
cmd 'show inventory' do |cfg|
|
|
190
|
+
comment cfg
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Remove the command echo and the prompt from every command output
|
|
194
|
+
cmd :all do |cfg|
|
|
195
|
+
cfg.cut_both
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Hide secrets when remove_secret is enabled
|
|
199
|
+
cmd :secret do |cfg|
|
|
200
|
+
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
|
|
201
|
+
cfg.gsub! /^(username .+ (password|secret) \d) .+/, '\\1 <secret hidden>'
|
|
202
|
+
cfg
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Ignore lines that change without a real configuration change
|
|
206
|
+
cmd :significant_changes do |cfg|
|
|
207
|
+
cfg.reject_lines [
|
|
208
|
+
/^! (Last|No) configuration change (at|since)/,
|
|
209
|
+
'! NVRAM config last updated at'
|
|
210
|
+
]
|
|
211
|
+
end
|
|
212
|
+
```
|
|
213
|
+
|
|
168
214
|
The `cmd "string"` method accepts a lambda function via the `:if` argument
|
|
169
215
|
to execute the command only when the lambda evaluates to true.
|
|
170
216
|
The lambda function is evaluated at runtime in the instance context.
|
|
171
217
|
See [Conditional `cmd`](Creating-Models.md#conditional-cmd) for details.
|
|
218
|
+
```ruby
|
|
219
|
+
cmd 'show vrrp', if: -> { vars(:show_vrrp) } do |cfg|
|
|
220
|
+
comment cfg
|
|
221
|
+
end
|
|
222
|
+
```
|
|
172
223
|
|
|
173
224
|
The `cmd "string"` method accepts a list of supported inputs via the `:input`
|
|
174
225
|
argument to limit this command to specific inputs.
|
|
@@ -202,6 +253,10 @@ emitted configuration for this model.
|
|
|
202
253
|
|
|
203
254
|
If not specified the default of `'# '` will be used (note the trailing space).
|
|
204
255
|
|
|
256
|
+
```ruby
|
|
257
|
+
comment '! '
|
|
258
|
+
```
|
|
259
|
+
|
|
205
260
|
#### `prompt`
|
|
206
261
|
|
|
207
262
|
Is called with a regular expression that is used to detect when command output
|
|
@@ -209,23 +264,59 @@ ends after a command has been executed.
|
|
|
209
264
|
|
|
210
265
|
If not specified, a default of `/^([\w.@-]+[#>]\s?)$/` is used.
|
|
211
266
|
|
|
267
|
+
Example from [procurve.rb](/lib/oxidized/model/procurve.rb), where the prompt
|
|
268
|
+
may be preceded by a carriage return:
|
|
269
|
+
```ruby
|
|
270
|
+
prompt /^\r?([\w\s.-]+[#>] )$/
|
|
271
|
+
```
|
|
272
|
+
|
|
212
273
|
#### `expect`
|
|
213
274
|
|
|
214
|
-
Called with a regular expression and a block. The block takes two
|
|
215
|
-
the
|
|
275
|
+
Called with a regular expression and a block. The block takes up to two
|
|
276
|
+
parameters: the data containing the match, and the regular expression.
|
|
216
277
|
|
|
217
|
-
The
|
|
278
|
+
The data contains all the output received so far for the current command, and
|
|
279
|
+
is replaced by the return value of the block. Use `data.sub re, ''` to remove
|
|
280
|
+
only the match; returning an empty string discards all the output received so
|
|
281
|
+
far.
|
|
218
282
|
|
|
219
283
|
`expect` can be used to, for example, strip escape sequences from output before
|
|
220
|
-
it's further processed.
|
|
284
|
+
it's further processed, or to answer interactive questions and pagers.
|
|
285
|
+
|
|
286
|
+
Example from [fortigate.rb](/lib/oxidized/model/fortigate.rb), handling the
|
|
287
|
+
pager:
|
|
288
|
+
```ruby
|
|
289
|
+
expect /^--More--\s$/ do |data, re|
|
|
290
|
+
send ' '
|
|
291
|
+
data.sub re, ''
|
|
292
|
+
end
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Example from [procurve.rb](/lib/oxidized/model/procurve.rb), answering a
|
|
296
|
+
prompt shown after login. As no command has been run yet, the block can discard
|
|
297
|
+
the data by returning an empty string:
|
|
298
|
+
```ruby
|
|
299
|
+
expect /Press any key to continue$/ do
|
|
300
|
+
send "\n"
|
|
301
|
+
""
|
|
302
|
+
end
|
|
303
|
+
```
|
|
221
304
|
|
|
222
305
|
Supports [monkey patching](#monkey-patching).
|
|
223
306
|
|
|
224
307
|
#### `macro :enable`
|
|
225
308
|
Implements an [handling of enable](Creating-Models.md#handling-enable-mode) for the model.
|
|
309
|
+
```ruby
|
|
310
|
+
macro :enable
|
|
311
|
+
# or, with options:
|
|
312
|
+
macro :enable, inputs: :ssh, command: "su -", regex: /Passwort: /
|
|
313
|
+
```
|
|
226
314
|
|
|
227
315
|
#### `clean :escape_codes`
|
|
228
316
|
[Remove ANSI escape codes](Creating-Models.md#remove-ansi-escape-codes) from the output.
|
|
317
|
+
```ruby
|
|
318
|
+
clean :escape_codes
|
|
319
|
+
```
|
|
229
320
|
|
|
230
321
|
#### `clean :cut`
|
|
231
322
|
Removes (default) the first and last line of the outputs (most of the time
|
|
@@ -252,11 +343,27 @@ The following methods are available:
|
|
|
252
343
|
Used inside `cmd` invocations. Comments out every line in the passed string and
|
|
253
344
|
returns the result.
|
|
254
345
|
|
|
346
|
+
```ruby
|
|
347
|
+
cmd 'show version' do |cfg|
|
|
348
|
+
comment cfg
|
|
349
|
+
end
|
|
350
|
+
```
|
|
351
|
+
|
|
255
352
|
#### `password`
|
|
256
353
|
|
|
257
354
|
Used inside `cfg` invocations to specify the regular expression used to detect
|
|
258
355
|
the password prompt. If not specified, the default of `/^Password/` is used.
|
|
259
356
|
|
|
357
|
+
Similarly, `username` specifies the regular expression for the username prompt
|
|
358
|
+
(default: `/^(Username|login)/`).
|
|
359
|
+
|
|
360
|
+
```ruby
|
|
361
|
+
cfg :telnet do
|
|
362
|
+
username /^Username:/i
|
|
363
|
+
password /^Password:/i
|
|
364
|
+
end
|
|
365
|
+
```
|
|
366
|
+
|
|
260
367
|
#### `post_login`
|
|
261
368
|
|
|
262
369
|
Used inside `cfg` invocations to specify commands to run once Oxidized has
|
|
@@ -267,6 +374,19 @@ This allows `post_login` to be used for any model-specific items prior to
|
|
|
267
374
|
running the regular commands. This could include disabling the output pager
|
|
268
375
|
or timestamp outputs that would cause constant differences.
|
|
269
376
|
|
|
377
|
+
Example from [procurve.rb](/lib/oxidized/model/procurve.rb):
|
|
378
|
+
```ruby
|
|
379
|
+
cfg :telnet, :ssh do
|
|
380
|
+
if vars :enable
|
|
381
|
+
post_login do
|
|
382
|
+
send "enable\n"
|
|
383
|
+
cmd vars(:enable)
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
post_login 'no page'
|
|
387
|
+
end
|
|
388
|
+
```
|
|
389
|
+
|
|
270
390
|
Supports [monkey patching](#monkey-patching).
|
|
271
391
|
|
|
272
392
|
#### `pre_logout`
|
|
@@ -278,17 +398,44 @@ string containing a command to execute.
|
|
|
278
398
|
This allows `pre_logout` to be used to 'undo' any changes that may have been
|
|
279
399
|
needed via `post_login` (restore pager output, etc.)
|
|
280
400
|
|
|
401
|
+
Example from [procurve.rb](/lib/oxidized/model/procurve.rb), answering the
|
|
402
|
+
questions asked on logout:
|
|
403
|
+
```ruby
|
|
404
|
+
cfg :telnet, :ssh do
|
|
405
|
+
pre_logout 'logout'
|
|
406
|
+
pre_logout 'y'
|
|
407
|
+
pre_logout 'n'
|
|
408
|
+
end
|
|
409
|
+
```
|
|
410
|
+
|
|
281
411
|
Supports [monkey patching](#monkey-patching).
|
|
282
412
|
|
|
283
413
|
#### `send`
|
|
284
414
|
|
|
285
415
|
Usually used inside `expect` or blocks passed to `post_login`/`pre_logout`.
|
|
286
|
-
Takes a single parameter: a string to be sent to the device.
|
|
416
|
+
Takes a single parameter: a string to be sent to the device. Unlike `cmd`, it
|
|
417
|
+
does not wait for the prompt and does not append a newline.
|
|
418
|
+
|
|
419
|
+
See the examples in [expect](#expect) and [post_login](#post_login).
|
|
287
420
|
|
|
288
421
|
#### `cmd`
|
|
289
422
|
You can nest a `cmd` block inside first level blocks. It will be executed at
|
|
290
423
|
runtime.
|
|
291
424
|
|
|
425
|
+
Example from [nxos.rb](/lib/oxidized/model/nxos.rb):
|
|
426
|
+
```ruby
|
|
427
|
+
cmd 'show inventory all' do |cfg|
|
|
428
|
+
if cfg.match? /^% Invalid .* at '\^' marker\./
|
|
429
|
+
# 'show inventory all' isn't supported on older versions
|
|
430
|
+
cfg = cmd 'show inventory'
|
|
431
|
+
end
|
|
432
|
+
comment cfg
|
|
433
|
+
end
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
See [Conditional commands](Creating-Models.md#conditional-commands) for more
|
|
437
|
+
examples.
|
|
438
|
+
|
|
292
439
|
### Monkey patching
|
|
293
440
|
|
|
294
441
|
Several model blocks accept behavior-modifying arguments that make monkey
|
|
@@ -301,11 +448,23 @@ blocks.
|
|
|
301
448
|
#### `clear: true`
|
|
302
449
|
Resets the existing block, allowing the user to completely override its contents.
|
|
303
450
|
|
|
451
|
+
```ruby
|
|
452
|
+
cmd 'show version', clear: true do |cfg|
|
|
453
|
+
comment cfg
|
|
454
|
+
end
|
|
455
|
+
```
|
|
456
|
+
|
|
304
457
|
#### `prepend: true`
|
|
305
458
|
|
|
306
459
|
Ensures that the contents of the block are prepended, rather than appended (the
|
|
307
460
|
default) to an existing block.
|
|
308
461
|
|
|
462
|
+
```ruby
|
|
463
|
+
cfg :ssh, prepend: true do
|
|
464
|
+
post_login 'terminal no-more'
|
|
465
|
+
end
|
|
466
|
+
```
|
|
467
|
+
|
|
309
468
|
### Refinements
|
|
310
469
|
|
|
311
470
|
#### `String` convenience methods
|
|
@@ -314,23 +473,86 @@ Since configuration processing tasks are occasionally similar across models,
|
|
|
314
473
|
Oxidized provides an refined [`String`](../lib/refinements.rb) class with the
|
|
315
474
|
intention of providing convenience methods and eliminating code duplication.
|
|
316
475
|
|
|
476
|
+
A model must activate the refinements with `using Refinements`:
|
|
477
|
+
```ruby
|
|
478
|
+
class IOS < Oxidized::Model
|
|
479
|
+
using Refinements
|
|
480
|
+
# ...
|
|
481
|
+
end
|
|
482
|
+
```
|
|
483
|
+
|
|
317
484
|
#### `cut_tail`
|
|
318
485
|
|
|
319
486
|
Returns a multi-line string without the last line, or an empty string if only a
|
|
320
|
-
single line was present.
|
|
487
|
+
single line was present. Takes an optional number of lines to remove (default: 1).
|
|
488
|
+
|
|
489
|
+
Example from [axos.rb](/lib/oxidized/model/axos.rb), removing the prompt:
|
|
490
|
+
```ruby
|
|
491
|
+
cmd :all do |cfg|
|
|
492
|
+
cfg.cut_tail
|
|
493
|
+
end
|
|
494
|
+
```
|
|
321
495
|
|
|
322
496
|
#### `cut_head`
|
|
323
497
|
|
|
324
498
|
Returns a multi-line string without the first line, or an empty string if only a
|
|
325
|
-
single line was present.
|
|
499
|
+
single line was present. Takes an optional number of lines to remove (default: 1).
|
|
500
|
+
|
|
501
|
+
```ruby
|
|
502
|
+
# Remove the command echo and the "Building configuration..." lines
|
|
503
|
+
cfg = cfg.cut_head(3)
|
|
504
|
+
```
|
|
326
505
|
|
|
327
506
|
#### `cut_both`
|
|
328
507
|
|
|
329
508
|
Returns a multi-line string without the first and last lines, or an empty string
|
|
330
|
-
if fewer than three lines were present.
|
|
509
|
+
if fewer than three lines were present. Takes optional numbers of lines to remove
|
|
510
|
+
at the head and the tail (default: 1 and 1).
|
|
511
|
+
|
|
512
|
+
This is typically used to remove the command echo (first line) and the prompt
|
|
513
|
+
(last line), which are not needed in the stored configuration:
|
|
514
|
+
```ruby
|
|
515
|
+
cmd :all do |cfg|
|
|
516
|
+
cfg.cut_both
|
|
517
|
+
end
|
|
518
|
+
```
|
|
331
519
|
|
|
332
520
|
#### `keep_lines`
|
|
333
521
|
Returns a multi-line string with only the lines matching any pattern (String or Regexp) given in an array.
|
|
334
522
|
|
|
523
|
+
```ruby
|
|
524
|
+
cmd 'show interfaces transceiver' do |cfg|
|
|
525
|
+
cfg = cfg.keep_lines [
|
|
526
|
+
'SFP Information',
|
|
527
|
+
/Vendor (Name|Serial Number)/
|
|
528
|
+
]
|
|
529
|
+
comment cfg
|
|
530
|
+
end
|
|
531
|
+
```
|
|
532
|
+
|
|
335
533
|
#### `reject_lines`
|
|
336
|
-
Returns a multi-line string without the lines matching any pattern (String or Regexp) given in an array.
|
|
534
|
+
Returns a multi-line string without the lines matching any pattern (String or Regexp) given in an array.
|
|
535
|
+
|
|
536
|
+
Example from [arubainstant.rb](/lib/oxidized/model/arubainstant.rb), removing
|
|
537
|
+
lines that change on every run:
|
|
538
|
+
```ruby
|
|
539
|
+
cmd 'show version' do |cfg|
|
|
540
|
+
cfg = cfg.reject_lines [
|
|
541
|
+
/^(Switch|AP) uptime is /,
|
|
542
|
+
/^Reboot Time and Cause/
|
|
543
|
+
]
|
|
544
|
+
comment cfg
|
|
545
|
+
end
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
#### `rstrip_lines`
|
|
549
|
+
Returns a multi-line string with trailing whitespace (including `\r`) removed
|
|
550
|
+
from each line. The result always ends with a single newline.
|
|
551
|
+
|
|
552
|
+
Example from [procurve.rb](/lib/oxidized/model/procurve.rb), removing the
|
|
553
|
+
trailing spaces that `comment` adds to empty lines (`"! "`):
|
|
554
|
+
```ruby
|
|
555
|
+
def clean_comment(lines)
|
|
556
|
+
comment(lines).rstrip_lines
|
|
557
|
+
end
|
|
558
|
+
```
|
data/docs/Supported-OS-Types.md
CHANGED
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
| |CatOS |[catos](/lib/oxidized/model/catos.rb)
|
|
55
55
|
| |Cisco Catalyst Express |[ciscoce](/lib/oxidized/model/ciscoce.rb)
|
|
56
56
|
| |ExaLink Fusion (Nexus 3550-F) |[exalink](/lib/oxidized/model/exalink.rb) |@obol89 |[ExaLink](Model-Notes/ExaLink.md)
|
|
57
|
-
| |
|
|
57
|
+
| |FTD via HTTP |[ftd](/lib/oxidized/model/ftd.rb) | |[FTD](Model-Notes/FTD.md)
|
|
58
|
+
| |FTD via SSH |[firelinuxos](/lib/oxidized/model/firelinuxos.rb)
|
|
58
59
|
| |IOS |[ios](/lib/oxidized/model/ios.rb) |@robertcheramy |[IOS](Model-Notes/IOS.md)
|
|
59
60
|
| |IOSXR |[iosxr](/lib/oxidized/model/iosxr.rb)
|
|
60
61
|
| |NGA |[cisconga](/lib/oxidized/model/cisconga.rb)
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
| |Enterasys 800-Series |[enterasys800](/lib/oxidized/model/enterasys800.rb)
|
|
91
92
|
| |WM |[mtrlrfs](/lib/oxidized/model/mtrlrfs.rb)
|
|
92
93
|
| |XOS, ExtremeWare |[xos](/lib/oxidized/model/xos.rb)
|
|
93
|
-
|F5 |F5OS |[
|
|
94
|
+
|F5 |F5OS |[f5os](/lib/oxidized/model/f5os.rb)
|
|
94
95
|
| |TMOS |[tmos](/lib/oxidized/model/tmos.rb)
|
|
95
96
|
|Fiberstore (fs.com) |S3400 |[fsos](/lib/oxidized/model/fsos.rb) | |[FSOS](Model-Notes/FSOS.md)
|
|
96
97
|
| |S3800 |[gcombnps](/lib/oxidized/model/gcombnps.rb)
|
|
@@ -108,18 +109,19 @@
|
|
|
108
109
|
|[Garderos](https://garderos.com/) |GRS (Garderos Router Software) |[garderos](/lib/oxidized/model/garderos.rb) | @robertcheramy |Routers for harsh environments
|
|
109
110
|
|GCOM Technologies |Broadband Network Platform Software|[gcombnps](/lib/oxidized/model/gcombnps.rb)
|
|
110
111
|
|Grandstream Networks|GSX |[grandstream](/lib/oxidized/model/grandstream.rb)
|
|
111
|
-
| |HT8xx |[
|
|
112
|
+
| |HT8xx |[grandstreamht8xx](/lib/oxidized/model/grandstreamht8xx.rb) | @mklopocki | [Grandstream](Model-Notes/GrandstreamHT8xx.md)
|
|
112
113
|
|Hatteras |Hatteras |[hatteras](/lib/oxidized/model/hatteras.rb)
|
|
113
114
|
|Hillstone Networks |StoneOS |[stoneos](/lib/oxidized/model/stoneos.rb)
|
|
114
115
|
|Hirschmann |Classic |[hirschmann](/lib/oxidized/model/hirschmann.rb)
|
|
115
116
|
| |HiOS |[hios](/lib/oxidized/model/hios.rb)
|
|
116
117
|
|HP |Comware (HP A-series, H3C, 3Com)|[comware](/lib/oxidized/model/comware.rb) |@robertcheramy |[Comware](Model-Notes/Comware.md)
|
|
117
|
-
| |Procurve |[procurve](/lib/oxidized/model/procurve.rb) |@robertcheramy
|
|
118
|
+
| |Procurve |[procurve](/lib/oxidized/model/procurve.rb) |@robertcheramy, @thanegill
|
|
118
119
|
| |BladeSystem (Onboard Administrator)|[hpebladesystem](/lib/oxidized/model/hpebladesystem.rb)
|
|
119
120
|
| |MSA |[hpemsa](/lib/oxidized/model/hpemsa.rb)
|
|
120
121
|
| |MSM (Wireless Controller) |[hpmsm](/lib/oxidized/model/hpmsm.rb)
|
|
121
122
|
|H3C |S6520X |[h3c](/lib/oxidized/model/h3c.rb)
|
|
122
123
|
|Huawei |VRP |[vrp](/lib/oxidized/model/vrp.rb) | |[VRP-Huawei](Model-Notes/VRP-Huawei.md)
|
|
124
|
+
| |YunShan OS |[vrp](/lib/oxidized/model/vrp.rb) | |[VRP-Huawei](Model-Notes/VRP-Huawei.md)
|
|
123
125
|
| |SmartAX series |[smartax](/lib/oxidized/model/smartax.rb) | |[SmartAX-Huawei](Model-Notes/SmartAX-Huawei.md)
|
|
124
126
|
|Icotera |6400 series |[icotera](/lib/oxidized/model/icotera.rb)
|
|
125
127
|
|Ingate |SIParator/Firewalls |[ingate](/lib/oxidized/model/ingate.rb) |@thanegill
|
|
@@ -128,6 +130,7 @@
|
|
|
128
130
|
|Juniper |JunOS |[junos](/lib/oxidized/model/junos.rb) | |[MX/QFX/EX/SRX/J Series](Model-Notes/JunOS.md)
|
|
129
131
|
| |ScreenOS (Netscreen) |[screenos](/lib/oxidized/model/screenos.rb)
|
|
130
132
|
|LANCOM Systems GmbH |LCOS |[lancom](/lib/oxidized/model/lancom.rb)
|
|
133
|
+
|[Lantronix](https://www.lantronix.com)|IT Management Gateway OS (SLC 8000, SLC 9000, EMG, SLB)|[itmgos](/lib/oxidized/model/itmgos.rb)| |[ITMGOS](Model-Notes/ITMGOS.md)
|
|
131
134
|
|Lenovo |Lenovo Network OS |[lenovonos](/lib/oxidized/model/lenovonos.rb) | |[Lenovo Network OS](Model-Notes/LenovoNOS.md)
|
|
132
135
|
|Linkys |SRW |[linksyssrw](/lib/oxidized/model/linksyssrw.rb) | |[LinksysSRW](Model-Notes/LinksysSRW.md)
|
|
133
136
|
|Linuxgeneric |CentOS |[linuxgeneric](/lib/oxidized/model/linuxgeneric.rb)| |[LinuxGeneric](Model-Notes/LinuxGeneric.md)
|
|
@@ -180,6 +183,7 @@
|
|
|
180
183
|
|Trango Systems |Trango |[trango](/lib/oxidized/model/trango.rb)
|
|
181
184
|
|TrueNAS |TrueNAS |[truenas](/lib/oxidized/model/truenas.rb)
|
|
182
185
|
|TPLink |TPLink |[tplink](/lib/oxidized/model/tplink.rb)
|
|
186
|
+
| |DeltaStream GPON OLT |[tplink](/lib/oxidized/model/tplink.rb) |@Vantomas |[TPLink](Model-Notes/TPLink.md)|
|
|
183
187
|
| |TL-SL5428 |[edgecos](/lib/oxidized/model/edgecos.rb)
|
|
184
188
|
| |TL-SL3428 |[powerconnect](/lib/oxidized/model/powerconnect.rb)
|
|
185
189
|
|Ubiquiti |AirOS |[airos](/lib/oxidized/model/airos.rb)
|
|
@@ -187,10 +191,11 @@
|
|
|
187
191
|
| |EdgeSwitch |[edgeswitch](/lib/oxidized/model/edgeswitch.rb)
|
|
188
192
|
| |AirFiber |[airfiber](/lib/oxidized/model/airfiber.rb)
|
|
189
193
|
| |UnifiAP |[unifiap](/lib/oxidized/model/unifiap.rb) |@clifcox |Also suports AirOS, and some Unifi switches
|
|
190
|
-
|Uplink |EP4440-DP |[
|
|
194
|
+
|Uplink |EP4440-DP |[uplinkolt](/lib/oxidized/model/uplinkolt.rb) | |Might support all EP4440 series
|
|
191
195
|
|VMWare |NSX Edge (configuration) |[nsxconfig](/lib/oxidized/model/nsxconfig.rb)
|
|
192
196
|
| |NSX Edge (firewall rules) |[nsxfirewall](/lib/oxidized/model/nsxfirewall.rb)
|
|
193
197
|
| |NSX Distributed Firewall |[nsxdfw](/lib/oxidized/model/nsxdfw.rb)
|
|
198
|
+
|VSOL |GPON OLT |[vsololt](/lib/oxidized/model/vsololt.rb) |@Vantomas |
|
|
194
199
|
|VYOS Networks |VYOS |[vyos](/lib/oxidized/model/vyos.rb) | |Fork of Vyatta, tracking the supported versions (>= 1.4.x)
|
|
195
200
|
|Watchguard |Fireware OS |[firewareos](/lib/oxidized/model/firewareos.rb)
|
|
196
201
|
|Waystream (PacketFront)|iBOS (Intelligent Broadband OS)|[ibos](/lib/oxidized/model/ibos.rb)
|
data/docs/Troubleshooting.md
CHANGED
|
@@ -97,12 +97,11 @@ In some situations, you may need to make changes to the git repository of
|
|
|
97
97
|
oxidized. Stop oxidized, make backups, and be sure you know exactly what you
|
|
98
98
|
are doing. You have been warned.
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
is not supported in [Rugged](https://github.com/libgit2/rugged)).
|
|
100
|
+
Oxidized 0.37.0 and older cached the HEAD tree in the git index and
|
|
101
|
+
ignored changes pushed to the repository. If you use such a version, update
|
|
102
|
+
the index manually after pushing: go into the oxidized repo and run
|
|
103
|
+
`git ls-tree -r HEAD | git update-index --index-info`.
|
|
104
|
+
|
|
105
|
+
Consider running `git gc` from time to time, as oxidized cannot garbage
|
|
106
|
+
collect the repo (this is not supported in
|
|
107
|
+
[Rugged](https://github.com/libgit2/rugged)).
|
data/extra/device2yaml.rb
CHANGED
|
@@ -129,7 +129,7 @@ optparse = OptionParser.new do |opts|
|
|
|
129
129
|
command2
|
|
130
130
|
command3" [options]
|
|
131
131
|
|
|
132
|
-
-i and -c are
|
|
132
|
+
-i and -c are mutually exclusive, one must be specified
|
|
133
133
|
|
|
134
134
|
[options]:
|
|
135
135
|
HEREDOC
|
|
@@ -143,10 +143,19 @@ optparse = OptionParser.new do |opts|
|
|
|
143
143
|
opts.on('-o', '--output file', 'Specify an output YAML-file') do |file|
|
|
144
144
|
options[:output] = file
|
|
145
145
|
end
|
|
146
|
+
opts.on('-p', '--port port', Integer, 'Specify SSH port (default: 22)') do |port|
|
|
147
|
+
options[:port] = port
|
|
148
|
+
end
|
|
146
149
|
opts.on('-t', '--timeout value', Integer,
|
|
147
|
-
'Specify the idle timeout
|
|
150
|
+
'Specify the idle timeout between commands (default: 5 seconds)') do |timeout|
|
|
148
151
|
options[:timeout] = timeout
|
|
149
152
|
end
|
|
153
|
+
opts.on('-n', '--newline value',
|
|
154
|
+
'Line terminator appended to each command (default: \n). ' \
|
|
155
|
+
'Accepts the escapes \n and \r, e.g. -n "\r\n" for ' \
|
|
156
|
+
'devices that submit a command only on a carriage return.') do |newline|
|
|
157
|
+
options[:newline] = newline.gsub('\n', "\n").gsub('\r', "\r")
|
|
158
|
+
end
|
|
150
159
|
opts.on('-e', '--exec-mode', 'Run ssh in exec mode (without tty)') { @exec_mode = true }
|
|
151
160
|
opts.on('-u', '--unordered', 'The YAML simulation should not enforce an order of the commands') do
|
|
152
161
|
@sequence_prepend_command = ''
|
|
@@ -194,8 +203,10 @@ elsif options[:input]
|
|
|
194
203
|
end
|
|
195
204
|
|
|
196
205
|
puts "Running #{ssh_commands} on #{ssh_user}@#{ssh_host}"
|
|
197
|
-
#
|
|
198
|
-
|
|
206
|
+
# Append the line terminator to each command (default "\n", overridable with -n
|
|
207
|
+
# for devices that submit a command only on a carriage return)
|
|
208
|
+
command_newline = options[:newline] || "\n"
|
|
209
|
+
ssh_commands.map! { |s| s + command_newline }
|
|
199
210
|
|
|
200
211
|
# Defaut idle timeout: 5 seconds, as tests showed that 2 seconds is too short
|
|
201
212
|
@idle_timeout = options[:timeout] || 5
|
|
@@ -206,7 +217,8 @@ ssh_commands.map! { |s| s + "\n" }
|
|
|
206
217
|
|
|
207
218
|
@ssh = Net::SSH.start(ssh_host,
|
|
208
219
|
ssh_user,
|
|
209
|
-
{
|
|
220
|
+
{ port: options[:port] || 22,
|
|
221
|
+
timeout: 10,
|
|
210
222
|
append_all_supported_algorithms: true })
|
|
211
223
|
|
|
212
224
|
@ssh_output = ''
|
|
@@ -235,6 +247,10 @@ end
|
|
|
235
247
|
|
|
236
248
|
# YAML begin of file
|
|
237
249
|
@output&.puts '---'
|
|
250
|
+
# Record the line terminator appended to each command, so it is clear how the
|
|
251
|
+
# simulation was captured (some CLIs submit a command only on "\r"). Consumers
|
|
252
|
+
# that don't need it (e.g. the model unit tests) simply ignore this key.
|
|
253
|
+
@output&.puts "command_newline: #{command_newline.dump}"
|
|
238
254
|
|
|
239
255
|
if @exec_mode
|
|
240
256
|
# init prompt does not exist and is empty in exec mode
|
|
@@ -157,9 +157,8 @@ class Modelrulesadvanced < Oxidized::Hook
|
|
|
157
157
|
node[:model] = matched_model
|
|
158
158
|
logger.debug "ModelRulesAdvanced: changed model from #{old_model.inspect} to #{matched_model.inspect}"
|
|
159
159
|
else
|
|
160
|
-
|
|
161
|
-
logger.debug "ModelRulesAdvanced: no rule matched, keeping existing model: #{
|
|
162
|
-
# rubocop:enable Layout/LineLength
|
|
160
|
+
model = node[:model] || node["model"]
|
|
161
|
+
logger.debug "ModelRulesAdvanced: no rule matched, keeping existing model: #{model.inspect}"
|
|
163
162
|
end
|
|
164
163
|
|
|
165
164
|
node
|
data/extra/oxidized.service
CHANGED
data/extra/syslog.rb
CHANGED
|
@@ -99,7 +99,7 @@ module Oxidized
|
|
|
99
99
|
def junos(log, index, **opts)
|
|
100
100
|
# TODO: we need to fetch 'ip/name' in mode == :file here
|
|
101
101
|
opts[:user] = log[index + 2][1..-2]
|
|
102
|
-
opts[:msg] = log[(index + 6)
|
|
102
|
+
opts[:msg] = log[(index + 6)..].join(' ')[10..-2]
|
|
103
103
|
opts.delete(:msg) if opts[:msg] == 'none'
|
|
104
104
|
opts
|
|
105
105
|
end
|
data/lib/oxidized/cli/support.rb
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
require 'time'
|
|
2
|
+
require_relative '../redact'
|
|
2
3
|
|
|
3
4
|
module Oxidized
|
|
4
5
|
class CLI
|
|
5
6
|
module Support
|
|
6
|
-
SENSITIVE_NAME_RE = /(password|passphrase|secret|token|enable|
|
|
7
|
-
(private|api|access)_?key|
|
|
8
|
-
community|credential|auth
|
|
9
|
-
)/ix
|
|
10
7
|
ROOT_GEMS = %w[oxidized oxidized-web].freeze
|
|
11
8
|
EXPLICIT_ENV_KEYS = %w[
|
|
12
9
|
OXIDIZED_HOME
|
|
@@ -53,7 +50,7 @@ module Oxidized
|
|
|
53
50
|
next unless ENV.has_key?(key)
|
|
54
51
|
|
|
55
52
|
value = ENV.fetch(key)
|
|
56
|
-
puts
|
|
53
|
+
puts "#{key}=#{Redact.value(key, value)}"
|
|
57
54
|
end
|
|
58
55
|
|
|
59
56
|
puts
|
|
@@ -126,8 +123,8 @@ module Oxidized
|
|
|
126
123
|
next
|
|
127
124
|
end
|
|
128
125
|
|
|
129
|
-
if
|
|
130
|
-
puts "#{key}:
|
|
126
|
+
if Redact.sensitive?(key)
|
|
127
|
+
puts "#{key}: #{Redact::REDACTED}"
|
|
131
128
|
else
|
|
132
129
|
puts line
|
|
133
130
|
end
|
data/lib/oxidized/config/vars.rb
CHANGED
|
@@ -25,7 +25,8 @@ module Oxidized
|
|
|
25
25
|
if val.nil?
|
|
26
26
|
Oxidized.logger.debug "vars.rb: scope #{scope_name} has key #{name} with value nil, ignoring scope"
|
|
27
27
|
else
|
|
28
|
-
Oxidized.logger.debug "vars.rb: scope #{scope_name} has key #{name}
|
|
28
|
+
Oxidized.logger.debug "vars.rb: scope #{scope_name} has key #{name} " \
|
|
29
|
+
"with value #{Redact.value(name, val)}, using scope"
|
|
29
30
|
return val
|
|
30
31
|
end
|
|
31
32
|
end
|
data/lib/oxidized/core.rb
CHANGED
|
@@ -10,6 +10,8 @@ module Oxidized
|
|
|
10
10
|
|
|
11
11
|
class NoNodesFound < OxidizedError; end
|
|
12
12
|
|
|
13
|
+
MIN_WEB_VERSION = '0.17.0'.freeze
|
|
14
|
+
|
|
13
15
|
def initialize(_args)
|
|
14
16
|
Oxidized.mgr = Manager.new
|
|
15
17
|
Oxidized.hooks = HookManager.from_config(Oxidized.config)
|
|
@@ -56,6 +58,7 @@ module Oxidized
|
|
|
56
58
|
'configuration'
|
|
57
59
|
end
|
|
58
60
|
@rest = API::Web.new nodes, configuration
|
|
61
|
+
check_web_version
|
|
59
62
|
@rest.run
|
|
60
63
|
end
|
|
61
64
|
run
|
|
@@ -63,6 +66,23 @@ module Oxidized
|
|
|
63
66
|
|
|
64
67
|
private
|
|
65
68
|
|
|
69
|
+
# WEB_VERSION is defined by oxidized/web/webapp, loaded by API::Web.new.
|
|
70
|
+
# Extracted from check_web_version so that core_spec can stub it in tests.
|
|
71
|
+
def web_version
|
|
72
|
+
API::WEB_VERSION if API.const_defined?(:WEB_VERSION)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def check_web_version
|
|
76
|
+
version = web_version
|
|
77
|
+
return if version.nil? || Gem::Version.new(version) >= Gem::Version.new(MIN_WEB_VERSION)
|
|
78
|
+
|
|
79
|
+
logger.warn(
|
|
80
|
+
"oxidized-web #{version} is older than #{MIN_WEB_VERSION}: " \
|
|
81
|
+
'the display of node versions and diffs fails, and puma may ' \
|
|
82
|
+
'override the signal handlers. Please update oxidized-web'
|
|
83
|
+
)
|
|
84
|
+
end
|
|
85
|
+
|
|
66
86
|
def reload
|
|
67
87
|
logger.info("Reloading node list")
|
|
68
88
|
@worker.reload
|
|
@@ -28,7 +28,7 @@ class CiscoSparkDiff < Oxidized::Hook
|
|
|
28
28
|
title = ctx.node.name.to_s
|
|
29
29
|
logger.info "Posting diff as snippet to #{cfg.space}"
|
|
30
30
|
room.send_message CiscoSpark::Message.new(text: "Device #{title} modified:\n" +
|
|
31
|
-
diff[:patch].lines.to_a[4
|
|
31
|
+
diff[:patch].lines.to_a[4..].join)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
if cfg.message?
|
|
@@ -65,7 +65,7 @@ class SlackDiff < Oxidized::Hook
|
|
|
65
65
|
diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil
|
|
66
66
|
unless diff == "no diffs"
|
|
67
67
|
title = "#{ctx.node.name} #{ctx.node.group} #{ctx.node.model.class.name.to_s.downcase}"
|
|
68
|
-
content = diff[:patch].lines.to_a[4
|
|
68
|
+
content = diff[:patch].lines.to_a[4..].join
|
|
69
69
|
slack_upload(client, title, content, cfg.channel, cfg.has_key?('proxy') ? cfg.proxy : nil)
|
|
70
70
|
end
|
|
71
71
|
end
|
|
@@ -56,7 +56,7 @@ class XMPPDiff < Oxidized::Hook
|
|
|
56
56
|
gitoutput = ctx.node.output.new
|
|
57
57
|
diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil
|
|
58
58
|
|
|
59
|
-
interesting = diff[:patch].lines.to_a[4
|
|
59
|
+
interesting = diff[:patch].lines.to_a[4..].any? do |line|
|
|
60
60
|
["+", "-"].include?(line[0]) && (not ["#", "!"].include?(line[1]))
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -68,7 +68,7 @@ class XMPPDiff < Oxidized::Hook
|
|
|
68
68
|
title = "#{ctx.node.name} #{ctx.node.group} #{ctx.node.model.class.name.to_s.downcase}"
|
|
69
69
|
logger.info "Posting diff as snippet to #{cfg.channel}"
|
|
70
70
|
|
|
71
|
-
@muc.say(title + "\n\n" + diff[:patch].lines.to_a[4
|
|
71
|
+
@muc.say(title + "\n\n" + diff[:patch].lines.to_a[4..].join)
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
end
|