summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWild Kat <wk@users.noreply.github.com>2018-06-14 01:13:55 +0200
committerGitHub <noreply@github.com>2018-06-14 01:13:55 +0200
commit5ad3e9bf883f5450e8f7cba046b1f47ebd88215f (patch)
treef32b605fa251e1646ab7750f130982be41bd868e
parent5fa09b89db99b70ad5e5841b89454df6d7c3d4ce (diff)
Document model callback enhancements from #1390 (#1391)
-rw-r--r--CHANGELOG.md1
-rw-r--r--docs/Creating-Models.md24
2 files changed, 25 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1629429..a9c814f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
* FEATURE: add frr support to cumulus model (@User4574 / @bobthebutcher)
* FEATURE: honour MAX_STAT in mtime, to store last N mtime
* FEATURE: configurable stats history size
+* FEATURE: model callback enhancements for customizing existing models (@ytti)
* BUGFIX: model ciscosmb
## 0.23.0
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