From 6890754f0a579fc9be3912113dcfe510b2837f7c Mon Sep 17 00:00:00 2001 From: CppMonkey Date: Thu, 1 Feb 2018 17:39:00 +0000 Subject: Initial commit for SSH/Telnet on Xyzel XGS4600 series --- docs/Model-Notes/README.md | 2 +- docs/Model-Notes/XGS4600-Zyxel.md | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/Model-Notes/README.md b/docs/Model-Notes/README.md index f51ed80..a2ac681 100644 --- a/docs/Model-Notes/README.md +++ b/docs/Model-Notes/README.md @@ -13,7 +13,7 @@ Vendor | Model |Updated ----------------|-----------------|---------------- Huawei|[VRP](VRP-Huawei.md)|17 Nov 2017 Juniper|[MX/QFX/EX/SRX/J Series](JunOS.md)|18 Jan 2018 -Xyzel|[XGS4600 Series](XGS4600-Zyxel.md)|23 Jan 2018 +Xyzel|[XGS4600 Series](XGS4600-Zyxel.md)|1 Feb 2018 If you discover additional caveats or problems please make sure to consult the [GitHub issues for oxidized](https://github.com/ytti/oxidized/issues) known issues. diff --git a/docs/Model-Notes/XGS4600-Zyxel.md b/docs/Model-Notes/XGS4600-Zyxel.md index 0ff2e7d..6fb6daf 100644 --- a/docs/Model-Notes/XGS4600-Zyxel.md +++ b/docs/Model-Notes/XGS4600-Zyxel.md @@ -18,6 +18,23 @@ input: passive: false ``` + +## SSH/TelNet + +Below is the table from the XGS4600 CLI Reference Guide (Version 3.79~4.50 Edition 1, 07/2017) +Take this table with a pink of salt, level 3 will not allow _show running-config_! +Privilege Level | Types of commands at this privilege level +----------------|------------------------------------------- +0|Display basic system information. +3|Display configuration or status. +13|Configure features except for login accounts, SNMP user accounts, the authentication +method sequence and authorization settings, multiple logins, administrator and enable +passwords, and configuration information display. +14|Configure login accounts, SNMP user accounts, the authentication method sequence and +authorization settings, multiple logins, and administrator and enable passwords, and display +configuration information. + + Oxidized can now retrieve your configuration! -- cgit v1.2.3 From 058bf1d9d19ddbcebd304c56c0a0aec1a271a036 Mon Sep 17 00:00:00 2001 From: CppMonkey Date: Thu, 1 Feb 2018 17:43:55 +0000 Subject: Fixed privilege table not displaying correctly --- docs/Model-Notes/XGS4600-Zyxel.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/Model-Notes/XGS4600-Zyxel.md b/docs/Model-Notes/XGS4600-Zyxel.md index 6fb6daf..072ac1a 100644 --- a/docs/Model-Notes/XGS4600-Zyxel.md +++ b/docs/Model-Notes/XGS4600-Zyxel.md @@ -23,6 +23,7 @@ input: Below is the table from the XGS4600 CLI Reference Guide (Version 3.79~4.50 Edition 1, 07/2017) Take this table with a pink of salt, level 3 will not allow _show running-config_! + Privilege Level | Types of commands at this privilege level ----------------|------------------------------------------- 0|Display basic system information. -- cgit v1.2.3 From 70b83e31ae40662b2d93aae0b7491af2464aaef1 Mon Sep 17 00:00:00 2001 From: KodApa85 Date: Thu, 1 Feb 2018 17:49:32 +0000 Subject: removed return characters, fixing the table --- docs/Model-Notes/XGS4600-Zyxel.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/Model-Notes/XGS4600-Zyxel.md b/docs/Model-Notes/XGS4600-Zyxel.md index 072ac1a..33953ea 100644 --- a/docs/Model-Notes/XGS4600-Zyxel.md +++ b/docs/Model-Notes/XGS4600-Zyxel.md @@ -28,12 +28,8 @@ Privilege Level | Types of commands at this privilege level ----------------|------------------------------------------- 0|Display basic system information. 3|Display configuration or status. -13|Configure features except for login accounts, SNMP user accounts, the authentication -method sequence and authorization settings, multiple logins, administrator and enable -passwords, and configuration information display. -14|Configure login accounts, SNMP user accounts, the authentication method sequence and -authorization settings, multiple logins, and administrator and enable passwords, and display -configuration information. +13|Configure features except for login accounts, SNMP user accounts, the authentication method sequence and authorization settings, multiple logins, administrator and enable passwords, and configuration information display. +14|Configure login accounts, SNMP user accounts, the authentication method sequence and authorization settings, multiple logins, and administrator and enable passwords, and display configuration information. Oxidized can now retrieve your configuration! -- cgit v1.2.3 From 7c108b6b7a3277aac44455b93a587d1d01a58041 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Mon, 5 Feb 2018 21:55:31 +0000 Subject: Added support for setting ssh auth methods --- docs/Configuration.md | 9 +++++++++ docs/Model-Notes/EOS.md | 9 +++++++++ docs/Model-Notes/README.md | 1 + lib/oxidized/input/ssh.rb | 5 ++++- lib/oxidized/worker.rb | 6 +++++- 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 docs/Model-Notes/EOS.md (limited to 'docs') diff --git a/docs/Configuration.md b/docs/Configuration.md index e2db05e..d0afdf6 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -59,6 +59,15 @@ vars: ssh_no_exec: true ``` +### SSH Auth Methods + +By default, Oxidized registers the following auth methods: `none`, `publickey` and `password`. However you can configure this globally, by groups, models or nodes. + +``` +vars: + auth_methods: none, publickey, password, keyboard-interactive +``` + ### SSH Proxy Command Oxidized can `ssh` through a proxy as well. To do so we just need to set `ssh_proxy` variable. diff --git a/docs/Model-Notes/EOS.md b/docs/Model-Notes/EOS.md new file mode 100644 index 0000000..66287e3 --- /dev/null +++ b/docs/Model-Notes/EOS.md @@ -0,0 +1,9 @@ +Arista EOS Configuration +======================== + +By default EOS requires keyboard-interactive to be added to your Oxidized config. You can avoid having to do this by configuring the following on the EOS device: + +``` +management ssh + authentication mode password +``` diff --git a/docs/Model-Notes/README.md b/docs/Model-Notes/README.md index f51ed80..636c9fa 100644 --- a/docs/Model-Notes/README.md +++ b/docs/Model-Notes/README.md @@ -11,6 +11,7 @@ Use the table below for more information on the Vendor/Model caveats. Vendor | Model |Updated ----------------|-----------------|---------------- +Arista|[EOS](EOS.md)|05 Feb 2018 Huawei|[VRP](VRP-Huawei.md)|17 Nov 2017 Juniper|[MX/QFX/EX/SRX/J Series](JunOS.md)|18 Jan 2018 Xyzel|[XGS4600 Series](XGS4600-Zyxel.md)|23 Jan 2018 diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index 27e81e0..8df18f5 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -29,10 +29,13 @@ module Oxidized :port => port.to_i, :password => @node.auth[:password], :timeout => Oxidized.config.timeout, :paranoid => secure, - :auth_methods => %w(none publickey password keyboard-interactive), :number_of_password_prompts => 0, } + auth_methods = vars(:auth_methods) || %w(none publickey password) + ssh_opts[:auth_methods] = auth_methods + Oxidized.logger.info "AUTH METHODS::#{auth_methods}" + if proxy_host = vars(:ssh_proxy) proxy_command = "ssh " proxy_command += "-o StrictHostKeyChecking=no " unless secure diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index 4173680..062233b 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -80,7 +80,11 @@ module Oxidized private def is_cycle_finished? - @jobs_done > 0 && @jobs_done % @nodes.count == 0 + if @jobs_done > @nodes.count + true + else + @jobs_done > 0 && @jobs_done % @nodes.count == 0 + end end def run_done_hook -- cgit v1.2.3 From baee367bfec7ec5241ad7e893de7df8ea7eec1e7 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 27 Feb 2018 14:10:14 +0000 Subject: Added model to Supported-OS-Types --- docs/Supported-OS-Types.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index c2035b0..683a022 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -133,6 +133,8 @@ * [Quanta / VxWorks 6.6 (1.1.0.8)](/lib/oxidized/model/quantaos.rb) * Siklu * [EtherHaul](/lib/oxidized/model/siklu.rb) + * SNR + * [SNR](/lib/oxidized/model/snr.rb) * Supermicro * [Supermicro](/lib/oxidized/model/supermicro.rb) * Symantec -- cgit v1.2.3 From 1b2a5721b66fbc11a182da1bd11fb7f7eb1b0e9b Mon Sep 17 00:00:00 2001 From: CppMonkey Date: Tue, 20 Mar 2018 09:51:15 +0000 Subject: Merged latest changes from ytti/oxidized --- docs/Model-Notes/README.md | 14 ++++++-------- docs/Model-Notes/XGS4600-Zyxel.md | 12 +++++++----- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'docs') diff --git a/docs/Model-Notes/README.md b/docs/Model-Notes/README.md index a2ac681..12133fb 100644 --- a/docs/Model-Notes/README.md +++ b/docs/Model-Notes/README.md @@ -1,19 +1,17 @@ - - Model Notes -======================== - +=========== -This directory contains implemention notes and caveats to assist you in your oxidized deployment. +This directory contains implementation notes and caveats to assist you in your oxidized deployment. Use the table below for more information on the Vendor/Model caveats. - Vendor | Model |Updated ----------------|-----------------|---------------- +3COM|[Comware](Comware.md)|15 Feb 2018 +AireOS|[AireOS](AireOS.md)|29 Nov 2017 +Arbor Networks|[ArbOS](ArbOS.md)|27 Feb 2018 Huawei|[VRP](VRP-Huawei.md)|17 Nov 2017 Juniper|[MX/QFX/EX/SRX/J Series](JunOS.md)|18 Jan 2018 -Xyzel|[XGS4600 Series](XGS4600-Zyxel.md)|1 Feb 2018 - +Zyxel|[XGS4600 Series](XGS4600-Zyxel.md)|1 Feb 2018 If you discover additional caveats or problems please make sure to consult the [GitHub issues for oxidized](https://github.com/ytti/oxidized/issues) known issues. diff --git a/docs/Model-Notes/XGS4600-Zyxel.md b/docs/Model-Notes/XGS4600-Zyxel.md index 33953ea..3c69cee 100644 --- a/docs/Model-Notes/XGS4600-Zyxel.md +++ b/docs/Model-Notes/XGS4600-Zyxel.md @@ -1,18 +1,20 @@ ZynOS Configuration -======================== +=================== ## FTP + FTP access is only possible as admin, other users can login but cannot pull the files. For the XGS4600 series the config file is _config_ and not _config-0_ -The following line in _oxidized/lib/oxidized/model/zynos.rb_ with need changing -``` - cmd 'config-0' +The following line in _oxidized/lib/oxidized/model/zynos.rb_ will need changing +```text + cmd 'config-0' ``` The inclusion of an extra ftp option is also require. Within _input_ add the following -``` + +```yaml input: ftp: passive: false -- cgit v1.2.3 From 3f8bd19e144d026d0d14ed0f26a6c7c2339bd17a Mon Sep 17 00:00:00 2001 From: Ilya Demyanov Date: Thu, 5 Apr 2018 19:06:23 +0300 Subject: docs: Fixed the link to SNR model --- docs/Supported-OS-Types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 5240297..7a765f8 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -139,7 +139,7 @@ * Siklu * [EtherHaul](/lib/oxidized/model/siklu.rb) * SNR - * [SNR-S300G, S2xxx, S3xxx, S4xxx](/lib/oxidized/dcnos.rb) + * [SNR-S300G, S2xxx, S3xxx, S4xxx](/lib/oxidized/model/dcnos.rb) * Supermicro * [SSE-G2252, G2252P](/lib/oxidized/model/edgecos.rb) * [SSE-G48-TG4, G24-TG4](/lib/oxidized/model/aricentiss.rb) -- cgit v1.2.3 From 30894a5015e6ce780096bd965493913133197c14 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 7 Apr 2018 01:49:05 +0200 Subject: extend githubrepo documentation --- docs/Hooks.md | 51 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) (limited to 'docs') diff --git a/docs/Hooks.md b/docs/Hooks.md index 8a0a8b9..b582a2f 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -9,7 +9,7 @@ Following configuration keys need to be defined for all hooks: * `events`: which events to subscribe. Needs to be an array. See below for the list of available events. * `type`: what hook class to use. See below for the list of available hook types. -### Events +## Events * `node_success`: triggered when configuration is successfully pulled from a node and right before storing the configuration. * `node_fail`: triggered after `retries` amount of failed node pulls. @@ -44,7 +44,7 @@ Exec hook recognizes following configuration keys: * `async`: influences whether main thread will wait for the command execution. Set this true for long running commands so node pull is not blocked. Default: false * `cmd`: command to run. -## exec hook configuration example +### exec hook configuration example ```yaml hooks: @@ -60,21 +60,29 @@ hooks: timeout: 120 ``` -### Hook type: githubrepo +## Hook type: githubrepo -This hook configures the repository `remote` and _push_ the code when the specified event is triggered. If the `username` and `password` are not provided, the `Rugged::Credentials::SshKeyFromAgent` will be used. +The `githubrepo` hook executes a `git push` to a configured `remote_repo` when the specified event is triggered. -`githubrepo` hook recognizes following configuration keys: +Several authentication methods are supported: + +* Provide a `password` for username + password authentication +* Provide both a `publickey` and a `privatekey` for ssh key-based authentication +* Don't provide any credentials for ssh-agent authentication + +The username will be set to the relevant part of the `remote_repo` URI, with a fallback to `git`. It is also possible to provide one by setting the `username` configuration key. + +For ssh key-based authentication, it is possible to set the environment variable `OXIDIZED_SSH_PASSPHRASE` to a passphrase if the private key requires it. + +`githubrepo` hook recognizes the following configuration keys: * `remote_repo`: the remote repository to be pushed to. * `username`: username for repository auth. * `password`: password for repository auth. -* `publickey`: publickey for repository auth. -* `privatekey`: privatekey for repository auth. +* `publickey`: public key for repository auth. +* `privatekey`: private key for repository auth. -It is also possible to set the environment variable `OXIDIZED_SSH_PASSPHRASE` to a passphrase if your keypair requires it. - -When using groups repositories, each group must have its own `remote` in the `remote_repo` config. +When using groups, each group must have a unique entry in the `remote_repo` config. ```yaml hooks: @@ -85,7 +93,9 @@ hooks: firewalls: git@git.intranet:oxidized/firewalls.git ``` -## githubrepo hook configuration example +### githubrepo hook configuration example + +Authenticate with the username `git` and a password: ```yaml hooks: @@ -93,10 +103,21 @@ hooks: type: githubrepo events: [post_store] remote_repo: git@git.intranet:oxidized/test.git - username: user password: pass ``` +Authenticate with the username `git` and an ssh key: + +```yaml +hooks: + push_to_remote: + type: githubrepo + events: [post_store] + remote_repo: git@git.intranet:oxidized/test.git + publickey: /root/.ssh/id_rsa.pub + privatekey: /root/.ssh/id_rsa +``` + ## Hook type: awssns The `awssns` hook publishes messages to AWS SNS topics. This allows you to notify other systems of device configuration changes, for example a config orchestration pipeline. Multiple services can subscribe to the same AWS topic. @@ -108,7 +129,7 @@ Fields sent in the message: * `model`: Model name (e.g. `eos`) * `node`: Device hostname -## awssns hook configuration example +### awssns hook configuration example ```yaml hooks: @@ -136,7 +157,7 @@ You will need to manually install the `slack-api` gem on your system: gem install slack-api ``` -## slackdiff hook configuration example +### slackdiff hook configuration example ```yaml hooks: @@ -172,7 +193,7 @@ You will need to manually install the `xmpp4r` gem on your system: gem install xmpp4r ``` -## xmppdiff hook configuration example +### xmppdiff hook configuration example ```yaml hooks: -- cgit v1.2.3 From bb7b89f0db0c73650e0d1ac035d8441a0cb2e94f Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 7 Apr 2018 01:57:08 +0200 Subject: improve githubrepo auth example --- docs/Hooks.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/Hooks.md b/docs/Hooks.md index b582a2f..fb80a19 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -95,7 +95,7 @@ hooks: ### githubrepo hook configuration example -Authenticate with the username `git` and a password: +Authenticate with a username and a password: ```yaml hooks: @@ -103,6 +103,7 @@ hooks: type: githubrepo events: [post_store] remote_repo: git@git.intranet:oxidized/test.git + username: user password: pass ``` -- cgit v1.2.3 From 09bcf46e276662ef518aac5fb11bc2eb4e127d36 Mon Sep 17 00:00:00 2001 From: rgnv Date: Thu, 12 Apr 2018 15:22:50 -0700 Subject: Added Cisco Spark hook --- README.md | 1 + docs/Hooks.md | 37 +++++++++++++++++++++++++ lib/oxidized/hook/ciscosparkdiff.rb | 54 +++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 lib/oxidized/hook/ciscosparkdiff.rb (limited to 'docs') diff --git a/README.md b/README.md index ebe3d43..4a389f3 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Check out the [Oxidized TREX 2014 presentation](http://youtu.be/kBQ_CTUuqeU#t=3h * [Hook: awssns](docs/Hooks.md#hook-type-awssns) * [Hook: slackdiff](docs/Hooks.md#hook-type-slackdiff) * [Hook: xmppdiff](docs/Hooks.md#hook-type-xmppdiff) + * [Hook: ciscosparkdiff](docs/Hooks.md#hook-type-ciscosparkdiff) 5. [Creating and Extending Models](docs/Creating-Models.md) 6. [Help](#help) 7. [Ruby API](docs/Ruby-API.md#ruby-api) diff --git a/docs/Hooks.md b/docs/Hooks.md index fb80a19..d1b6925 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -184,6 +184,43 @@ hooks: Note the channel name must be in quotes. +## Hook type: ciscosparkdiff + +The `ciscosparkdiff` hook posts config diffs to a [Cisco Spark](https://www.ciscospark.com/) space of your choice. It only triggers for `post_store` events. + +You will need to manually install the `cisco_spark` gem on your system (see [cisco_spark-ruby](https://github.com/NGMarmaduke/cisco_spark-ruby): + +```shell +gem install cisco_spark +``` + +### ciscosparkdiff hook configuration example + +```yaml +hooks: + ciscospark: + type: ciscosparkdiff + events: [post_store] + accesskey: [SPARK_BOT_API_OR_OAUTH_KEY](https://developer.ciscospark.com/apps.html) + space: [SPARK_SPACE_ID](https://developer.ciscospark.com/endpoint-rooms-get.html) + diff: true +``` + +Optionally you can disable snippets and post a formatted message, for instance linking to a commit in a git repo. Named parameters `%{node}`, `%{group}`, `%{model}` and `%{commitref}` are available. + +```yaml +hooks: + ciscospark: + type: ciscosparkdiff + events: [post_store] + accesskey: [SPARK_BOT_API_OR_OAUTH_KEY](https://developer.ciscospark.com/apps.html) + space: [SPARK_SPACE_ID](https://developer.ciscospark.com/endpoint-rooms-get.html) + diff: false + message: "%{node} %{group} %{model} updated https://git.intranet/network-changes/commit/%{commitref}" +``` + +Note the space and access tokens must be in quotes. + ## Hook type: xmppdiff The `xmppdiff` hook posts config diffs to a [XMPP](https://en.wikipedia.org/wiki/XMPP) chatroom of your choice. It only triggers for `post_store` events. diff --git a/lib/oxidized/hook/ciscosparkdiff.rb b/lib/oxidized/hook/ciscosparkdiff.rb new file mode 100644 index 0000000..a1c9130 --- /dev/null +++ b/lib/oxidized/hook/ciscosparkdiff.rb @@ -0,0 +1,54 @@ +require 'cisco_spark' + +# defaults to posting a diff, if messageformat is supplied them a message will be posted too +# diffenable defaults to true +# Modified from slackdiff + +class CiscoSparkDiff < Oxidized::Hook + def validate_cfg! + raise KeyError, 'hook.accesskey is required' unless cfg.has_key?('accesskey') + raise KeyError, 'hook.space is required' unless cfg.has_key?('space') + end + + def run_hook(ctx) + if ctx.node + if ctx.event.to_s == "post_store" + log "Connecting to Cisco Spark" + CiscoSpark.configure do |config| + config.api_key = cfg.accesskey + config.proxy = cfg.proxy if cfg.has_key?('proxy') + end + space = cfg.space + client = CiscoSpark::Room.new(id: space) + client.fetch + log "Connected" + # diff snippet - default + diffenable = true + if cfg.has_key?('diff') == true + if cfg.diff == false + diffenable = false + end + end + if diffenable == true + gitoutput = ctx.node.output.new + diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil + title = "#{ctx.node.name.to_s}" + log "Posting diff as snippet to #{cfg.space}" + message = CiscoSpark::Message.new(text: 'Device ' + title + ' modified:' + "\n" + diff[:patch].lines.to_a[4..-1].join + ) + room = CiscoSpark::Room.new(id: space) + room.send_message(message) + end + # message custom formatted - optional + if cfg.has_key?('message') == true + log cfg.message + msg = cfg.message % {:node => ctx.node.name.to_s, :group => ctx.node.group.to_s, :commitref => ctx.commitref, :model => ctx.node.model.class.name.to_s.downcase} + log msg + log "Posting message to #{cfg.space}" + client.chat_postMessage(channel: cfg.channel, text: msg, as_user: true) + end + log "Finished" + end + end + end +end -- cgit v1.2.3 From 93508ddee0226a271ab2b7db56443518e90ec50c Mon Sep 17 00:00:00 2001 From: rgnv Date: Thu, 12 Apr 2018 15:32:44 -0700 Subject: Fixed markdown for Spark hook --- docs/Hooks.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/Hooks.md b/docs/Hooks.md index d1b6925..92ba9ed 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -188,7 +188,7 @@ Note the channel name must be in quotes. The `ciscosparkdiff` hook posts config diffs to a [Cisco Spark](https://www.ciscospark.com/) space of your choice. It only triggers for `post_store` events. -You will need to manually install the `cisco_spark` gem on your system (see [cisco_spark-ruby](https://github.com/NGMarmaduke/cisco_spark-ruby): +You will need to manually install the `cisco_spark` gem on your system (see [cisco_spark-ruby](https://github.com/NGMarmaduke/cisco_spark-ruby) and generate either a [Bot or OAUTH access key](https://developer.ciscospark.com/apps.html), and retrieve the [Spark Space ID](https://developer.ciscospark.com/endpoint-rooms-get.html) ```shell gem install cisco_spark @@ -201,8 +201,8 @@ hooks: ciscospark: type: ciscosparkdiff events: [post_store] - accesskey: [SPARK_BOT_API_OR_OAUTH_KEY](https://developer.ciscospark.com/apps.html) - space: [SPARK_SPACE_ID](https://developer.ciscospark.com/endpoint-rooms-get.html) + accesskey: SPARK_BOT_API_OR_OAUTH_KEY + space: SPARK_SPACE_ID diff: true ``` -- cgit v1.2.3 From 48e50aca2229214fd5465d7faf1bd2908358c9ab Mon Sep 17 00:00:00 2001 From: rgnv Date: Thu, 12 Apr 2018 15:34:11 -0700 Subject: Fixed markdown for Spark hook --- docs/Hooks.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/Hooks.md b/docs/Hooks.md index 92ba9ed..b11570a 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -188,7 +188,7 @@ Note the channel name must be in quotes. The `ciscosparkdiff` hook posts config diffs to a [Cisco Spark](https://www.ciscospark.com/) space of your choice. It only triggers for `post_store` events. -You will need to manually install the `cisco_spark` gem on your system (see [cisco_spark-ruby](https://github.com/NGMarmaduke/cisco_spark-ruby) and generate either a [Bot or OAUTH access key](https://developer.ciscospark.com/apps.html), and retrieve the [Spark Space ID](https://developer.ciscospark.com/endpoint-rooms-get.html) +You will need to manually install the `cisco_spark` gem on your system (see [cisco_spark-ruby](https://github.com/NGMarmaduke/cisco_spark-ruby ) and generate either a [Bot or OAUTH access key](https://developer.ciscospark.com/apps.html), and retrieve the [Spark Space ID](https://developer.ciscospark.com/endpoint-rooms-get.html) ```shell gem install cisco_spark @@ -213,8 +213,8 @@ hooks: ciscospark: type: ciscosparkdiff events: [post_store] - accesskey: [SPARK_BOT_API_OR_OAUTH_KEY](https://developer.ciscospark.com/apps.html) - space: [SPARK_SPACE_ID](https://developer.ciscospark.com/endpoint-rooms-get.html) + accesskey: SPARK_BOT_API_OR_OAUTH_KEY + space: SPARK_SPACE_ID diff: false message: "%{node} %{group} %{model} updated https://git.intranet/network-changes/commit/%{commitref}" ``` -- cgit v1.2.3 From ec90b081f0fed05497ce6ae21e4b4ba4d44ecc01 Mon Sep 17 00:00:00 2001 From: rgnv Date: Thu, 12 Apr 2018 15:41:31 -0700 Subject: fix formatting to comply with Rubocop --- docs/Hooks.md | 2 +- lib/oxidized/hook/ciscosparkdiff.rb | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/Hooks.md b/docs/Hooks.md index b11570a..ee7b3ee 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -188,7 +188,7 @@ Note the channel name must be in quotes. The `ciscosparkdiff` hook posts config diffs to a [Cisco Spark](https://www.ciscospark.com/) space of your choice. It only triggers for `post_store` events. -You will need to manually install the `cisco_spark` gem on your system (see [cisco_spark-ruby](https://github.com/NGMarmaduke/cisco_spark-ruby ) and generate either a [Bot or OAUTH access key](https://developer.ciscospark.com/apps.html), and retrieve the [Spark Space ID](https://developer.ciscospark.com/endpoint-rooms-get.html) +You will need to manually install the `cisco_spark` gem on your system (see [cisco_spark-ruby](https://github.com/NGMarmaduke/cisco_spark-ruby)) and generate either a [Bot or OAUTH access key](https://developer.ciscospark.com/apps.html), and retrieve the [Spark Space ID](https://developer.ciscospark.com/endpoint-rooms-get.html) ```shell gem install cisco_spark diff --git a/lib/oxidized/hook/ciscosparkdiff.rb b/lib/oxidized/hook/ciscosparkdiff.rb index a1c9130..12094e6 100644 --- a/lib/oxidized/hook/ciscosparkdiff.rb +++ b/lib/oxidized/hook/ciscosparkdiff.rb @@ -22,7 +22,6 @@ class CiscoSparkDiff < Oxidized::Hook client = CiscoSpark::Room.new(id: space) client.fetch log "Connected" - # diff snippet - default diffenable = true if cfg.has_key?('diff') == true if cfg.diff == false @@ -34,12 +33,10 @@ class CiscoSparkDiff < Oxidized::Hook diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil title = "#{ctx.node.name.to_s}" log "Posting diff as snippet to #{cfg.space}" - message = CiscoSpark::Message.new(text: 'Device ' + title + ' modified:' + "\n" + diff[:patch].lines.to_a[4..-1].join - ) + message = CiscoSpark::Message.new(text: 'Device ' + title + ' modified:' + "\n" + diff[:patch].lines.to_a[4..-1].join) room = CiscoSpark::Room.new(id: space) room.send_message(message) end - # message custom formatted - optional if cfg.has_key?('message') == true log cfg.message msg = cfg.message % {:node => ctx.node.name.to_s, :group => ctx.node.group.to_s, :commitref => ctx.commitref, :model => ctx.node.model.class.name.to_s.downcase} -- cgit v1.2.3 From b29550ce0cfaf6192652747d340da2dc777ac22b Mon Sep 17 00:00:00 2001 From: Zsolt Zsiros Date: Mon, 16 Apr 2018 14:48:43 +0200 Subject: model: netgear.rb support for older models (#1268) * Added support for older models (FW 5.x.y.z like on GS110TP, GS748Tv4, etc) * Fixed prompt regex * docs/Model-Notes/Netgear created * docs/Model-Notes/Netgear fixed typos --- docs/Model-Notes/Netgear.md | 66 +++++++++++++++++++++++++++++++++++++++++++ docs/Model-Notes/README.md | 1 + lib/oxidized/model/netgear.rb | 5 ++-- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 docs/Model-Notes/Netgear.md (limited to 'docs') diff --git a/docs/Model-Notes/Netgear.md b/docs/Model-Notes/Netgear.md new file mode 100644 index 0000000..9bfd094 --- /dev/null +++ b/docs/Model-Notes/Netgear.md @@ -0,0 +1,66 @@ +Netgear Configuration +===================== + +There are several models available with CLI management via telnet (port 60000), but they all behave like one of the following: +- older models: +``` +Connected to 192.168.3.201. + +(GS748Tv4) +Applying Interface configuration, please wait ...admin +Password:******** +(GS748Tv4) >enable +Password: + +(GS748Tv4) #terminal length 0 + +(GS748Tv4) #show running-config +``` + +- newer models: +``` +Connected to 172.0.3.203. + +User:admin +Password:******** +(GS724Tv4) >enable + +(GS724Tv4) #terminal length 0 + +(GS724Tv4) #show running-config +``` + +The main differences are: +- the prompt for username is different (looks quite strange for older models) +- enable password + - the older model prompts for enable password and it expects empty string + - the newer model does not prompt for enable password at all + +Configuration for older/newer models: make sure you have defined variable 'enable': +- `'true'` for newer models +- `''` empty string: for older models + +One possible configuration: +- oxidized config +``` +source: + default: csv + csv: + file: "/home/oxidized/.config/oxidized/router.db" + delimiter: !ruby/regexp /:/ + map: + name: 0 + model: 1 + username: 2 + password: 3 + vars_map: + enable: 4 + telnet_port: 5 +``` +- router.db +``` +switchOldFW:netgear:admin:adminpw::60000 +switchNewFW:netgear:admin:adminpw:true:60000 +``` + +[Reference](https://github.com/ytti/oxidized/pull/1268) \ No newline at end of file diff --git a/docs/Model-Notes/README.md b/docs/Model-Notes/README.md index c4b0ed1..fd1298e 100644 --- a/docs/Model-Notes/README.md +++ b/docs/Model-Notes/README.md @@ -12,6 +12,7 @@ AireOS|[AireOS](AireOS.md)|29 Nov 2017 Arbor Networks|[ArbOS](ArbOS.md)|27 Feb 2018 Huawei|[VRP](VRP-Huawei.md)|17 Nov 2017 Juniper|[MX/QFX/EX/SRX/J Series](JunOS.md)|18 Jan 2018 +Netgear|[Netgear](Netgear.md)|11 Apr 2018 Zyxel|[XGS4600 Series](XGS4600-Zyxel.md)|23 Jan 2018 If you discover additional caveats or problems please make sure to consult the [GitHub issues for oxidized](https://github.com/ytti/oxidized/issues) known issues. diff --git a/lib/oxidized/model/netgear.rb b/lib/oxidized/model/netgear.rb index 0ab1349..a32eb66 100644 --- a/lib/oxidized/model/netgear.rb +++ b/lib/oxidized/model/netgear.rb @@ -1,15 +1,16 @@ class Netgear < Oxidized::Model comment '!' - prompt /^(\([\w\-.]+\)\s[#>])$/ + prompt /^(\([\w\s\-.]+\)\s[#>])$/ cmd :secret do |cfg| cfg.gsub!(/password (\S+)/, 'password ') + cfg.gsub!(/encrypted (\S+)/, 'encrypted ') cfg end cfg :telnet do - username /^User:/ + username /^(User:|Applying Interface configuration, please wait ...)/ end cfg :telnet, :ssh do -- cgit v1.2.3 From 12c770dd3504748d3e67f99175b26d0515a3d283 Mon Sep 17 00:00:00 2001 From: Yuri Zubov Date: Thu, 19 Apr 2018 14:19:41 +0300 Subject: Basic support for NDMS OS (Zyxel Keenetic) --- docs/Supported-OS-Types.md | 1 + lib/oxidized/model/ndms.rb | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lib/oxidized/model/ndms.rb (limited to 'docs') diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 7a765f8..4556946 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -163,3 +163,4 @@ * [Zhone (OLT and MX)](/lib/oxidized/model/zhoneolt.rb) * Zyxel * [ZyNOS](/lib/oxidized/model/zynos.rb) + * [NDMS](/lib/oxidized/model/ndms.rb) diff --git a/lib/oxidized/model/ndms.rb b/lib/oxidized/model/ndms.rb new file mode 100644 index 0000000..c632bb9 --- /dev/null +++ b/lib/oxidized/model/ndms.rb @@ -0,0 +1,25 @@ +class NDMS < Oxidized::Model + + # Pull config from Zyxel Keenetic devices from version NDMS >= 2.0 + + comment '! ' + + prompt /^([\w.@()-]+[#>]\s?)/m + + cmd 'show version' do |cfg| + cfg = cfg.each_line.to_a[1..-3].join + comment cfg + end + + cmd 'show running-config' do |cfg| + cfg = cfg.each_line.to_a[1..-2] + cfg = cfg.reject { |line| line.match /(clock date|checksum)/ }.join + cfg + end + + cfg :telnet do + username /^Login:/ + password /^Password:/ + pre_logout 'exit' + end +end -- cgit v1.2.3 From ffd4cc1569df3a9ad5c1ac453861544762ac4853 Mon Sep 17 00:00:00 2001 From: ytti Date: Mon, 23 Apr 2018 15:44:00 +0300 Subject: Fix Brocade links Fixes #1302 --- docs/Supported-OS-Types.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 4556946..8839cc3 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -32,12 +32,12 @@ * [VOSS (VSP Operating System Software)](/lib/oxidized/model/voss.rb) * [BOSS (Baystack Operating System Software)](/lib/oxidized/model/boss.rb) * Brocade - * [FabricOS](lib/oxidized/model/fabricos.rb) - * [Ironware](lib/oxidized/model/ironware.rb) - * [NOS (Network Operating System)](lib/oxidized/model/nos.rb) - * [Vyatta](lib/oxidized/model/vyatta.rb) - * [6910](lib/oxidized/model/br6910.rb) - * [SLX-OS](lib/oxidized/model/slxos.rb) + * [FabricOS](/lib/oxidized/model/fabricos.rb) + * [Ironware](/lib/oxidized/model/ironware.rb) + * [NOS (Network Operating System)](/lib/oxidized/model/nos.rb) + * [Vyatta](/lib/oxidized/model/vyatta.rb) + * [6910](/lib/oxidized/model/br6910.rb) + * [SLX-OS](/lib/oxidized/model/slxos.rb) * Casa * [Casa](/lib/oxidized/model/casa.rb) * Check Point -- cgit v1.2.3 From cb002959bfc776de117f2353041e9d40aa486585 Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 24 Apr 2018 10:07:51 -0500 Subject: Add a note about database engine reserved keywords. --- docs/Sources.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docs') diff --git a/docs/Sources.md b/docs/Sources.md index 6d8e19e..eb3cd0c 100644 --- a/docs/Sources.md +++ b/docs/Sources.md @@ -59,6 +59,9 @@ pinentry-mode loopback Oxidized uses the `sequel` ruby gem. You can use a variety of databases that aren't explicitly listed. For more information visit https://github.com/jeremyevans/sequel Make sure you have the correct adapter! +**NOTE** - Many database engines have reserved keywords that may conflict with Oxidized configuration field names (such as 'name', 'group', etc). Pay attention to any names that are used and observed proper quoting methods to avoid errors or unpredictable results. + + ## Source: MYSQL `sudo apt-get install libmysqlclient-dev` -- cgit v1.2.3 From 6d9181ae1a191a9e4bfc028edfd3c5b5d0435d0e Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 24 Apr 2018 10:08:58 -0500 Subject: Consistency - add a link back to Model-Notes at the bottom --- docs/Model-Notes/ArbOS.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/Model-Notes/ArbOS.md b/docs/Model-Notes/ArbOS.md index f68467f..ebac997 100644 --- a/docs/Model-Notes/ArbOS.md +++ b/docs/Model-Notes/ArbOS.md @@ -8,3 +8,5 @@ If you are running ArbOS version 7 or lower then you may need to update the mode pre_logout 'exit' end ``` + +Back to [Model-Notes](README.md) -- cgit v1.2.3 From ffbc250f019fadabb7fd26b046c2a2e8e235b33c Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 24 Apr 2018 10:09:28 -0500 Subject: Consistency - add a link back to Model-Notes at the bottom --- docs/Model-Notes/Comware.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/Model-Notes/Comware.md b/docs/Model-Notes/Comware.md index e7a2198..048f312 100644 --- a/docs/Model-Notes/Comware.md +++ b/docs/Model-Notes/Comware.md @@ -10,3 +10,5 @@ info-center source default channel 1 log state off debug state off ``` [Reference](https://github.com/ytti/oxidized/issues/1171) + +Back to [Model-Notes](README.md) -- cgit v1.2.3 From b6f4c3665b773ae0ba95a9a6084392d47779e8fd Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 24 Apr 2018 10:10:06 -0500 Subject: Netgear notes updates Consistency - add a link back to Model-Notes at the bottom Tag a YAML block as YAML for highlighting. --- docs/Model-Notes/Netgear.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/Model-Notes/Netgear.md b/docs/Model-Notes/Netgear.md index 9bfd094..d82bdcc 100644 --- a/docs/Model-Notes/Netgear.md +++ b/docs/Model-Notes/Netgear.md @@ -6,7 +6,7 @@ There are several models available with CLI management via telnet (port 60000), ``` Connected to 192.168.3.201. -(GS748Tv4) +(GS748Tv4) Applying Interface configuration, please wait ...admin Password:******** (GS748Tv4) >enable @@ -42,7 +42,7 @@ Configuration for older/newer models: make sure you have defined variable 'enabl One possible configuration: - oxidized config -``` +```yaml source: default: csv csv: @@ -63,4 +63,6 @@ switchOldFW:netgear:admin:adminpw::60000 switchNewFW:netgear:admin:adminpw:true:60000 ``` -[Reference](https://github.com/ytti/oxidized/pull/1268) \ No newline at end of file +[Reference](https://github.com/ytti/oxidized/pull/1268) + +Back to [Model-Notes](README.md) -- cgit v1.2.3 From d1723993e6048621f6a2428bcba51c1cd17a124e Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 24 Apr 2018 10:11:24 -0500 Subject: Ruby-API.md cleanups Refer to things as 'device' versus 'switch' Add some example use case notes for post_login and pre_logout. MD highlight some items in the list for clarity misc text clarity adjustments. --- docs/Ruby-API.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'docs') diff --git a/docs/Ruby-API.md b/docs/Ruby-API.md index 8621870..a9963b3 100644 --- a/docs/Ruby-API.md +++ b/docs/Ruby-API.md @@ -6,7 +6,7 @@ The following objects exist in Oxidized. * gets config from nodes * must implement 'connect', 'get', 'cmd' -* 'ssh', 'telnet, ftp, and tftp' implemented +* 'ssh', 'telnet', 'ftp', and 'tftp' implemented ## Output @@ -18,12 +18,12 @@ The following objects exist in Oxidized. * gets list of nodes to poll * must implement 'load' -* source can have 'name', 'model', 'group', 'username', 'password', 'input', 'output', 'prompt' - * name - name of the devices - * model - model to use ios/junos/xyz, model is loaded dynamically when needed (Also default in config file) - * input - method to acquire config, loaded dynamically as needed (Also default in config file) - * output - method to store config, loaded dynamically as needed (Also default in config file) - * prompt - prompt used for node (Also default in config file, can be specified in model too) +* source can have 'name', 'model', 'group', 'username', 'password', 'input', 'output', 'prompt' for each device. + * `name` - name of the device + * `model` - model to use ('ios', 'junos', etc).The model is loaded dynamically by the first node of that model type. (Also default in config file) + * `input` - method to acquire config, loaded dynamically as needed (Also default in config file) + * `output` - method to store config, loaded dynamically as needed (Also default in config file) + * `prompt` - prompt used for node (Also default in config file, can be specified in model too) * 'sql', 'csv' and 'http' (supports any format with single entry per line, like router.db) ## Model @@ -116,16 +116,20 @@ 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 +logged in to the device. Takes one argument that is either a block (taking zero parameters) or a string containing a command to execute. +This allows `post_login` to be used for any model-specific items prior to running the regular commands. This could include disabling the output pager or timestamp outputs that would cause constant differences. + #### `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 +device. Takes one argument that is either a block (taking zero parameters) or a string containing a command to execute. +This allows `pre_logout` to be used to 'undo' any changes that may have been needed via `post_login` (restore pager output, etc.) + #### `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. +Takes a single parameter: a string to be sent to the device. -- cgit v1.2.3 From e383a573e6c11f7366ce52774e191f7272db114f Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 24 Apr 2018 10:13:49 -0500 Subject: Misc Hooks.md cleanups misc text clarity. clarify timeout is in seconds clarity the publickey/privatekey are paths - not the keys themselves. Reorder the AWS SNS example of describing the config before the example config for consistency with the rest. --- docs/Hooks.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'docs') diff --git a/docs/Hooks.md b/docs/Hooks.md index fb80a19..ff430ca 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -1,6 +1,6 @@ # Hooks -You can define arbitrary number of hooks that subscribe different events. The hook system is modular and different kind of hook types can be enabled. +You can define an arbitrary number of hooks that subscribe to different events. The hook system is modular and different kind of hook types can be enabled. ## Configuration @@ -38,10 +38,10 @@ OX_REPO_COMMITREF OX_REPO_NAME ``` -Exec hook recognizes following configuration keys: +Exec hook recognizes the following configuration keys: -* `timeout`: hard timeout for the command execution. SIGTERM will be sent to the child process after the timeout has elapsed. Default: 60 -* `async`: influences whether main thread will wait for the command execution. Set this true for long running commands so node pull is not blocked. Default: false +* `timeout`: hard timeout (in seconds) for the command execution. SIGTERM will be sent to the child process after the timeout has elapsed. Default: `60` +* `async`: Execute the command in an asynchronous fashion. The main thread by default will wait for the hook command execution to complete. Set this to `true` for long running commands so node configuration pulls are not blocked. Default: `false` * `cmd`: command to run. ### exec hook configuration example @@ -79,8 +79,8 @@ For ssh key-based authentication, it is possible to set the environment variable * `remote_repo`: the remote repository to be pushed to. * `username`: username for repository auth. * `password`: password for repository auth. -* `publickey`: public key for repository auth. -* `privatekey`: private key for repository auth. +* `publickey`: public key file path for repository auth. +* `privatekey`: private key file path for repository auth. When using groups, each group must have a unique entry in the `remote_repo` config. @@ -95,7 +95,7 @@ hooks: ### githubrepo hook configuration example -Authenticate with a username and a password: +Authenticate with a username and a password without groups in use: ```yaml hooks: @@ -130,6 +130,11 @@ Fields sent in the message: * `model`: Model name (e.g. `eos`) * `node`: Device hostname + +The AWS SNS hook requires the following configuration keys: + +* `region`: AWS Region name +* `topic_arn`: ASN Topic reference ### awssns hook configuration example ```yaml @@ -141,11 +146,6 @@ hooks: topic_arn: arn:aws:sns:us-east-1:1234567:oxidized-test-backup_events ``` -AWS SNS hook requires the following configuration keys: - -* `region`: AWS Region name -* `topic_arn`: ASN Topic reference - Your AWS credentials should be stored in `~/.aws/credentials`. ## Hook type: slackdiff -- cgit v1.2.3 From 7d450963907a76b26c47082b5c482a093ba3a533 Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 24 Apr 2018 10:15:45 -0500 Subject: A few Outputs.md textual cleanups misc clarity items --- docs/Outputs.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/Outputs.md b/docs/Outputs.md index 92c672c..fab3bf8 100644 --- a/docs/Outputs.md +++ b/docs/Outputs.md @@ -14,7 +14,7 @@ output: This uses the rugged/libgit2 interface. So you should remember that normal Git hooks will not be executed. -For a single repositories for all devices: +For a single repository containing all devices: ```yaml output: @@ -25,7 +25,7 @@ output: repo: "/var/lib/oxidized/devices.git" ``` -And for groups repositories: +And for group-based repositories: ```yaml output: @@ -68,7 +68,7 @@ output: This uses the gem git and system git-crypt interfaces. Have a look at [GIT-Crypt](https://www.agwa.name/projects/git-crypt/) documentation to know how to install it. Additionally to user and email informations, you have to provide the users ID that can be a key ID, a full fingerprint, an email address, or anything else that uniquely identifies a public key to GPG (see "HOW TO SPECIFY A USER ID" in the gpg man page). -For a single repositories for all devices: +For a single repository containing all devices: ```yaml output: @@ -82,7 +82,7 @@ output: - "" ``` -And for groups repositories: +And for group-based repositories: ```yaml output: @@ -130,8 +130,9 @@ Please note that user list is only updated once at creation. ## Output: Http -POST a config to the specified URL +The HTTP output will POST a config to the specified HTTP URL. Basic username/password authentication is supported. +Example HTTP output configuration: ```yaml output: default: http @@ -185,4 +186,4 @@ which will result in the following layout diff/$FQDN--show_running_config nodiff/$FQDN--show_version nodiff/$FQDN--show_inventory -``` \ No newline at end of file +``` -- cgit v1.2.3 From 90a84a79279a0bac817ef871a4992e3d7d019cef Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 24 Apr 2018 10:16:38 -0500 Subject: Give some examples of smart loading Indicate that it can be used to have local site changes or updated models from the repo. minor text clarity on other items. --- docs/Creating-Models.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/Creating-Models.md b/docs/Creating-Models.md index d7a8155..3cb87c3 100644 --- a/docs/Creating-Models.md +++ b/docs/Creating-Models.md @@ -4,6 +4,8 @@ Oxidized supports a growing list of [operating system types](Supported-OS-Types. A user may wish to extend an existing model to collect the output of additional commands. Oxidized offers smart loading of models in order to facilitate this with ease, without the need to introduce changes to the upstream source code. +This methodology allows local site changes to be preserved during Oxidized version updates / gem updates. + ## Extending an existing model with a new command The example below can be used to extend the `JunOS` model to collect the output of `show interfaces diagnostics optics` and append the output to the configuration file as a comment. This command retrieves DOM information on pluggable optics present in a `JunOS`-powered chassis. @@ -25,13 +27,16 @@ class JunOS end ``` -Due to smart loading, the user-supplied `~/.config/oxidized/model/junos.rb` file will take precedence over the model with the same name included in Oxidized. The code then uses `require` to load the included model, and extends the class defined therein with an additional command. +Due to smart loading, the user-supplied `~/.config/oxidized/model/junos.rb` file will take precedence over the model with the same name included in the Oxidized distribution. + +The code then uses `require` to initially load the Oxidized-supplied model, and extends the class defined therein with an additional command. Intuitively, it is also possible to: * Completely re-define an existing model by creating a file in `~/.config/oxidized/model/` with the same name as an existing model, but not `require`-ing the upstream model file. -* Create a named variation of an existing model, by creating a file with a new name (such as `~/.config/oxidized/model/junos-extra.rb`), Then `require` the original model and extend its base class as in the above example. The named variation can then be specified as an OS type for some devices but not others when defining sources. +* Create a named variation of an existing model, by creating a file with a new name (such as `~/.config/oxidized/model/junos-extra.rb`), Then `require` the original model and extend its base class as in the above example. The named variation can then be specified as an OS type for specific devices that can benefit from the extra functionality. This allows for preservation of the base functionality for the default model types. * Create a completely new model, with a new name, for a new operating system type. +* Testing/validation of an updated model from the [Oxidized GitHub repo models](https://github.com/ytti/oxidized/tree/master/lib/oxidized/model) by placing an updated model in the proper location without disrupting the gem-supplied model files. ## Advanced features @@ -70,4 +75,4 @@ class JunOS 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. \ No newline at end of file +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. -- cgit v1.2.3 From cdcecd48fd05fecd656f384d074bd06406ac2690 Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 24 Apr 2018 10:17:40 -0500 Subject: clarity updates for Configuration doc typo fixes - IP-Adress -> IP-Address remove_secrets -> remove_secret tag a ruby block as ruby for correct highlight misc other small text clarity (ssh_proxy is the proxy information etc) --- docs/Configuration.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'docs') diff --git a/docs/Configuration.md b/docs/Configuration.md index 6bbbb61..661e65a 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -4,7 +4,7 @@ In case a model plugin doesn't work correctly (ios, procurve, etc.), you can enable live debugging of SSH/Telnet sessions. Just add a `debug` option containing the value true to the `input` section. The log files will be created depending on the parent directory of the logfile option. -The following example will log an active ssh/telnet session `/home/oxidized/.config/oxidized/log/-`. The file will be truncated on each consecutive ssh/telnet session, so you need to put a `tailf` or `tail -f` on that file! +The following example will log an active ssh/telnet session `/home/oxidized/.config/oxidized/log/-`. The file will be truncated on each consecutive ssh/telnet session, so you need to put a `tailf` or `tail -f` on that file! ```yaml log: /home/oxidized/.config/oxidized/log @@ -29,18 +29,18 @@ vars: ## Removing secrets -To strip out secrets from configurations before storing them, Oxidized needs the the remove_secrets flag. You can globally enable this by adding the following snippet to the global sections of the configuration file. +To strip out secrets from configurations before storing them, Oxidized needs the `remove_secret` flag. You can globally enable this by adding the following snippet to the global section of the configuration file. ```yaml vars: remove_secret: true ``` -Device models can contain substitution filters to remove potentially sensitive data from configs. +Device models that contain substitution filters to remove sensitive data will now be run on any fetched configuration. As a partial example from ios.rb: -```yaml +```ruby cmd :secret do |cfg| cfg.gsub! /^(snmp-server community).*/, '\\1 ' (...) @@ -64,7 +64,11 @@ vars: ## SSH Proxy Command -Oxidized can `ssh` through a proxy as well. To do so we just need to set `ssh_proxy` variable. +Oxidized can `ssh` through a proxy as well. To do so we just need to set `ssh_proxy` variable with the proxy host information. + +This can be provided on a per-node basis by mapping the proper fields from your source. + +An example for a `csv` input source that maps the 4th field as the `ssh_proxy` value. ```yaml ... @@ -79,7 +83,7 @@ vars_map: ## FTP Passive Mode -Oxidized uses ftp passive mode by default. Some devices require passive mode to be disabled. To do so, we can set `input.ftp.passive` to false +Oxidized uses ftp passive mode by default. Some devices require passive mode to be disabled. To do so, we can set `input.ftp.passive` to false - this will make use of FTP active mode. ```yaml input: @@ -192,10 +196,12 @@ rest: 10.0.0.1:8000/oxidized ## Triggered backups -A node can be moved to head-of-queue via the REST API `GET/POST /node/next/[NODE]`. +A node can be moved to head-of-queue via the REST API `GET/POST /node/next/[NODE]`. This can be useful to immediately schedule a fetch of the configuration after some other event such as a syslog message indicating a configuration update on the device. -In the default configuration this node will be processed when the next job worker becomes available, it could take some time if existing backups are in progress. To execute moved jobs immediately a new job can be added: +In the default configuration this node will be processed when the next job worker becomes available, it could take some time if existing backups are in progress. To execute moved jobs immediately a new job can be added automatically: ```yaml next_adds_job: true ``` + +This will allow for a more timely fetch of the device configuration. -- cgit v1.2.3 From b1d2d69c1fa0a122b3a99687721b35c99d25aab5 Mon Sep 17 00:00:00 2001 From: KodApa85 Date: Fri, 27 Apr 2018 14:53:05 +0100 Subject: Corrected spelling mistake --- docs/Model-Notes/XGS4600-Zyxel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/Model-Notes/XGS4600-Zyxel.md b/docs/Model-Notes/XGS4600-Zyxel.md index c24bed6..8b58ed8 100644 --- a/docs/Model-Notes/XGS4600-Zyxel.md +++ b/docs/Model-Notes/XGS4600-Zyxel.md @@ -24,7 +24,7 @@ input: ## SSH/TelNet Below is the table from the XGS4600 CLI Reference Guide (Version 3.79~4.50 Edition 1, 07/2017) -Take this table with a pink of salt, level 3 will not allow _show running-config_! +Take this table with a pinch of salt, level 3 will not allow _show running-config_! Privilege Level | Types of commands at this privilege level ----------------|------------------------------------------- -- cgit v1.2.3 From be6872a004f3422471edcc3cab8479e7adff07dd Mon Sep 17 00:00:00 2001 From: KodApa85 Date: Fri, 27 Apr 2018 14:55:13 +0100 Subject: Removed accidental deletion --- docs/Model-Notes/README.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/Model-Notes/README.md b/docs/Model-Notes/README.md index 99c8291..993eb77 100644 --- a/docs/Model-Notes/README.md +++ b/docs/Model-Notes/README.md @@ -13,6 +13,7 @@ Arbor Networks|[ArbOS](ArbOS.md)|27 Feb 2018 Arista|[EOS](EOS.md)|05 Feb 2018 Huawei|[VRP](VRP-Huawei.md)|17 Nov 2017 Juniper|[MX/QFX/EX/SRX/J Series](JunOS.md)|18 Jan 2018 +Netgear|[Netgear](Netgear.md)|11 Apr 2018 Zyxel|[XGS4600 Series](XGS4600-Zyxel.md)|1 Feb 2018 If you discover additional caveats or problems please make sure to consult the [GitHub issues for oxidized](https://github.com/ytti/oxidized/issues) known issues. -- cgit v1.2.3 From 73175e95c253471f7f06dee04f88e76c77204e6c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 27 Apr 2018 19:07:31 +0200 Subject: add docs and tests for resolve_dns --- docs/Configuration.md | 10 ++++++++++ lib/oxidized/config.rb | 2 +- spec/input/ssh_spec.rb | 49 +++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 9 deletions(-) (limited to 'docs') diff --git a/docs/Configuration.md b/docs/Configuration.md index 1d16c91..aea5e3c 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -214,3 +214,13 @@ next_adds_job: true ``` This will allow for a more timely fetch of the device configuration. + +## Disabling DNS resolution + +In some instances it might not be desirable to attempt to resolve names of nodes. One such use case is when nodes are accessed through an SSH proxy, where the remote end resolves the names differently than the host on which Oxidized runs would. + +Names can instead be passed verbatim to the input: + +```yaml +resolve_dns: false +``` diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb index 0a8fdfd..36d9d73 100644 --- a/lib/oxidized/config.rb +++ b/lib/oxidized/config.rb @@ -20,7 +20,7 @@ module Oxidized asetus.default.username = 'username' asetus.default.password = 'password' asetus.default.model = 'junos' - asetus.default.resolve_dns = true # if false, don't resolve DNS to IP + asetus.default.resolve_dns = true # if false, don't resolve DNS to IP asetus.default.interval = 3600 asetus.default.use_syslog = false asetus.default.debug = false diff --git a/spec/input/ssh_spec.rb b/spec/input/ssh_spec.rb index 3c33cd8..0a3bd8d 100644 --- a/spec/input/ssh_spec.rb +++ b/spec/input/ssh_spec.rb @@ -8,17 +8,19 @@ describe Oxidized::SSH do Oxidized::Node.any_instance.stubs(:resolve_repo) Oxidized::Node.any_instance.stubs(:resolve_input) Oxidized::Node.any_instance.stubs(:resolve_output) - @node = Oxidized::Node.new(name: 'example.com', - input: 'ssh', - output: 'git', - model: 'junos', - username: 'alma', - password: 'armud', - vars: { ssh_proxy: 'test.com' }) end describe "#connect" do - it "should use proxy command when proxy host given" do + it "should use proxy command when proxy host given and connect by ip if resolve_dns is true" do + Oxidized.config.resolve_dns = true + @node = Oxidized::Node.new(name: 'example.com', + input: 'ssh', + output: 'git', + model: 'junos', + username: 'alma', + password: 'armud', + vars: { ssh_proxy: 'test.com' }) + ssh = Oxidized::SSH.new model = mock @@ -39,5 +41,36 @@ describe Oxidized::SSH do ssh.instance_variable_set("@exec", true) ssh.connect(@node) end + + it "should use proxy command when proxy host given and connect by name if resolve_dns is false" do + Oxidized.config.resolve_dns = false + @node = Oxidized::Node.new(name: 'example.com', + input: 'ssh', + output: 'git', + model: 'junos', + username: 'alma', + password: 'armud', + vars: { ssh_proxy: 'test.com' }) + + ssh = Oxidized::SSH.new + + model = mock + model.expects(:cfg).returns('ssh' => []) + @node.expects(:model).returns(model).at_least_once + + proxy = mock + Net::SSH::Proxy::Command.expects(:new).with("ssh test.com -W %h:%p").returns(proxy) + Net::SSH.expects(:start).with('example.com', 'alma', port: 22, + timeout: Oxidized.config.timeout, + paranoid: Oxidized.config.input.ssh.secure, + keepalive: true, + proxy: proxy, + password: 'armud', + number_of_password_prompts: 0, + auth_methods: %w[none publickey password]) + + ssh.instance_variable_set("@exec", true) + ssh.connect(@node) + end end end -- cgit v1.2.3 From dc893722569ac8a319c616c06978bbf9c5fa44d7 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Tue, 1 May 2018 12:15:50 +0200 Subject: add reference for openwrt support and update changelog --- CHANGELOG.md | 4 ++++ docs/Supported-OS-Types.md | 1 + 2 files changed, 5 insertions(+) (limited to 'docs') diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e03883..4e7f09e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Master + +* FEATURE: openwrt model (@z00nx) + ## 0.21.0 * FEATURE: routeros include system history (@InsaneSplash) diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 8839cc3..75845b9 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -127,6 +127,7 @@ * [OneOS](/lib/oxidized/model/oneos.rb) * Opengear * [Opengear](/lib/oxidized/model/opengear.rb) +* [OpenWRT](/lib/oxidized/model/openwrt.rb) * [OPNsense](/lib/oxidized/model/opnsense.rb) * Palo Alto * [PANOS](/lib/oxidized/model/panos.rb) -- cgit v1.2.3 From 9273e5feee159040622348d922512dd6b2f097b9 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 9 May 2018 13:04:16 +0200 Subject: tidy up and add references for stoneos model --- CHANGELOG.md | 1 + docs/Supported-OS-Types.md | 2 ++ lib/oxidized/model/stoneos.rb | 22 ++++++++-------------- 3 files changed, 11 insertions(+), 14 deletions(-) (limited to 'docs') diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e7f09e..90456d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Master +* FEATURE: stoneos model (@macaty) * FEATURE: openwrt model (@z00nx) ## 0.21.0 diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 75845b9..ce0f9c6 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -95,6 +95,8 @@ * [Broadband Network Platform Software](/lib/oxidized/model/gcombnps.rb) * Hatteras * [Hatteras](/lib/oxidized/model/hatteras.rb) +* Hillstone Networks + * [StoneOS](/lib/oxidized/model/stoneos.rb) * Hirschmann * [HiOS](/lib/oxidized/model/hirschmann.rb) * HP diff --git a/lib/oxidized/model/stoneos.rb b/lib/oxidized/model/stoneos.rb index 405e389..d2bc017 100644 --- a/lib/oxidized/model/stoneos.rb +++ b/lib/oxidized/model/stoneos.rb @@ -1,25 +1,19 @@ -class Stoneos < Oxidized::Model -#Hillstone Networks StoneOS software +class StoneOS < Oxidized::Model + # Hillstone Networks StoneOS software prompt /^\r?[\w.()-]+[#>](\s)?$/ comment '# ' - + expect /^\s.*--More--.*$/ do |data, re| - send ' ' - data.sub re, '' - end - - cmd :all do |cfg| - cfg = cfg.lines.to_a[1..-2].join + send ' ' + data.sub re, '' end - cmd :secret do |cfg| - cfg + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].join end - cmd 'show configuration running' do |cfg| - cfg - end + cmd 'show configuration running' cmd 'show version' do |cfg| comment cfg -- cgit v1.2.3 From 7402b4f0902de2a1ece579f33b83977c03d9db2d Mon Sep 17 00:00:00 2001 From: Juho Ylikorpi Date: Sat, 26 May 2018 19:00:54 +0300 Subject: Comnet Microsemi Switch support (#1346) * ComnetMicrosemiSwitch support --- docs/Supported-OS-Types.md | 2 ++ lib/oxidized/model/comnetms.rb | 43 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 lib/oxidized/model/comnetms.rb (limited to 'docs') diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index ce0f9c6..5850bd1 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -63,6 +63,8 @@ * [TMOS (8800)](/lib/oxidized/model/corianttmos.rb) * [8600](/lib/oxidized/model/coriant8600.rb) * [Groove](/lib/oxidized/model/coriantgroove.rb) +* ComNet + * [ComNet Microsemi Switch](/lib/oxidized/model/comnetms.rb) * Cumulus * [Linux](/lib/oxidized/model/cumulus.rb) * DataCom diff --git a/lib/oxidized/model/comnetms.rb b/lib/oxidized/model/comnetms.rb new file mode 100644 index 0000000..1ce4601 --- /dev/null +++ b/lib/oxidized/model/comnetms.rb @@ -0,0 +1,43 @@ +class ComnetMS < Oxidized::Model + # Comnet Microsemi Switch + prompt /^\r?([\w.@()-]+[#>]\s?)$/ + comment '! ' + + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].join + end + + cmd 'show running-config' do |cfg| + cfg.gsub! "\n\r", "\n" + cfg.gsub! /^[\r\n\s]*Building configuration\.\.\.\n/, '' + cfg.gsub! /^end\n/, '' + cfg + end + + cmd 'show version' do |cfg| + cfg.gsub! "\n\r", "\n" + cfg.gsub! /^MEMORY\s*:.*\n/, '' + cfg.gsub! /^FLASH\s*:.*\n/, '' + cfg.gsub! /^Previous Restart\s*:.*\n/, '' + cfg.gsub! /^System Time\s*:.*\n/, '' + cfg.gsub! /^System Uptime\s*:.*\n/, '' + comment cfg + end + + cfg :telnet do + username /^Username:/i + password /^Password:/i + end + + cfg :telnet, :ssh do + if vars :enable + post_login do + send "enable\n" + cmd vars(:enable) + end + end + post_login 'terminal length 0' + post_login 'terminal width 0' + pre_logout 'exit' + end +end -- cgit v1.2.3