From 5ad3e9bf883f5450e8f7cba046b1f47ebd88215f Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Thu, 14 Jun 2018 01:13:55 +0200 Subject: Document model callback enhancements from #1390 (#1391) --- docs/Creating-Models.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'docs') 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 `--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 -- cgit v1.2.1