oxidized 0.36.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.yml +3 -0
- data/.rubocop_todo.yml +2 -8
- data/AGENTS.md +174 -0
- data/CHANGELOG.md +127 -0
- data/CONTRIBUTING.md +78 -44
- data/Dockerfile +8 -4
- data/README.md +8 -1
- data/Rakefile +1 -1
- data/docs/Configuration.md +10 -1
- data/docs/Creating-Models.md +6 -6
- data/docs/DeviceSimulation.md +80 -51
- data/docs/Docker.md +49 -0
- data/docs/Hooks.md +92 -67
- data/docs/Inputs.md +95 -16
- data/docs/Issues.md +49 -13
- data/docs/Model-Notes/FTD.md +64 -0
- data/docs/Model-Notes/GrandstreamHT8xx.md +8 -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/RouterOS.md +13 -0
- data/docs/Model-Notes/TPLink.md +75 -0
- data/docs/Model-Notes/TrueNAS.md +11 -7
- data/docs/Outputs.md +1 -0
- data/docs/Release.md +49 -22
- data/docs/Ruby-API.md +231 -9
- data/docs/Supported-OS-Types.md +10 -4
- data/docs/Troubleshooting.md +8 -9
- data/extra/device2yaml.rb +21 -5
- data/extra/hooks/modelrulesadvanced.rb +2 -4
- data/extra/oxidized.service +0 -1
- data/extra/syslog.rb +1 -1
- data/lib/oxidized/cli/support.rb +149 -0
- data/lib/oxidized/cli.rb +9 -0
- 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/hook.rb +2 -0
- data/lib/oxidized/input/cli.rb +14 -2
- data/lib/oxidized/input/debugtext.rb +40 -0
- data/lib/oxidized/input/debugyaml.rb +82 -0
- data/lib/oxidized/input/exec.rb +1 -6
- data/lib/oxidized/input/ftp.rb +0 -4
- data/lib/oxidized/input/http.rb +23 -15
- data/lib/oxidized/input/scp.rb +3 -1
- data/lib/oxidized/input/ssh.rb +28 -21
- data/lib/oxidized/input/sshbase.rb +50 -24
- data/lib/oxidized/input/telnet.rb +14 -11
- data/lib/oxidized/input/tftp.rb +0 -4
- 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 +20 -12
- 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/cumulus.rb +3 -3
- data/lib/oxidized/model/dellx.rb +1 -1
- data/lib/oxidized/model/dlink.rb +1 -1
- data/lib/oxidized/model/dlinknextgen.rb +2 -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 +16 -3
- 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/grandstreamht8xx.rb +19 -0
- 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/ios.rb +2 -0
- 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 +10 -4
- data/lib/oxidized/model/kornfeldos.rb +2 -4
- data/lib/oxidized/model/lancom.rb +2 -2
- data/lib/oxidized/model/linuxgeneric.rb +4 -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 +13 -1
- 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 +6 -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 +8 -10
- data/lib/oxidized/model/truenas.rb +56 -5
- 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 +6 -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 +74 -29
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# TP-Link Configuration
|
|
2
|
+
|
|
3
|
+
The `tplink` model is used for TP-Link JetStream managed switches and the
|
|
4
|
+
DeltaStream GPON OLT. The notes below apply to all of them.
|
|
5
|
+
|
|
6
|
+
## SSH authentication: avoid public-key authentication
|
|
7
|
+
|
|
8
|
+
Some TP-Link devices (the DeltaStream GPON OLT for example) **abort the SSH
|
|
9
|
+
connection if the client attempts public-key authentication before the
|
|
10
|
+
password**. By default net-ssh offers any key from the SSH agent or the default
|
|
11
|
+
identity files first, so when the Oxidized host has SSH keys the device closes the
|
|
12
|
+
connection before the password is ever tried:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
connection closed by remote host (Net::SSH::Disconnect)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
This is why the same device may connect fine from one host (no SSH keys) and fail
|
|
19
|
+
from another (keys present). Tell Oxidized to skip `publickey` with the
|
|
20
|
+
`auth_methods` variable (see [SSH Auth Methods](../Inputs.md#ssh-auth-methods)).
|
|
21
|
+
It can be set globally, by group, by model or by node, e.g. for every `tplink`
|
|
22
|
+
device:
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
models:
|
|
26
|
+
tplink:
|
|
27
|
+
vars:
|
|
28
|
+
auth_methods: ["none", "password"]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Capturing a simulation with device2yaml.rb
|
|
32
|
+
|
|
33
|
+
`extra/device2yaml.rb` has no `auth_methods` option, but net-ssh reads
|
|
34
|
+
`~/.ssh/config`, so add a host block for the device to force password
|
|
35
|
+
authentication:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
Host <device-ip>
|
|
39
|
+
PreferredAuthentications password
|
|
40
|
+
PubkeyAuthentication no
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This CLI also submits a command only on a carriage return, so run device2yaml with
|
|
44
|
+
`-n '\r\n'`; otherwise the commands are echoed but never executed.
|
|
45
|
+
|
|
46
|
+
## Enable mode
|
|
47
|
+
|
|
48
|
+
Devices such as the DeltaStream GPON OLT only expose their configuration in
|
|
49
|
+
privileged (enable) mode. The model enters enable mode through the standard
|
|
50
|
+
`enable` variable:
|
|
51
|
+
|
|
52
|
+
- `enable: true` — switch to enable with **no** password (TP-Link devices enable
|
|
53
|
+
without a password by default).
|
|
54
|
+
- `enable: <password>` — switch to enable and send `<password>` when prompted.
|
|
55
|
+
|
|
56
|
+
Set it globally, per model or per node, e.g. in the configuration:
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
models:
|
|
60
|
+
tplink:
|
|
61
|
+
vars:
|
|
62
|
+
enable: true
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
or as the 6th column of a CSV `router.db` line (the CSV source maps the string
|
|
66
|
+
`true` to the boolean `true`):
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
tplink-olt:tplink:10.0.0.1:admin:secret:true
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Without the `enable` variable the model stays in user mode (`>`) and privileged
|
|
73
|
+
commands return `Error: Bad command`.
|
|
74
|
+
|
|
75
|
+
Back to [Model-Notes](README.md)
|
data/docs/Model-Notes/TrueNAS.md
CHANGED
|
@@ -6,14 +6,18 @@ TrueNAS SCALE (Linux-based) devices.
|
|
|
6
6
|
## Authentication
|
|
7
7
|
|
|
8
8
|
Ensure that the user configured for oxidized to login to your device has the
|
|
9
|
-
permissions to read the configuration database. On older
|
|
10
|
-
just work.
|
|
9
|
+
permissions to read the configuration database. On older CORE instances, this
|
|
10
|
+
would just work without sudo. On newer devices, the `/data/freenas-v1.db` file
|
|
11
|
+
can only be read by the root user.
|
|
11
12
|
|
|
12
|
-
On
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
On SCALE devices with Apps support, it's also necessary to add some privileges
|
|
14
|
+
to read the container configurations for any apps you have installed, which can
|
|
15
|
+
be found under `/mnt/.ix-apps`.
|
|
16
|
+
|
|
17
|
+
You can make sure that the user that oxidized uses to login (`oxidized` in this
|
|
18
|
+
example) can dump the configuration using `sudo` by adding something like this
|
|
19
|
+
to your `/etc/sudoers` file:
|
|
16
20
|
|
|
17
21
|
```
|
|
18
|
-
oxidized ALL=(ALL) NOPASSWD: /usr/bin/sqlite3 file
|
|
22
|
+
oxidized ALL=(ALL) NOPASSWD: /usr/bin/find /mnt/.ix-apps/app_configs *, /usr/bin/sqlite3 -readonly file\:/data/freenas-v1.db *
|
|
19
23
|
```
|
data/docs/Outputs.md
CHANGED
data/docs/Release.md
CHANGED
|
@@ -7,38 +7,59 @@ Oxidized versions are numbered like major.minor.patch
|
|
|
7
7
|
- minor is incremented when releasing new features.
|
|
8
8
|
- patch is incremented when releasing fixes only.
|
|
9
9
|
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
## Overview
|
|
11
|
+
The release is done in two steps, each with its own branch:
|
|
12
|
+
1. A review branch, where all the fixes are made. Once it is merged into
|
|
13
|
+
master, GitHub automatically builds a container image, which is used for
|
|
14
|
+
testing.
|
|
15
|
+
2. A release branch, which only bumps the version and finalizes the
|
|
16
|
+
CHANGELOG.
|
|
17
|
+
|
|
18
|
+
## Step 1: Review branch
|
|
19
|
+
### Create a review branch
|
|
20
|
+
Name the review branch `review-for-0.xx.yy`
|
|
21
|
+
|
|
22
|
+
### Review changes
|
|
14
23
|
Run `git diff 0.30.0` (where `0.30.0` is to be changed to the last release) and review
|
|
15
24
|
all the changes that have been done. Have a specific look at changes you don't understand.
|
|
16
25
|
|
|
17
26
|
For a graphical compare, use `git difftool -d 0.30.0`.
|
|
18
27
|
|
|
19
|
-
Commit fixes to the
|
|
28
|
+
Commit fixes to the review branch
|
|
20
29
|
|
|
21
|
-
|
|
30
|
+
### Update the gem dependencies to the latest versions
|
|
22
31
|
```
|
|
23
32
|
bundle outdated
|
|
24
33
|
bundle update
|
|
25
34
|
bundle outdated
|
|
26
35
|
```
|
|
27
36
|
|
|
28
|
-
|
|
37
|
+
### Update rubocup .rubocop_todo.yml
|
|
29
38
|
Run `bundle exec rubocop --auto-gen-config`,
|
|
30
39
|
and make sure `bundle exec rake` passes after it.
|
|
31
40
|
|
|
32
|
-
If you change some code => Restart the release process at the beginning ;-)
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
Run `bundle exec rake chmod`
|
|
42
|
+
### Make sure the file permissions are correct
|
|
43
|
+
Run `bundle exec rake chmod`, then `git status`
|
|
44
|
+
|
|
45
|
+
### Merge the review branch
|
|
46
|
+
Upload the branch to github, make a Pull Request for it and make sure it passes
|
|
47
|
+
all GitHub CI. Merge it into master.
|
|
48
|
+
|
|
49
|
+
GitHub automatically builds the container image from master.
|
|
36
50
|
|
|
37
|
-
##
|
|
38
|
-
Test the git code and the container
|
|
39
|
-
environments as you can.
|
|
51
|
+
## Step 2: Tests
|
|
52
|
+
Test the git code (master) and the container image built from master against
|
|
53
|
+
as much device types and environments as you can.
|
|
54
|
+
|
|
55
|
+
If you need to fix something, do it in a new review branch (go back to
|
|
56
|
+
Step 1).
|
|
57
|
+
|
|
58
|
+
## Step 3: Release branch
|
|
59
|
+
### Create a release branch
|
|
60
|
+
Name the release branch `release/0.xx.yy`
|
|
40
61
|
|
|
41
|
-
|
|
62
|
+
### Bump the version
|
|
42
63
|
Update CHANGELOG.md:
|
|
43
64
|
- review it
|
|
44
65
|
- add release notes
|
|
@@ -48,10 +69,10 @@ Change the version in `lib/oxidized/version.rb`
|
|
|
48
69
|
|
|
49
70
|
Upload the branch to github, make a Pull Request for it.
|
|
50
71
|
|
|
51
|
-
|
|
72
|
+
### Make sure you pass all GitHub CI
|
|
52
73
|
They test different ruby versions an run security checks on the code (codeql).
|
|
53
74
|
|
|
54
|
-
|
|
75
|
+
### Prepare the release in your working repository
|
|
55
76
|
1. Merge the Pull Request into master with the commit message
|
|
56
77
|
`chore(release): release version 0.3x.y`
|
|
57
78
|
2. `git pull` on master
|
|
@@ -64,26 +85,32 @@ gem install --user-install pkg/oxidized-0.xx.yy.gem
|
|
|
64
85
|
~/.local/share/gem/ruby/3.3.0/bin/oxidized
|
|
65
86
|
```
|
|
66
87
|
|
|
67
|
-
##
|
|
88
|
+
## Step 4: Publish the release
|
|
89
|
+
### Release in github
|
|
68
90
|
Push the tag to github:
|
|
69
91
|
```
|
|
70
92
|
git push origin 0.xx.yy
|
|
71
93
|
```
|
|
72
94
|
|
|
73
95
|
Make a release from the tag in github.
|
|
74
|
-
-
|
|
96
|
+
- Name the release `0.xx.yy`
|
|
97
|
+
- Generate release notes
|
|
98
|
+
- Remove `## What's changed`
|
|
99
|
+
- Take the release notes from CHANGELOG.md
|
|
75
100
|
- List new contributors (generated automatically)
|
|
76
101
|
- Keep the Full Changelog (generated automatically)
|
|
102
|
+
- Preview
|
|
103
|
+
- Publish
|
|
77
104
|
|
|
78
105
|
Close the corresponding milestone in github.
|
|
79
106
|
|
|
80
|
-
|
|
81
|
-
Push the gem with
|
|
107
|
+
### Release in rubygems
|
|
108
|
+
Push the gem with `rake push`
|
|
82
109
|
|
|
83
|
-
|
|
110
|
+
### Release in docker.io
|
|
84
111
|
The OCI-Containter is automatically build and pushed to docker.io by github
|
|
85
112
|
|
|
86
|
-
|
|
113
|
+
### Update CHANGELOG.md for next release
|
|
87
114
|
Add
|
|
88
115
|
```
|
|
89
116
|
## [Unreleased]
|
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,17 +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)
|
|
112
|
+
| |HT8xx |[grandstreamht8xx](/lib/oxidized/model/grandstreamht8xx.rb) | @mklopocki | [Grandstream](Model-Notes/GrandstreamHT8xx.md)
|
|
111
113
|
|Hatteras |Hatteras |[hatteras](/lib/oxidized/model/hatteras.rb)
|
|
112
114
|
|Hillstone Networks |StoneOS |[stoneos](/lib/oxidized/model/stoneos.rb)
|
|
113
115
|
|Hirschmann |Classic |[hirschmann](/lib/oxidized/model/hirschmann.rb)
|
|
114
116
|
| |HiOS |[hios](/lib/oxidized/model/hios.rb)
|
|
115
117
|
|HP |Comware (HP A-series, H3C, 3Com)|[comware](/lib/oxidized/model/comware.rb) |@robertcheramy |[Comware](Model-Notes/Comware.md)
|
|
116
|
-
| |Procurve |[procurve](/lib/oxidized/model/procurve.rb) |@robertcheramy
|
|
118
|
+
| |Procurve |[procurve](/lib/oxidized/model/procurve.rb) |@robertcheramy, @thanegill
|
|
117
119
|
| |BladeSystem (Onboard Administrator)|[hpebladesystem](/lib/oxidized/model/hpebladesystem.rb)
|
|
118
120
|
| |MSA |[hpemsa](/lib/oxidized/model/hpemsa.rb)
|
|
119
121
|
| |MSM (Wireless Controller) |[hpmsm](/lib/oxidized/model/hpmsm.rb)
|
|
120
122
|
|H3C |S6520X |[h3c](/lib/oxidized/model/h3c.rb)
|
|
121
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)
|
|
122
125
|
| |SmartAX series |[smartax](/lib/oxidized/model/smartax.rb) | |[SmartAX-Huawei](Model-Notes/SmartAX-Huawei.md)
|
|
123
126
|
|Icotera |6400 series |[icotera](/lib/oxidized/model/icotera.rb)
|
|
124
127
|
|Ingate |SIParator/Firewalls |[ingate](/lib/oxidized/model/ingate.rb) |@thanegill
|
|
@@ -127,6 +130,7 @@
|
|
|
127
130
|
|Juniper |JunOS |[junos](/lib/oxidized/model/junos.rb) | |[MX/QFX/EX/SRX/J Series](Model-Notes/JunOS.md)
|
|
128
131
|
| |ScreenOS (Netscreen) |[screenos](/lib/oxidized/model/screenos.rb)
|
|
129
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)
|
|
130
134
|
|Lenovo |Lenovo Network OS |[lenovonos](/lib/oxidized/model/lenovonos.rb) | |[Lenovo Network OS](Model-Notes/LenovoNOS.md)
|
|
131
135
|
|Linkys |SRW |[linksyssrw](/lib/oxidized/model/linksyssrw.rb) | |[LinksysSRW](Model-Notes/LinksysSRW.md)
|
|
132
136
|
|Linuxgeneric |CentOS |[linuxgeneric](/lib/oxidized/model/linuxgeneric.rb)| |[LinuxGeneric](Model-Notes/LinuxGeneric.md)
|
|
@@ -179,6 +183,7 @@
|
|
|
179
183
|
|Trango Systems |Trango |[trango](/lib/oxidized/model/trango.rb)
|
|
180
184
|
|TrueNAS |TrueNAS |[truenas](/lib/oxidized/model/truenas.rb)
|
|
181
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)|
|
|
182
187
|
| |TL-SL5428 |[edgecos](/lib/oxidized/model/edgecos.rb)
|
|
183
188
|
| |TL-SL3428 |[powerconnect](/lib/oxidized/model/powerconnect.rb)
|
|
184
189
|
|Ubiquiti |AirOS |[airos](/lib/oxidized/model/airos.rb)
|
|
@@ -186,10 +191,11 @@
|
|
|
186
191
|
| |EdgeSwitch |[edgeswitch](/lib/oxidized/model/edgeswitch.rb)
|
|
187
192
|
| |AirFiber |[airfiber](/lib/oxidized/model/airfiber.rb)
|
|
188
193
|
| |UnifiAP |[unifiap](/lib/oxidized/model/unifiap.rb) |@clifcox |Also suports AirOS, and some Unifi switches
|
|
189
|
-
|Uplink |EP4440-DP |[
|
|
194
|
+
|Uplink |EP4440-DP |[uplinkolt](/lib/oxidized/model/uplinkolt.rb) | |Might support all EP4440 series
|
|
190
195
|
|VMWare |NSX Edge (configuration) |[nsxconfig](/lib/oxidized/model/nsxconfig.rb)
|
|
191
196
|
| |NSX Edge (firewall rules) |[nsxfirewall](/lib/oxidized/model/nsxfirewall.rb)
|
|
192
197
|
| |NSX Distributed Firewall |[nsxdfw](/lib/oxidized/model/nsxdfw.rb)
|
|
198
|
+
|VSOL |GPON OLT |[vsololt](/lib/oxidized/model/vsololt.rb) |@Vantomas |
|
|
193
199
|
|VYOS Networks |VYOS |[vyos](/lib/oxidized/model/vyos.rb) | |Fork of Vyatta, tracking the supported versions (>= 1.4.x)
|
|
194
200
|
|Watchguard |Fireware OS |[firewareos](/lib/oxidized/model/firewareos.rb)
|
|
195
201
|
|Waystream (PacketFront)|iBOS (Intelligent Broadband OS)|[ibos](/lib/oxidized/model/ibos.rb)
|