diff options
author | Wild Kat <wk@users.noreply.github.com> | 2018-06-14 01:13:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-14 01:13:55 +0200 |
commit | 5ad3e9bf883f5450e8f7cba046b1f47ebd88215f (patch) | |
tree | f32b605fa251e1646ab7750f130982be41bd868e /docs | |
parent | 5fa09b89db99b70ad5e5841b89454df6d7c3d4ce (diff) |
Document model callback enhancements from #1390 (#1391)
Diffstat (limited to 'docs')
-rw-r--r-- | docs/Creating-Models.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/Creating-Models.md b/docs/Creating-Models.md index 3cb87c3..317ba14 100644 --- a/docs/Creating-Models.md +++ b/docs/Creating-Models.md @@ -76,3 +76,27 @@ end ``` The output of the `show configuration | display set` command is marked with a new arbitrary alternative output type, `junos-set`. The `git` output will use the output type to create a new subdirectory by the same name. In this subdirectory, the `git` output will create files with the name `<devicename>--set` that will contain the output of this command for each device. + +## Monkey-patching blocks in existing models + +In addition to adding new commands and blocks to existing models, Oxidized offers convenience methods for monkey-patching existing commands and blocks within existing models. + +When defining a monkey-patched block, two boolean arguments can be passed as part of the block definition: + +* `clear: true`, which resets the existing block, allowing the user to completely override its contents. +* `prepend: true`, which ensures that the contents of the block are prepended, rather than appended (the default) to an existing block. + +This functionality is supported for `cfg`, `cmd`, `pre`, `post`, and `expect` blocks. + +Examples: + +```ruby +cmd :secret clear: true do + ... "(new code for secret removal which replaces the existing :secret definition in the model)" ... +end +``` + +```ruby +cmd :ssh do prepend: true do + ... "(code that should run first, before any code in the existing :ssh definition in the model)" ... +end |