Skip to content

Commit

Permalink
Merge branch 'ytti:master' into revert-3224-master
Browse files Browse the repository at this point in the history
  • Loading branch information
systeembeheerder authored Sep 6, 2024
2 parents c57fe9a + 26f48bd commit 0f18707
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- fortios: variable `fullconfig` to get the configuration with default values. Fixes: #3159 (@robertcheramy)
- model for VMWare NSX DFW (@elmobp)
- model for F5OS (@teunvink)
- cumulus: Add possibility to use NVUE (@lagertonne)
- model for garderos (@robertcheramy)
- unit tests framework for models with ssh input (@robertcheramy)

Expand Down
17 changes: 13 additions & 4 deletions docs/Creating-Models.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,29 @@ Intuitively, it is also possible to:
* 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.

## Create unit tests for the model
> :warning model unit tests are still work in progress and need some polishing.
If you want the model to be integrated into oxidized, you can
[submit a pull request on github](https://github.com/ytti/oxidized/pulls).
This is a greatly appreciated submission, as there are probably other users
using the same network device as you are.

We ask you to write a unit test for the model, in order to be sure further developments don't break your model, and to facilitate debugging issues without having access to a physical network device for the model. Writing a model unit test for SSH should be straightforward, and it is described in the next lines. If you encounter problems, open an issue or ask for help within the pull request.
A good practice for submissions is to provide a unit test for your model. This
reduces the risk that further developments don't break it, and facilitates
debugging issues without having access to a physical network device for the
model. Writing a model unit test for SSH is described in the next lines. Most
of the work is writing a YAML file with the commands and their output, the ruby
code itself is copy & paste with a few modifications. If you encounter
problems, open an issue or ask for help within the pull request.

You can have a look at the [Garderos unit test](spec/model/garderos_spec.rb) for an example. The model unit test consists of (at least) two files:
You can have a look at the [Garderos unit test](/spec/model/garderos_spec.rb) for an example. The model unit test
consists of (at least) two files:
- a yaml file under `examples/model/`, containing the data used to simulate the network device.
- Please name your file `<model>_<hardware type>_<software_version>.yaml`, for example in the garderos unit test: `garderos_R7709_003_006_068.yaml`.
- Please name your file `<model>_<hardware type>_<software_version>.yaml`, for example in the garderos unit test: [garderos_R7709_003_006_068.yaml](/examples/model/garderos_R7709_003_006_068.yaml).
- You can create multiple files in order to support multiple devices or software versions.
- You may append a comment after the software version to differentiate between two tested features (something like `garderos_R7709_003_006_068_with_ipsec.yaml`).
- a ruby script containing the tests under `spec/model/`.
- It is named `<model>_spec.rb`, for the garderos model: `garderos_spec.rb`.
- It is named `<model>_spec.rb`, for the garderos model: [garderos_spec.rb](/spec/model/garderos_spec.rb).
- The script described below is a minimal example; you can add as many tests as needed.

### YAML description to simulate the network device.
Expand Down
5 changes: 5 additions & 0 deletions docs/Model-Notes/Cumulus.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ A variable has been added to enable users running Cumulus Linux > 3.4.0 to targe
## NCLU
It is possible to switch to [NCLU](https://docs.nvidia.com/networking-ethernet-software/cumulus-linux-44/System-Configuration/Network-Command-Line-Utility-NCLU/) as a configuration collecting method, by setting `cumulus_use_nclu` to true

## NVUE
It is also possible to use [NVUE](https://docs.nvidia.com/networking-ethernet-software/knowledge-base/Setup-and-Getting-Started/NVUE-Cheat-Sheet/) as a configuration collecting method, by setting `cumulus_use_nvue` to true.

### Example usage

```yaml
Expand Down Expand Up @@ -43,4 +46,6 @@ The default value for `cumulus_routing_daemon` is `quagga` so existing installat

The default value for `cumulus_use_nclu` is `false`, in case NCLU is not installed.

The default value for `cumulus_use_nvue` is `false`, in case NVUE is not installed.

Back to [Model-Notes](README.md)
2 changes: 1 addition & 1 deletion lib/oxidized/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def self.load(cmd_opts = {})
raise InvalidConfig, "Error loading config: #{e.message}"
end

raise NoConfig, 'edit ~/.config/oxidized/config' if asetus.create
raise NoConfig, "edit #{ROOT}/config" if asetus.create

# override if comand line flag given
asetus.cfg.debug = cmd_opts[:debug] if cmd_opts[:debug]
Expand Down
3 changes: 3 additions & 0 deletions lib/oxidized/model/cumulus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ def add_comment(comment)
# show the persistent configuration
pre do
use_nclu = vars(:cumulus_use_nclu) || false
use_nvue = vars(:cumulus_use_nvue) || false

if use_nclu
cfg = cmd 'net show configuration commands'
elsif use_nvue
cfg = cmd 'nv config show --color off'
else
# Set FRR or Quagga in config
routing_daemon = vars(:cumulus_routing_daemon) ? vars(:cumulus_routing_daemon).downcase : 'quagga'
Expand Down
2 changes: 1 addition & 1 deletion oxidized.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'pry', '~> 0.14.2'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rubocop', '~> 1.65.1'
s.add_development_dependency 'rubocop-minitest', '~> 0.35.0'
s.add_development_dependency 'rubocop-minitest', '~> 0.36.0'
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
s.add_development_dependency 'simplecov', '~> 0.22.0'
s.add_development_dependency 'simplecov-cobertura', '~> 2.1.0'
Expand Down

0 comments on commit 0f18707

Please sign in to comment.