diff options
-rw-r--r-- | README.md | 93 | ||||
-rw-r--r-- | lib/oxidized/model/iosxr.rb | 1 |
2 files changed, 89 insertions, 5 deletions
@@ -1094,12 +1094,95 @@ The following objects exist in Oxidized. * 'sql', 'csv' and 'http' (supports any format with single entry per line, like router.db) ## Model - * lists commands to gather from given device model - * can use 'cmd', 'prompt', 'comment', 'cfg' - * cfg is executed in input/output/source context - * cmd is executed in instance of model - * 'junos', 'ios', 'ironware' and 'powerconnect' implemented +### At the top level +A model may use several methods at the top level in the class. `cfg` is +executed in input/output/source context. `cmd` is executed within an instance +of the model. +#### `cfg` +`cfg` may be called with a list of methods (`:ssh`, `:telnet`) and a block with +zero parameters. Calling `cfg` registers the given access methods and calling +it at least once is required for a model to work. + +The block may contain commands to change some behaviour for the given methods +(e.g. calling `post_login` to disable the pager). + +#### `cmd` +Is used to specify commands that should be executed on a model in order to +gather its configuration. It can be called with: + +* Just a string +* A string and a block +* `:all` and a block +* `:secret` and a block + +The block takes a single parameter `cfg` containing the output of the command +being processed. + +Calling `cmd` with just a string will emit the output of the command given in +that string as configuration. + +Calling `cmd` with a string and a block will pass the output of the given +command to the block, then emit its return value (that must be a string) as +configuration. + +Calling `cmd` with `:all` and a block will pass all command output through this +block before emitting it. This is useful if some cleanup is required of the +output of all commands. + +Calling `cmd` with `:secret` and a block will pass all configuration to the +given block before emitting it to hide secrets if secret hiding is enabled. The +block should replace any secrets with `'<hidden>'` and return the resulting +string. + +Execution order is `:all`, `:secret`, and lastly the command specific block, if +given. + +#### `comment` +Called with a single string containing the string to prepend for comments in +emitted configuration for this model. + +If not specified the default of `'# '` will be used (note the trailing space). + +#### `prompt` +Is called with a regular expression that is used to detect when command output +ends after a command has been executed. + +If not specified, a default of `/^([\w.@-]+[#>]\s?)$/` is used. + +#### `expect` +Called with a regular expression and a block. The block takes two parameters: +the regular expression, and the data containing the match. + +The passed data is replaced by the return value of the block. + +`expect` can be used to, for example, strip escape sequences from output before +it's further processed. + +### At the second level +The following methods are available: + +#### `comment` +Used inside `cmd` invocations. Comments out every line in the passed string and +returns the result. + +#### `password` +Used inside `cfg` invocations to specify the regular expression used to detect +the password prompt. If not specified, the default of `/^Password/` is used. + +#### `post_login` +Used inside `cfg` invocations to specify commands to run once Oxidized has +logged in to the switch. Takes one argument that is either a block (taking zero +parameters) or a string containing a command to execute. + +#### `pre_logout` +Used to specify commands to run before Oxidized closes the connection to the +switch. Takes one argument that is either a block (taking zero parameters) or a +string containing a command to execute. + +#### `send` +Usually used inside `expect` or blocks passed to `post_login`/`pre_logout`. +Takes a single parameter: a string to be sent to the switch. # Help Needed diff --git a/lib/oxidized/model/iosxr.rb b/lib/oxidized/model/iosxr.rb index bf01140..ac2f798 100644 --- a/lib/oxidized/model/iosxr.rb +++ b/lib/oxidized/model/iosxr.rb @@ -36,6 +36,7 @@ class IOSXR < Oxidized::Model cfg :telnet, :ssh do post_login 'terminal length 0' post_login 'terminal width 0' + post_login 'terminal exec prompt no-timestamp' if vars :enable post_login do send "enable\n" |