summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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