oxidized 0.31.0 → 0.32.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +2 -9
  3. data/.rubocop.yml +8 -7
  4. data/.rubocop_todo.yml +6 -6
  5. data/CHANGELOG.md +40 -0
  6. data/Dockerfile +5 -2
  7. data/Rakefile +28 -0
  8. data/docs/Configuration.md +14 -2
  9. data/docs/Creating-Models.md +52 -22
  10. data/docs/DeviceSimulation.md +184 -0
  11. data/docs/Hooks.md +5 -5
  12. data/docs/Issues.md +15 -9
  13. data/docs/Model-Notes/APC_AOS.md +29 -16
  14. data/docs/Model-Notes/FSOS.md +1 -0
  15. data/docs/ModelUnitTests.md +186 -0
  16. data/docs/Release.md +18 -2
  17. data/docs/Supported-OS-Types.md +3 -2
  18. data/examples/podman-compose/Makefile +1 -2
  19. data/{examples/device-simulation → extra}/device2yaml.rb +32 -12
  20. data/extra/gitdiff-msteams.sh +32 -5
  21. data/extra/nagios_check_failing_nodes.rb +1 -1
  22. data/extra/rest_client.rb +1 -1
  23. data/lib/oxidized/config.rb +1 -1
  24. data/lib/oxidized/input/ssh.rb +13 -5
  25. data/lib/oxidized/model/aos7.rb +2 -0
  26. data/lib/oxidized/model/aosw.rb +1 -1
  27. data/lib/oxidized/model/apc_aos.rb +1 -1
  28. data/lib/oxidized/model/arubainstant.rb +1 -1
  29. data/lib/oxidized/model/asa.rb +2 -1
  30. data/lib/oxidized/model/asyncos.rb +1 -1
  31. data/lib/oxidized/model/cumulus.rb +16 -2
  32. data/lib/oxidized/model/enterprise_sonic.rb +46 -0
  33. data/lib/oxidized/model/fsos.rb +5 -1
  34. data/lib/oxidized/model/garderos.rb +4 -4
  35. data/lib/oxidized/model/junos.rb +1 -1
  36. data/lib/oxidized/model/kornfeldos.rb +33 -0
  37. data/lib/oxidized/model/model.rb +2 -2
  38. data/lib/oxidized/model/powerconnect.rb +1 -1
  39. data/lib/oxidized/model/sonicos.rb +8 -2
  40. data/lib/oxidized/model/tplink.rb +1 -0
  41. data/lib/oxidized/model/xos.rb +1 -1
  42. data/lib/oxidized/source/source.rb +32 -2
  43. data/lib/oxidized/version.rb +2 -2
  44. data/oxidized.gemspec +21 -11
  45. metadata +47 -71
  46. data/examples/device-simulation/README.md +0 -173
  47. data/examples/device-simulation/cmdsets/aoscx +0 -9
  48. data/examples/device-simulation/cmdsets/arubainstant +0 -5
  49. data/examples/device-simulation/cmdsets/asa +0 -7
  50. data/examples/device-simulation/cmdsets/ios +0 -7
  51. data/examples/device-simulation/cmdsets/nxos +0 -5
  52. data/examples/device-simulation/cmdsets/routeros +0 -5
  53. data/examples/device-simulation/cmdsets/srosmd +0 -11
  54. data/examples/device-simulation/yaml/aoscx_R0X25A-6410_FL.10.10.1100.yaml +0 -2281
  55. data/examples/device-simulation/yaml/aoscx_R8N85A-C6000-48G-CL4_PL.10.08.1010.yaml +0 -451
  56. data/examples/device-simulation/yaml/arubainstant_IAP515_8.10.0.6_VWLC.yaml +0 -213
  57. data/examples/device-simulation/yaml/asa_5512_9.12-4-67_single-context.yaml +0 -531
  58. data/examples/device-simulation/yaml/asr920_16.8.1b.yaml +0 -1122
  59. data/examples/device-simulation/yaml/garderos_R7709_003_006_068.yaml +0 -101
  60. data/examples/device-simulation/yaml/iosxe_C9200L-24P-4G_17.09.04a.yaml +0 -514
  61. data/examples/device-simulation/yaml/iosxe_C9800-L-F-K9_17.06.05.yaml +0 -417
  62. data/examples/device-simulation/yaml/riverbed_915.yaml +0 -123
  63. data/examples/device-simulation/yaml/routeros_CHR_7.10.1.yaml +0 -145
  64. data/examples/device-simulation/yaml/routeros_CHR_7.16.yaml +0 -79
  65. data/examples/device-simulation/yaml/routeros_L009UiGS_7.15.2.yaml +0 -353
@@ -1,173 +0,0 @@
1
- # Device simulation
2
- Oxidized supports [150+ devices](/docs/Supported-OS-Types.md).
3
- No developer has access to all of these devices, which makes the task of
4
- maintaining Oxidized difficult:
5
-
6
- - issues can't be resolved because the developer has no access to the device.
7
- - further developments can produce regressions.
8
-
9
- In order to address this, we can simulate the devices. An example for a
10
- simulation are the [model unit tests](/spec/model) but one could also simulate
11
- a device within a ssh server.
12
-
13
- The simulation of devices is currently focused on ssh-based devices. This may
14
- be extended to other inputs like telnet or ftp in the future.
15
-
16
- ## YAML Simulation Data
17
- The underlying data for the simulation is a [YAML](https://yaml.org/) file in
18
- which we store all relevant information about the device. The most important
19
- information is the responses to the commands used in the oxidized models.
20
-
21
- The YAML simulation files are stored under
22
- [/examples/device-simulation/yaml/](/examples/device-simulation/yaml/).
23
-
24
- ### Creating a YAML file with device2yaml.rb
25
- A device does not only output the ASCII text we can see in the console.
26
- It adds ANSI-escape code for nice colors, bold and underline, \r and so on.
27
- These are key factors in prompt issues so they must be represented in the YAML
28
- file. We use the ruby string format with interpolations like \r \e and so on.
29
- Another important point is trailing spaces at the end of lines. Some text
30
- editors automatically remove trailing spaces, so we code them with \x20.
31
-
32
- Although a YAML file could be written by hand, this is quite a tedious task to
33
- catch all the extra codes and code them into YAML. This can be
34
- automated with the ruby script
35
- [device2yaml.rb](/examples/device-simulation/device2yaml.rb).
36
-
37
- `device2yaml.rb` needs ruby and the gem
38
- [net-ssh](https://rubygems.org/gems/net-ssh/) to run. On debian, you can install
39
- them with `sudo apt install ruby-net-ssh`
40
-
41
- Run `device2yaml.rb` in the directory `/examples/device-simulation/`, the
42
- online help tells you the options.
43
- ```
44
- device-simulation$ ./device2yaml.rb
45
- Missing a host to connect to...
46
-
47
- Usage: device2yaml.rb [user@]host [options]
48
- -c, --cmdset file Mandatory: specify the commands to be run
49
- -o, --output file Specify an output YAML-file
50
- -t, --timeout value Specify the idle timeout beween commands (default: 5 seconds)
51
- -e, --exec-mode Run ssh in exec mode (without tty)
52
- -h, --help Print this help
53
- ```
54
-
55
- - `[user@]host` specifies the user and host to connect to the device. The
56
- password will be prompted interactively by the script. If you do not specify a
57
- user, it will use the user executing the script.
58
- - You must list the commands you want to run on the device in a file. Just
59
- enter one command per line. It is important that you enter exactly the commands
60
- used by the oxidized model, and no abbreviation like `sh run`. Do not forget
61
- to insert the `post_login` commands at the beginning if the model has some and
62
- also the `pre_logout`commands at the end.
63
- Predefined command sets for some models are stored in
64
- `/examples/device-simulation/cmdsets`.
65
- - `device2yaml.rb` waits an idle timeout after the last received data before
66
- sending the next command. The default is 5 seconds. If your device makes a
67
- longer pause than 5 seconds before or within a command, you will see that the
68
- output of the command is shortened or slips into the next command in the yaml
69
- file. You will have to change the idle timeout to a greater value to address
70
- this.
71
- - When run without the output argument, `device2yaml.rb` will only print the ssh
72
- output to the standard output. You must use `-o <model_HW_SW.yaml>` to store the
73
- collected data in a YAML file.
74
- - If your oxidized model uses ssh exec mode (look for `exec true` in the model),
75
- you will have to use the option `-e` to run device2yaml in ssh exec mode.
76
-
77
- Note that `device2yaml.rb` takes some time to run because of the idle
78
- timeout of (default) 5 seconds between each command. You can press the "Escape"
79
- key if you know there is no more data to come for the current command (when you
80
- see the prompt for the next command), and the script will stop waiting and
81
- directly process the next command.
82
-
83
- Here are two examples of how to run the script:
84
- ```shell
85
- ./device2yaml.rb OX-SW123.sample.domain -c cmdsets/aoscx -o yaml/aoscx_R8N85A-C6000-48G-CL4_PL.10.08.1010.yaml
86
- ./device2yaml.rb admin@r7 -c cmdsets/routeros -e -o yaml/routeros_CHR_7.10.1.yaml
87
- ```
88
-
89
- ### Publishing the YAML simulation file to oxidized
90
- Publishing the YAML simulation file of your device helps maintain oxidized.
91
- This task may take some time, and we are very grateful that you take this time
92
- for the community!
93
-
94
- You should pay attention to removing or replacing anything you don't want to
95
- share with the rest of the world, for example:
96
-
97
- - Passwords
98
- - IP Adresses
99
- - Serial numbers
100
-
101
- You can also shorten the configuration if you want - we don't need 48 times the
102
- same config for each interface, but it doesn't hurt either.
103
-
104
- Take your time, this is an important task: after you have
105
- uploaded your file on github, it may be impossible to remove it. You can use
106
- search/replace to make consistent and faster changes (change the hostname).
107
-
108
- You can leave the section `oxidized_output` unchanged, it is only used for
109
- [model unit tests](/spec/model). You will find an explanation of how to produce
110
- the `oxidized_output`-section in the README.md there.
111
-
112
- The YAML simulation file should be stored under
113
- [/examples/device-simulation/yaml/](/examples/device-simulation/yaml/. It
114
- should be named so that it can be easily recognized: model, hardware type,
115
- software version and optionally a description if you need to differentiate two
116
- YAML files:
117
-
118
- - #model_#hardware_#software.yaml
119
- - #model_#hardware_#software_#description.yaml
120
-
121
- Examples:
122
-
123
- - garderos_R7709_003_006_068.yaml
124
- - iosxe_C9200L-24P-4G_17.09.04a.yaml
125
- - asa_5512_9.12-4-67_single-context.yaml
126
-
127
- ### Interactive mode
128
- The `device2yaml.rb` script is a little dumb and needs some help, especially
129
- when having a device sending its output page by page and requiring you to press
130
- space for the next page. `device2yaml.rb` does not know how to handle this.
131
-
132
- While `device2yaml.rb` is running, you can type anything to the keyboard, it
133
- will be send to the remote device. So you can press space or 'n' to get the
134
- next page.
135
-
136
- You can also use this to enter an enable password.
137
-
138
- If you press the "Esc" key, `device2yaml.rb` will not wait for the idle timeout
139
- and will process the next command right away.
140
-
141
- ### YAML Format
142
- The yaml file has three sections:
143
- - init_prompt: describing the lines send by the device before we can send a
144
- command. It usually includes MOTD banners, and must include the first prompt.
145
- - commands: the commands the oxidized model sends to the network device and the
146
- expected output.
147
- - oxidized_output: the expected output of oxidized, so that you can compare it
148
- to the output generated by the unit test. This is optional and only used for
149
- unit tests.
150
-
151
- The outputs are multiline and use YAML block scalars (`|`), with the trailing \n
152
- removed (`-` after `|`). The outputs include the echo of the given command and
153
- the next prompt. Escape characters are coded in Ruby style (\n, \r...).
154
-
155
- Here is a shortened example of a YAML file:
156
- ```yaml
157
- ---
158
- init_prompt: |-
159
- \e[4m\rLAB-R1234_Garderos#\e[m\x20
160
- commands:
161
- show system version: |-
162
- show system version
163
- grs-gwuz-armel/003_005_068 (Garderos; 2021-04-30 16:19:35)
164
- \e[4m\rLAB-R1234_Garderos#\e[m\x20
165
- # ...
166
- exit: ""
167
- oxidized_output: |
168
- # grs-gwuz-armel/003_005_068 (Garderos; 2021-04-30 16:19:35)
169
- #\x20
170
- # ...
171
- ```
172
-
173
-
@@ -1,9 +0,0 @@
1
- no page
2
- show version
3
- show environment
4
- show module
5
- show interface transceiver
6
- show system | exclude "Up Time" | exclude "CPU" | exclude "Memory" | exclude "Pkts .x" | exclude "Lowest" | exclude "Missed"
7
- show running-config
8
- show system
9
- exit
@@ -1,5 +0,0 @@
1
- show version
2
- show activate status
3
- show aps
4
- show running-config no-encrypt
5
- exit
@@ -1,7 +0,0 @@
1
- enable
2
- terminal pager 0
3
- show mode
4
- show version
5
- show inventory
6
- more system:running-config
7
- exit
@@ -1,7 +0,0 @@
1
- terminal length 0
2
- terminal width 0
3
- show version
4
- show vtp status
5
- show inventory
6
- show running-config
7
- exit
@@ -1,5 +0,0 @@
1
- terminal length 0
2
- show version
3
- show inventory
4
- show running-config
5
- exit
@@ -1,5 +0,0 @@
1
- /system resource print
2
- /system package update print
3
- /system history print without-paging
4
- /export show-sensitive
5
- quit
@@ -1,11 +0,0 @@
1
- environment more false
2
- show system information
3
- show card state
4
- show chassis
5
- file show bootlog.txt
6
- admin show configuration debug full-context
7
- file show config.dbg
8
- admin show configuration configure | match persistent-indices post-lines 10000
9
- admin show configuration bof full-context
10
- admin show configuration configure full-context
11
- logout