oxidized 0.31.0 → 0.32.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -3
- data/.rubocop.yml +1 -2
- data/.rubocop_todo.yml +6 -6
- data/CHANGELOG.md +32 -0
- data/Dockerfile +5 -2
- data/Rakefile +28 -0
- data/docs/Configuration.md +14 -2
- data/docs/Creating-Models.md +52 -22
- data/docs/DeviceSimulation.md +184 -0
- data/docs/Hooks.md +5 -5
- data/docs/Issues.md +15 -9
- data/docs/Model-Notes/APC_AOS.md +29 -16
- data/docs/Model-Notes/FSOS.md +1 -0
- data/docs/ModelUnitTests.md +186 -0
- data/docs/Supported-OS-Types.md +3 -2
- data/examples/podman-compose/Makefile +1 -2
- data/{examples/device-simulation → extra}/device2yaml.rb +32 -12
- data/extra/gitdiff-msteams.sh +32 -5
- data/extra/nagios_check_failing_nodes.rb +1 -1
- data/extra/rest_client.rb +1 -1
- data/lib/oxidized/config.rb +1 -1
- data/lib/oxidized/input/ssh.rb +13 -5
- data/lib/oxidized/model/aos7.rb +2 -0
- data/lib/oxidized/model/aosw.rb +1 -1
- data/lib/oxidized/model/apc_aos.rb +1 -1
- data/lib/oxidized/model/arubainstant.rb +1 -1
- data/lib/oxidized/model/asa.rb +2 -1
- data/lib/oxidized/model/asyncos.rb +1 -1
- data/lib/oxidized/model/cumulus.rb +16 -2
- data/lib/oxidized/model/enterprise_sonic.rb +46 -0
- data/lib/oxidized/model/fsos.rb +5 -1
- data/lib/oxidized/model/garderos.rb +4 -4
- data/lib/oxidized/model/junos.rb +1 -1
- data/lib/oxidized/model/kornfeldos.rb +33 -0
- data/lib/oxidized/model/model.rb +2 -2
- data/lib/oxidized/model/sonicos.rb +8 -2
- data/lib/oxidized/model/tplink.rb +1 -0
- data/lib/oxidized/model/xos.rb +1 -1
- data/lib/oxidized/source/source.rb +32 -2
- data/lib/oxidized/version.rb +2 -2
- data/oxidized.gemspec +7 -6
- metadata +33 -35
- data/examples/device-simulation/README.md +0 -173
- data/examples/device-simulation/cmdsets/aoscx +0 -9
- data/examples/device-simulation/cmdsets/arubainstant +0 -5
- data/examples/device-simulation/cmdsets/asa +0 -7
- data/examples/device-simulation/cmdsets/ios +0 -7
- data/examples/device-simulation/cmdsets/nxos +0 -5
- data/examples/device-simulation/cmdsets/routeros +0 -5
- data/examples/device-simulation/cmdsets/srosmd +0 -11
- data/examples/device-simulation/yaml/aoscx_R0X25A-6410_FL.10.10.1100.yaml +0 -2281
- data/examples/device-simulation/yaml/aoscx_R8N85A-C6000-48G-CL4_PL.10.08.1010.yaml +0 -451
- data/examples/device-simulation/yaml/arubainstant_IAP515_8.10.0.6_VWLC.yaml +0 -213
- data/examples/device-simulation/yaml/asa_5512_9.12-4-67_single-context.yaml +0 -531
- data/examples/device-simulation/yaml/asr920_16.8.1b.yaml +0 -1122
- data/examples/device-simulation/yaml/garderos_R7709_003_006_068.yaml +0 -101
- data/examples/device-simulation/yaml/iosxe_C9200L-24P-4G_17.09.04a.yaml +0 -514
- data/examples/device-simulation/yaml/iosxe_C9800-L-F-K9_17.06.05.yaml +0 -417
- data/examples/device-simulation/yaml/riverbed_915.yaml +0 -123
- data/examples/device-simulation/yaml/routeros_CHR_7.10.1.yaml +0 -145
- data/examples/device-simulation/yaml/routeros_CHR_7.16.yaml +0 -79
- data/examples/device-simulation/yaml/routeros_L009UiGS_7.15.2.yaml +0 -353
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b47cc2ddbb41778414a86ed387714b91340ff440f125d948b8168c6ab1641f71
|
4
|
+
data.tar.gz: 492d75d181d94cef898e5a687715d81e94dd9139ff6310e4c6b304edb92be39e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5028d2ae6b9ecb04783381d0804d68014f308e4109627b27d7a4c8225529ea06d3c300a46547fcfd47f1c961acab294cb7abae8200b0aa857a86af27c6f1269
|
7
|
+
data.tar.gz: cbeebeca48db2727432e42d069f3b94d326e150163944f27a21594dcaf73bc0eab7b91518f5d265c5a576e083b749ca733123fa438d247d15d9d2cf365b4a1dc
|
data/.github/workflows/ruby.yml
CHANGED
@@ -19,7 +19,8 @@ jobs:
|
|
19
19
|
runs-on: ubuntu-latest
|
20
20
|
strategy:
|
21
21
|
matrix:
|
22
|
-
ruby-version: ['3.1', '3.2', '3.3']
|
22
|
+
ruby-version: ['3.1', '3.2', '3.3', '3.4', 'ruby-head']
|
23
|
+
continue-on-error: ${{ matrix.ruby-version == 'ruby-head' }}
|
23
24
|
|
24
25
|
steps:
|
25
26
|
- uses: actions/checkout@v4
|
@@ -38,5 +39,3 @@ jobs:
|
|
38
39
|
reporter: github-pr-review
|
39
40
|
- name: Run tests
|
40
41
|
run: bundle exec rake
|
41
|
-
- uses: codecov/codecov-action@v3
|
42
|
-
if: ${{ always() }}
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2025-02-17 10:13:53 UTC using RuboCop version 1.72.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 30
|
10
10
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
11
11
|
Metrics/AbcSize:
|
12
12
|
Enabled: false
|
13
13
|
|
14
|
-
# Offense count:
|
14
|
+
# Offense count: 17
|
15
15
|
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
16
16
|
Metrics/CyclomaticComplexity:
|
17
17
|
Max: 12
|
18
18
|
|
19
|
-
# Offense count:
|
19
|
+
# Offense count: 14
|
20
20
|
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
21
21
|
Metrics/PerceivedComplexity:
|
22
22
|
Max: 12
|
@@ -72,12 +72,12 @@ Style/OpenStructUse:
|
|
72
72
|
- 'lib/oxidized/node.rb'
|
73
73
|
- 'spec/hook/githubrepo_spec.rb'
|
74
74
|
|
75
|
-
# Offense count:
|
75
|
+
# Offense count: 33
|
76
76
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
77
77
|
Style/SlicingWithRange:
|
78
78
|
Enabled: false
|
79
79
|
|
80
|
-
# Offense count:
|
80
|
+
# Offense count: 94
|
81
81
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
82
82
|
# Configuration parameters: Mode.
|
83
83
|
Style/StringConcatenation:
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,37 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
6
6
|
|
7
|
+
## [0.32.0 – 2025-02-17]
|
8
|
+
This release fixes a security issue in oxidized-web, which is included in the
|
9
|
+
Docker container of oxidized. If you are not using the Docker container but
|
10
|
+
use oxidized-web, be sure to update your oxidized-web gem to 0.15.0.
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- junos: add unit test (@systeembeheerder)
|
14
|
+
- apc_aos: support for scp (@robertcheramy)
|
15
|
+
- config: allow model_map and group_map keys to be regexp. Fixes #3360 (@ytti)
|
16
|
+
- enterprise_sonic: add new model enterprise_sonic (@ohai89)
|
17
|
+
- model for Kornfeld Operating System (@yurenkov)
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
- sonicos: accept policy message. Fixes #3339 (@Steve-M-C, @robertcheramy)
|
21
|
+
- input/ssh: change input.debug to dump all characters and include sent commands. (@robertcheramy)
|
22
|
+
- cumulus: remove ANSI Escape codes and fix prompt issues. The prompt is more specific now (@alchemyx, @robertcheramy)
|
23
|
+
- model unit tests: the tests are automated and simpler to use (@ytti, @robertcheramy)
|
24
|
+
- device2yaml.rb: moved to extra/, commands can be specified from the command line or from a file (no cmdsets provided anymore) (@robertcheramy)
|
25
|
+
- extra/gitdiff-msteams.sh: honor the 28KB size limit and add an optional link to GitHub (@mopi3456)
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
- tplink: send 'enable' before the enable password. Fixes #3271 (@robertcheramy)
|
29
|
+
- asyncos: fix prompt for hostnames containing "-" . Fixes #3327 (@robertcheramy)
|
30
|
+
- sonicos: fix prompt for hostnames containing "-" . Fixes #3333 (@robertcheramy)
|
31
|
+
- xos: Hide radius accounting secret
|
32
|
+
- fsos: Hide AAA and SNMP secrets (@RayaneB35)
|
33
|
+
- aos7: fix prompt for version 8.8x. Fixes #3351 (@robertcheramy)
|
34
|
+
- aosw: Hide power measurements (@rouven0)
|
35
|
+
- arubainstant: show version prepends a space to prompt when a core file is present. Fixes #3398 (@robertcheramy)
|
36
|
+
|
37
|
+
|
7
38
|
## [0.31.0 – 2024-11-29]
|
8
39
|
|
9
40
|
### Added
|
@@ -66,6 +97,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
66
97
|
- netgear: prompt for gs752tpp. Fixes #3287 (@robertcheramy)
|
67
98
|
- aoscx: fixed regex for 6400 switches to hide temperature and power (@steveneppler)
|
68
99
|
|
100
|
+
|
69
101
|
## [0.30.1 – 2024-04-12]
|
70
102
|
|
71
103
|
### Added
|
data/Dockerfile
CHANGED
@@ -18,6 +18,7 @@ ENV GEM_HOME=/usr/local/bundle
|
|
18
18
|
# Install the x25519 gem
|
19
19
|
RUN gem install x25519 --no-document
|
20
20
|
|
21
|
+
|
21
22
|
###################
|
22
23
|
# build oxidized
|
23
24
|
COPY . /tmp/oxidized/
|
@@ -76,7 +77,7 @@ RUN apt-get -yq update \
|
|
76
77
|
# Use ubuntu gems where possible
|
77
78
|
# Gems needed by oxidized
|
78
79
|
ruby-rugged ruby-slop ruby-psych \
|
79
|
-
ruby-net-telnet ruby-net-ssh ruby-net-ftp ruby-
|
80
|
+
ruby-net-telnet ruby-net-ssh ruby-net-ftp ruby-ed25519 \
|
80
81
|
# Gem dependencies for inputs
|
81
82
|
ruby-net-http-persistent ruby-mechanize \
|
82
83
|
# Gem dependencies for sources
|
@@ -101,7 +102,9 @@ RUN gem install --no-document \
|
|
101
102
|
# dependencies for hooks
|
102
103
|
slack-ruby-client cisco_spark \
|
103
104
|
# dependencies for specific inputs
|
104
|
-
net-tftp
|
105
|
+
net-tftp \
|
106
|
+
# Net scp is needed in Version >= 4.1.0, which is not available in ubuntu
|
107
|
+
net-scp
|
105
108
|
|
106
109
|
# install oxidized from prebuilder
|
107
110
|
# The Dockerfile ist version-independent, so use oxidized-*.gem to cach the gem
|
data/Rakefile
CHANGED
@@ -74,6 +74,7 @@ task :chmod do
|
|
74
74
|
extra/oxidized.runit
|
75
75
|
extra/syslog.rb
|
76
76
|
extra/update-ca-certificates.runit
|
77
|
+
extra/device2yaml.rb
|
77
78
|
]
|
78
79
|
dirs = []
|
79
80
|
%x(git ls-files -z).split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }.each do |file|
|
@@ -83,4 +84,31 @@ task :chmod do
|
|
83
84
|
dirs.sort.uniq.each { |dir| File.chmod(0o0755, dir) }
|
84
85
|
end
|
85
86
|
|
87
|
+
# Build the container image with docker or podman
|
88
|
+
def command_available?(command)
|
89
|
+
system("which #{command} > /dev/null 2>&1")
|
90
|
+
end
|
91
|
+
|
92
|
+
def docker_needs_root?
|
93
|
+
!system('docker info > /dev/null 2>&1')
|
94
|
+
end
|
95
|
+
|
96
|
+
desc 'Build the container image with docker or podman'
|
97
|
+
task :build_container do
|
98
|
+
# Prefer podman if available as it runs rootless
|
99
|
+
if command_available?('podman')
|
100
|
+
sh 'podman build -t oxidized:`git describe --tags` -t oxidized:latest .'
|
101
|
+
elsif command_available?('docker')
|
102
|
+
if docker_needs_root?
|
103
|
+
puts 'docker needs root to build the image. Using sudo...'
|
104
|
+
sh 'sudo docker build -t oxidized:`git describe --tags` -t oxidized:latest .'
|
105
|
+
else
|
106
|
+
sh 'docker build -t oxidized:`git describe --tags` -t oxidized:latest .'
|
107
|
+
end
|
108
|
+
else
|
109
|
+
puts 'You need Podman or Docker to build the container image.'
|
110
|
+
exit 1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
86
114
|
task default: :test
|
data/docs/Configuration.md
CHANGED
@@ -174,7 +174,16 @@ input:
|
|
174
174
|
|
175
175
|
## Advanced Configuration
|
176
176
|
|
177
|
-
Below is an advanced example configuration.
|
177
|
+
Below is an advanced example configuration.
|
178
|
+
|
179
|
+
You will be able to (optionally) override options per device.
|
180
|
+
The router.db format used is `hostname:model:username:password:enable_password`.
|
181
|
+
Hostname and model will be the only required options, all others override the
|
182
|
+
global configuration sections.
|
183
|
+
|
184
|
+
Custom model names can be mapped to an oxidized model name with a string or
|
185
|
+
a regular expression.
|
186
|
+
|
178
187
|
|
179
188
|
```yaml
|
180
189
|
---
|
@@ -226,6 +235,7 @@ source:
|
|
226
235
|
model_map:
|
227
236
|
cisco: ios
|
228
237
|
juniper: junos
|
238
|
+
!ruby/regexp /procurve/: procurve
|
229
239
|
```
|
230
240
|
|
231
241
|
## Advanced Group Configuration
|
@@ -268,7 +278,8 @@ groups:
|
|
268
278
|
ssh_keys: "~/.ssh/id_rsa_bar_vyatta"
|
269
279
|
```
|
270
280
|
|
271
|
-
For mapping multiple group values to a common name
|
281
|
+
For mapping multiple group values to a common name, you can use strings and
|
282
|
+
regular expressions:
|
272
283
|
|
273
284
|
```yaml
|
274
285
|
group_map:
|
@@ -276,6 +287,7 @@ group_map:
|
|
276
287
|
alias2: groupA
|
277
288
|
alias3: groupB
|
278
289
|
alias4: groupB
|
290
|
+
!ruby/regexp /specialgroup/: groupS
|
279
291
|
aliasN: groupZ
|
280
292
|
# ...
|
281
293
|
```
|
data/docs/Creating-Models.md
CHANGED
@@ -54,6 +54,52 @@ The API documentation contains a list of [methods](https://github.com/ytti/oxidi
|
|
54
54
|
|
55
55
|
A more fleshed out example can be found in the `IOS` and `JunOS` models.
|
56
56
|
|
57
|
+
### Common task: mechanism for handling 'enable' mode
|
58
|
+
The following code snippet demonstrates how to handle sending the 'enable'
|
59
|
+
command and an enable password.
|
60
|
+
|
61
|
+
This example is taken from the `IOS` model. It covers scenarios where users
|
62
|
+
need to enable privileged mode, either without providing a password (by setting
|
63
|
+
`enable: true` in the configuration) or with a password.
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
cfg :telnet, :ssh do
|
67
|
+
post_login do
|
68
|
+
if vars(:enable) == true
|
69
|
+
cmd "enable"
|
70
|
+
elsif vars(:enable)
|
71
|
+
cmd "enable", /^[pP]assword:/
|
72
|
+
cmd vars(:enable)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
```
|
77
|
+
Note: remove `:telnet, ` if your device does not support telnet.
|
78
|
+
|
79
|
+
### Common Task: remove ANSI escape codes
|
80
|
+
> :warning: This common task is experimental.
|
81
|
+
> If it does not work for you, please open an issue so that we can adapt the
|
82
|
+
> code snippet.
|
83
|
+
|
84
|
+
Some devices produce ANSI escape codes to enhance the appearance of output.
|
85
|
+
However, this can make prompt matching difficult and some of these ANSI escape
|
86
|
+
codes might end up in the resulting configuration.
|
87
|
+
|
88
|
+
You can remove most [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Control_Sequence_Introducer_commands) using the following Ruby
|
89
|
+
code in your model:
|
90
|
+
```
|
91
|
+
# Remove ANSI escape codes
|
92
|
+
expect /\e\[[0-?]*[ -\/]*[@-~]\r?/ do |data, re|
|
93
|
+
data.gsub re, ''
|
94
|
+
end
|
95
|
+
```
|
96
|
+
Explanation of the Regular Expression:
|
97
|
+
- `\e\[` : Control Sequence Introducer (CSI), which starts with "ESC [".
|
98
|
+
- `[0-?]*` : "Parameter" bytes (range 0x30–0x3F, corresponding to ASCII `0–9:;<=>?`).
|
99
|
+
- `[ -\/]*`: "Intermediate" bytes (range 0x20–0x2F, corresponding to ASCII ` !"#$%&'()*+,-./`).
|
100
|
+
- `[@-~]` : The "final" byte (range 0x40–0x7E, corresponding to ASCII ``@A–Z[\]^_`a–z{|}~).[``).
|
101
|
+
- `\r?` : Some ESC codes include a carriage return, which we do not want in the resulting config.
|
102
|
+
|
57
103
|
## Extending an existing model with a new command
|
58
104
|
|
59
105
|
The example below can be used to extend the `JunOS` model to collect the output of `show interfaces diagnostics optics` and append the output to the configuration file as a comment. This command retrieves DOM information on pluggable optics present in a `JunOS`-powered chassis.
|
@@ -86,32 +132,16 @@ Intuitively, it is also possible to:
|
|
86
132
|
* Create a completely new model, with a new name, for a new operating system type.
|
87
133
|
* Testing/validation of an updated model from the [Oxidized GitHub repo models](https://github.com/ytti/oxidized/tree/master/lib/oxidized/model) by placing an updated model in the proper location without disrupting the gem-supplied model files.
|
88
134
|
|
89
|
-
## Create
|
90
|
-
|
91
|
-
|
92
|
-
If you want the model to be integrated into oxidized, you can
|
93
|
-
[submit a pull request on github](https://github.com/ytti/oxidized/pulls).
|
135
|
+
## Create Unit Tests for the Model
|
136
|
+
If you want the model to be integrated into Oxidized, you can
|
137
|
+
[submit a pull request on GitHub](https://github.com/ytti/oxidized/pulls).
|
94
138
|
This is a greatly appreciated submission, as there are probably other users
|
95
139
|
using the same network device as you are.
|
96
140
|
|
97
141
|
A good (and optional) practice for submissions is to provide a
|
98
|
-
[unit test for your model](/
|
99
|
-
developments could break it, and facilitates debugging issues without
|
100
|
-
access to a physical network device for the model.
|
101
|
-
|
102
|
-
In order to simulate the device in the unit test, you need a
|
103
|
-
[YAML simulation file](/examples/device-simulation/), have a look at the
|
104
|
-
link for an explanation on how to create one.
|
105
|
-
|
106
|
-
Creating the unit test itself is explained in
|
107
|
-
[README.md in the model unit test directory](/spec/model/README.md).
|
108
|
-
|
109
|
-
Remember - producing a YAML simulation file and/or writing a unit test is
|
110
|
-
optional.
|
111
|
-
The most value comes from the YAML simulation file. The unit
|
112
|
-
test can be written by someone else, but you need access to the device for the
|
113
|
-
YAML simulation file. If you encounter problems, open an issue or ask for help
|
114
|
-
in your pull request.
|
142
|
+
[unit test for your model](/docs/ModelUnitTests.md). This reduces the risk that
|
143
|
+
further developments could break it, and facilitates debugging issues without
|
144
|
+
having access to a physical network device for the model.
|
115
145
|
|
116
146
|
## Advanced features
|
117
147
|
|
@@ -0,0 +1,184 @@
|
|
1
|
+
# Device Simulation
|
2
|
+
Oxidized supports [150+ devices](/docs/Supported-OS-Types.md).
|
3
|
+
|
4
|
+
No developer has access to all of these devices, which makes the task of
|
5
|
+
maintaining Oxidized difficult:
|
6
|
+
|
7
|
+
- Issues can't be resolved because the developer has no access to the device.
|
8
|
+
- Further developments can produce regressions.
|
9
|
+
|
10
|
+
In order to address this, we can simulate the devices. An example of a
|
11
|
+
simulation is the [model unit tests](/spec/model), but one could also simulate a
|
12
|
+
device within an SSH server.
|
13
|
+
|
14
|
+
The simulation of devices is currently focused on SSH-based devices. This may be
|
15
|
+
extended to other inputs like Telnet or FTP in the future.
|
16
|
+
|
17
|
+
## YAML Simulation Data
|
18
|
+
The underlying data for the simulation is a [YAML](https://yaml.org/) file in
|
19
|
+
which we store all relevant information about the device. The most important
|
20
|
+
information is the responses to the commands used in the Oxidized models.
|
21
|
+
|
22
|
+
The YAML simulation files are stored under
|
23
|
+
[/spec/model/data/](/spec/model/data/), with the naming convention
|
24
|
+
`<model>:<description>:simulation.yaml`, where `<model>` is the lowercase name
|
25
|
+
of the Oxidized model and `<description>` is the name of the test case.
|
26
|
+
`<description>` is generally formatted as `<hardware>_<software>` or
|
27
|
+
`<hardware>_<software>_<information>`.
|
28
|
+
|
29
|
+
### Creating a YAML Simulation File with device2yaml.rb
|
30
|
+
A device does not only output the ASCII text we can see in the console.
|
31
|
+
It adds ANSI escape codes for nice colors, bold and underline, \r, and so on.
|
32
|
+
These are key factors in prompt issues, so they must be represented in the YAML
|
33
|
+
file. We use the Ruby string format with interpolations like \r, \e, and so on.
|
34
|
+
Another important point is trailing spaces at the end of lines. Some text
|
35
|
+
editors automatically remove trailing spaces, so we code them with \x20.
|
36
|
+
|
37
|
+
Although a YAML file could be written by hand, this is quite a tedious task to
|
38
|
+
catch all the extra codes and code them into YAML. This can be automated with
|
39
|
+
the Ruby script [extra/device2yaml.rb](/extra/device2yaml.rb).
|
40
|
+
|
41
|
+
`device2yaml.rb` needs Ruby and the gem
|
42
|
+
[net-ssh](https://rubygems.org/gems/net-ssh/) to run. On Debian, you can install
|
43
|
+
them with `sudo apt install ruby-net-ssh`.
|
44
|
+
|
45
|
+
Run `extra/device2yaml.rb`, the online help tells you the options.
|
46
|
+
```
|
47
|
+
oxidized$ extra/device2yaml.rb
|
48
|
+
Missing a host to connect to...
|
49
|
+
|
50
|
+
Usages:
|
51
|
+
- device2yaml.rb [user@]host -i file [options]
|
52
|
+
- device2yaml.rb [user@]host -c "command1
|
53
|
+
command2
|
54
|
+
command3" [options]
|
55
|
+
|
56
|
+
-i and -c are mutualy exclusive, one must be specified
|
57
|
+
|
58
|
+
[options]:
|
59
|
+
-c, --commands "command list" specify the commands to be run
|
60
|
+
-i, --input file Specify an input file for commands to be run
|
61
|
+
-o, --output file Specify an output YAML-file
|
62
|
+
-t, --timeout value Specify the idle timeout beween commands (default: 5 seconds)
|
63
|
+
-e, --exec-mode Run ssh in exec mode (without tty)
|
64
|
+
-h, --help Print this help
|
65
|
+
```
|
66
|
+
|
67
|
+
- `[user@]host` specifies the user and host to connect to the device. The
|
68
|
+
password will be prompted interactively by the script. If you do not specify a
|
69
|
+
user, it will use the user executing the script.
|
70
|
+
- The commands that will be run on the device must be defined in
|
71
|
+
`deviceyaml.rb`. You can give the commands online with `-c` or read them from a
|
72
|
+
file (one line per command) with `-i`. The commands should match exactly the
|
73
|
+
ones of the model (no abbreviations) and include the commands of the
|
74
|
+
`post_login` and `pre_logout` sections. When using `-c` and editing the shell
|
75
|
+
command line, `CTRL-V CTRL-J` is very useful to add a line break.
|
76
|
+
- `device2yaml.rb` waits an idle timeout after the last received data
|
77
|
+
before sending the next command. The default is 5 seconds. If your device makes
|
78
|
+
a longer pause than 5 seconds before or within a command, you will see that the
|
79
|
+
output of the command is shortened or slips into the next command in the YAML
|
80
|
+
file. You will have to change the idle timeout to a greater value to address
|
81
|
+
this.
|
82
|
+
- When run without the output argument, `device2yaml.rb` will only print the SSH
|
83
|
+
output to the standard output. You must use `-o <model:HW_SW:simulation.yaml>`
|
84
|
+
to store the collected data in a YAML file.
|
85
|
+
- If your Oxidized model uses SSH exec mode (look for `exec true` in the model),
|
86
|
+
you will have to use the option `-e` to run `device2yaml.rb` in SSH exec mode.
|
87
|
+
|
88
|
+
Note that `device2yaml.rb` takes some time to run because of the idle timeout of
|
89
|
+
(default) 5 seconds between each command. You can press the "Escape" key if you
|
90
|
+
know there is no more data to come for the current command (when you see the
|
91
|
+
prompt for the next command), and the script will stop waiting and directly
|
92
|
+
process the next command.
|
93
|
+
|
94
|
+
|
95
|
+
Running the script against an ios device would look like:
|
96
|
+
```shell
|
97
|
+
extra/device2yaml.rb oxidized@r61 -c "terminal length 0
|
98
|
+
terminal width 0
|
99
|
+
show version
|
100
|
+
show vtp status
|
101
|
+
show inventory
|
102
|
+
show running-config
|
103
|
+
exit" -o spec/model/data/ios:C8200L_16.12.1:simulation.yaml
|
104
|
+
```
|
105
|
+
### Publishing the YAML Simulation File to Oxidized
|
106
|
+
Publishing the YAML simulation file of your device helps maintain Oxidized. This
|
107
|
+
task may take some time, and we are very grateful that you take this time for
|
108
|
+
the community!
|
109
|
+
|
110
|
+
You should pay attention to removing or replacing anything you don't want to
|
111
|
+
share with the rest of the world, for example:
|
112
|
+
|
113
|
+
- Passwords
|
114
|
+
- IP Addresses
|
115
|
+
- Serial numbers
|
116
|
+
|
117
|
+
You can also shorten the configuration if you want - we don't need 48 times the
|
118
|
+
same configuration for each interface, but it doesn't hurt either.
|
119
|
+
|
120
|
+
Take your time, this is an important task: after you have uploaded your file on
|
121
|
+
GitHub, it may be impossible to remove it.
|
122
|
+
You can use search/replace to make consistent and faster changes, for example
|
123
|
+
change the hostname everywhere.
|
124
|
+
|
125
|
+
The YAML simulation files are stored under
|
126
|
+
[/spec/model/data/](/spec/model/data/), with the naming convention
|
127
|
+
`<model>:<description>:simulation.yaml`, where `<model>` is the lowercase name
|
128
|
+
of the Oxidized model and `<description>` is the name of the test case.
|
129
|
+
`<description>` is generally formatted as `<hardware>_<software>` or
|
130
|
+
`<hardware>_<software>_<information>`.
|
131
|
+
|
132
|
+
Using a correct name for the file is important to ensure it is included in
|
133
|
+
automatic model unit tests.
|
134
|
+
|
135
|
+
Examples:
|
136
|
+
|
137
|
+
- spec/model/data/aoscx:R0X25A-6410_FL.10.10.1100:simulation.yaml
|
138
|
+
- spec/model/data/asa:5512_9.12-4-67_single-context:simulation.yaml
|
139
|
+
- spec/model/data/ios:C9200L-24P-4G_17.09.04a:simulation.yaml
|
140
|
+
|
141
|
+
When you are finished, commit and push to your forked repository on GitHub, and
|
142
|
+
submit a Pull Request. Thank you for your help!
|
143
|
+
|
144
|
+
### Interactive Mode
|
145
|
+
The `device2yaml.rb` script is basic and sometimes needs some help, especially
|
146
|
+
when dealing with a device that sends its output page by page and requires you
|
147
|
+
to press space for the next page. `device2yaml.rb` does not know how to handle
|
148
|
+
this.
|
149
|
+
|
150
|
+
While `device2yaml.rb` is running, you can type anything on the keyboard, and it
|
151
|
+
will be sent to the remote device. So you can press space or 'n' to get the next
|
152
|
+
page.
|
153
|
+
|
154
|
+
You can also use this to enter an enable password.
|
155
|
+
|
156
|
+
If you press the "Esc" key, `device2yaml.rb` will not wait for the idle timeout
|
157
|
+
and will process the next command right away.
|
158
|
+
|
159
|
+
### YAML Format
|
160
|
+
The YAML file has two sections:
|
161
|
+
- init_prompt: describing the lines sent by the device before we can send a
|
162
|
+
command. It usually includes MOTD banners and must include the first prompt.
|
163
|
+
- commands: the commands the Oxidized model sends to the network device and
|
164
|
+
their outputs.
|
165
|
+
|
166
|
+
The outputs are multiline and use YAML block scalars (`|`), with the trailing \n
|
167
|
+
removed (`-` after `|`). The outputs include the echo of the given command and
|
168
|
+
the next prompt. Escape characters are coded in Ruby style (\n, \r...).
|
169
|
+
|
170
|
+
Here is a shortened example of a YAML file:
|
171
|
+
```yaml
|
172
|
+
---
|
173
|
+
init_prompt: |-
|
174
|
+
\e[4m\rLAB-R1234_Garderos#\e[m\x20
|
175
|
+
commands:
|
176
|
+
show system version: |-
|
177
|
+
show system version
|
178
|
+
grs-gwuz-armel/003_005_068 (Garderos; 2021-04-30 16:19:35)
|
179
|
+
\e[4m\rLAB-R1234_Garderos#\e[m\x20
|
180
|
+
# ...
|
181
|
+
exit: ""
|
182
|
+
```
|
183
|
+
|
184
|
+
|
data/docs/Hooks.md
CHANGED
@@ -259,13 +259,15 @@ gem install slack-ruby-client
|
|
259
259
|
|
260
260
|
### slackdiff hook configuration example
|
261
261
|
|
262
|
+
> Please note that the channel needs to be your Slack channel ID.
|
263
|
+
|
262
264
|
```yaml
|
263
265
|
hooks:
|
264
266
|
slack:
|
265
267
|
type: slackdiff
|
266
268
|
events: [post_store]
|
267
269
|
token: SLACK_BOT_TOKEN
|
268
|
-
channel: "
|
270
|
+
channel: "CHANNEL_ID"
|
269
271
|
```
|
270
272
|
|
271
273
|
The token parameter is a Slack API token that can be generated following [this tutorial](https://api.slack.com/tutorials/tracks/getting-a-token). Until Slack stops supporting them, legacy tokens can also be used.
|
@@ -278,13 +280,11 @@ hooks:
|
|
278
280
|
type: slackdiff
|
279
281
|
events: [post_store]
|
280
282
|
token: SLACK_BOT_TOKEN
|
281
|
-
channel: "
|
283
|
+
channel: "CHANNEL_ID"
|
282
284
|
diff: false
|
283
285
|
message: "%{node} %{group} %{model} updated https://git.intranet/network-changes/commit/%{commitref}"
|
284
286
|
```
|
285
287
|
|
286
|
-
Note the channel name must be in quotes.
|
287
|
-
|
288
288
|
A proxy can optionally be specified if needed to reach the Slack API endpoint.
|
289
289
|
|
290
290
|
```yaml
|
@@ -293,7 +293,7 @@ hooks:
|
|
293
293
|
type: slackdiff
|
294
294
|
events: [post_store]
|
295
295
|
token: SLACK_BOT_TOKEN
|
296
|
-
channel: "#
|
296
|
+
channel: "#CHANNEL_ID"
|
297
297
|
proxy: http://myproxy:8080
|
298
298
|
```
|
299
299
|
|
data/docs/Issues.md
CHANGED
@@ -49,7 +49,7 @@ contributing code via a pull request (PR) or hiring a developer.
|
|
49
49
|
|
50
50
|
## Sumbit a YAML Simulation File
|
51
51
|
To help developers troubleshoot device-specific issues, you may be asked to submit a
|
52
|
-
[YAML simulation file](
|
52
|
+
[YAML simulation file](/docs/DeviceSimulation.md#creating-a-yaml-file-with-device2yamlrb) for your device.
|
53
53
|
|
54
54
|
Here's a brief overview how to do it, you can find more details in the link
|
55
55
|
above.
|
@@ -63,22 +63,28 @@ sudo apt install git ruby-net-ssh
|
|
63
63
|
```
|
64
64
|
git clone git@github.com:<your github user>/oxidized.git
|
65
65
|
```
|
66
|
-
- run the device2yaml.rb script (you’ll be provided with the command
|
67
|
-
|
66
|
+
- run the `extra/device2yaml.rb` script (you’ll be provided with the command to
|
67
|
+
run) from the repository root:
|
68
|
+
|
68
69
|
```
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
extra/device2yaml.rb oxidized@r61 -c "terminal length 0
|
71
|
+
terminal width 0
|
72
|
+
show version
|
73
|
+
show vtp status
|
74
|
+
show inventory
|
75
|
+
show running-config
|
76
|
+
exit" -o spec/model/data/ios:C8200L_16.12.1:simulation.yaml
|
72
77
|
```
|
78
|
+
|
73
79
|
- The script waits 5 seconds between commands, and outputs the response of the
|
74
80
|
device. You can press "ESC" if you see the prompt and want to pass to next
|
75
81
|
command without waiting for the timeout.
|
76
|
-
- The result will be stored in `
|
82
|
+
- The result will be stored in `spec/model/data/`.
|
77
83
|
- Replace any sensitive information with placeholder values in the output file.
|
78
84
|
- Commit & push the file to github
|
79
85
|
```
|
80
|
-
git add
|
81
|
-
git commit -m "Device simulation for
|
86
|
+
git add spec/model/data/ios:C8200L_16.12.1:simulation.yaml
|
87
|
+
git commit -m "Device simulation for C8200L"
|
82
88
|
git push
|
83
89
|
```
|
84
90
|
- Create a pull request (PR) in GitHub, referencing the issue number (e.g.,
|
data/docs/Model-Notes/APC_AOS.md
CHANGED
@@ -1,29 +1,42 @@
|
|
1
1
|
# APC AOS Configuration
|
2
2
|
|
3
|
-
|
3
|
+
The configuration of APC Network Management Cards can be downloaded using FTP
|
4
|
+
and SCP.
|
5
|
+
|
6
|
+
To download with SCP, you need a
|
7
|
+
[patch](https://github.com/net-ssh/net-scp/pull/71) to
|
8
|
+
[Net::SCP](https://github.com/net-ssh/net-scp, which has been included
|
9
|
+
upstream, but there is currently no new release of Net::SCP and its authors are
|
10
|
+
unresponsive.
|
11
|
+
|
12
|
+
To temporarily solve this,
|
13
|
+
[@robertcheramy forked Net::SCP](https://github.com/robertcheramy/net-scp). You
|
14
|
+
can build or download the gem there. This gem is already included in the
|
15
|
+
oxidized container image (in the release coming after 0.31.0).
|
4
16
|
|
5
|
-
A download of the configuration with SCP is [work in progress](https://github.com/ytti/oxidized/issues/1802).
|
6
|
-
As the APC has an unusual behavior (the connection is closed without an exit-status), this has to be
|
7
|
-
[fixed](https://github.com/net-ssh/net-scp/pull/71) upstream in [Net::SCP](https://github.com/net-ssh/net-scp).
|
8
|
-
As soon as there is a release of Net::SCP supporting the behavior of APC OS, we will activate SCP in oxidized.
|
9
17
|
|
10
18
|
## Can I collect more information than just the configuration?
|
11
|
-
APC OS does not have the ability to show the config.ini within an SSH-session.
|
12
|
-
configuration with one input type at a time, it is
|
13
|
-
|
19
|
+
APC OS does not have the ability to show the config.ini within an SSH-session.
|
20
|
+
As oxidized can only get the configuration with one input type at a time, it is
|
21
|
+
not possible to fetch config.ini via FTP/SCP and get the output of
|
22
|
+
some commands via SSH at the same time. Feature request #3334 has been opened
|
23
|
+
to support multiple inputs in oxidized.
|
24
|
+
|
25
|
+
A ticket has been opened with APC support in order to enable "cat config.ini"
|
26
|
+
within an SSH-session, but APC is not willing to support this.
|
14
27
|
|
15
|
-
A ticket has been opened with APC support in order to support "cat config.ini" within an SSH-session, but
|
16
|
-
the chances it will be supported at some time are not very good, and older versions will still not support it.
|
17
28
|
|
18
|
-
## How do I activate FTP input?
|
19
|
-
In order to download the configuration with FTP
|
20
|
-
input in the oxidized configuration. If you do not activate the input,
|
21
|
-
|
29
|
+
## How do I activate FTP/SCP input?
|
30
|
+
In order to download the configuration with FTP or SCP, you have to activate it
|
31
|
+
as an input in the oxidized configuration. If you do not activate the input,
|
32
|
+
oxidized will fail for the node with a
|
33
|
+
[rather unspecific error](https://github.com/ytti/oxidized/issues/3346)
|
34
|
+
(`WARN -- : /apc status fail, retry attempt 1`).
|
22
35
|
|
23
36
|
The configuration can be done either globally or only for the model apc_aos.
|
24
37
|
|
25
|
-
The global configuration would look like this. Note that Oxidized will try every
|
26
|
-
until it succeeds, or it will report a failure.
|
38
|
+
The global configuration would look like this. Note that Oxidized will try every
|
39
|
+
input type in the given order until it succeeds, or it will report a failure.
|
27
40
|
```yaml
|
28
41
|
input:
|
29
42
|
default: ssh, ftp, scp
|