From 81fc3a4b423d8ce9fe69def57007312a96db6f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20L=C3=B6nnemark?= Date: Tue, 19 Sep 2017 16:28:41 +0200 Subject: Add support for Supermicro SSE-G48-TG4 This model (and possibly others) runs an OS with a different set of commands than the Supermicro model that already exists. --- docs/Supported-OS-Types.md | 3 ++- lib/oxidized/model/supermicro2.rb | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 lib/oxidized/model/supermicro2.rb diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index e600040..f5352de 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -128,7 +128,8 @@ * Siklu * [EtherHaul](lib/oxidized/model/siklu.rb) * Supermicro - * [Supermicro](lib/oxidized/model/supermicro.rb) + * [Supermicro](lib/oxidized/model/supermicro.rb): Known to work with the Supermicro SSE-G2252. + * [Supermicro2](lib/oxidized/model/supermicro2.rb): Known to work with the Supermicro SSE-G48-TG4. * Symantec * [Blue Coat ProxySG / Security Gateway OS (SGOS)](lib/oxidized/model/sgos.rb) * Trango Systems diff --git a/lib/oxidized/model/supermicro2.rb b/lib/oxidized/model/supermicro2.rb new file mode 100644 index 0000000..710603c --- /dev/null +++ b/lib/oxidized/model/supermicro2.rb @@ -0,0 +1,48 @@ +# Developed against: +# #show version +# Switch ID Hardware Version Firmware Version +# 0 SSE-G48-TG4 (P2-01) 1.0.16-9 + +class Supermicro2 < Oxidized::Model + prompt (/^(\e\[27m)?[ \r]*\w+# ?$/) + + cfg :ssh do + post_login 'no cli pagignation' + pre_logout 'exit' + end + + cmd :all do |cfg| + # * Drop first line that contains the command, and the last line that + # contains a prompt + # * Strip carriage returns + cfg.delete("\r").each_line.to_a[1..-2].join + end + + cmd :secret do |cfg| + cfg.gsub(/^(snmp community) .*/, '\1 ') + end + + cmd 'show system information' do |cfg| + cfg.sub! /^Device Up Time.*\n/, '' + cfg.delete! "\r" + comment(cfg).gsub(/ +$/, '') + end + + cmd 'show running-config' do |cfg| + comment_next = 0 + cfg.each_line.map { |l| + next '' if l.match /^Building configuration/ + + if l.match /^Switch ID.*Hardware Version.*Firmware Version/ then + comment_next = 2 + end + + if comment_next > 0 then + comment_next -= 1 + next comment(l) + end + + l + }.join.gsub(/ +$/, '') + end +end -- cgit v1.2.1 From a302b12af7edb5960c9812a51fec529c132ac401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verch=C3=A8re?= Date: Tue, 17 Oct 2017 12:27:44 +0200 Subject: Handle Dell N2000 switches (dnos6) --- lib/oxidized/model/dnos.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/oxidized/model/dnos.rb b/lib/oxidized/model/dnos.rb index a44630e..5c3cd53 100644 --- a/lib/oxidized/model/dnos.rb +++ b/lib/oxidized/model/dnos.rb @@ -5,6 +5,7 @@ class DNOS < Oxidized::Model comment '! ' cmd :all do |cfg| + cfg.gsub! /^% Invalid input detected at '\^' marker\.$|^\s+\^$/, '' cfg.each_line.to_a[2..-2].join end @@ -22,6 +23,14 @@ class DNOS < Oxidized::Model comment cfg end + cmd 'show version' do |cfg| + comment cfg + end + + cmd 'show system' do |cfg| + comment cfg + end + cmd 'show running-config' do |cfg| cfg = cfg.each_line.to_a[3..-1].join cfg -- cgit v1.2.1 From 4203e00cbde157e767e8be39ffdcecb30db14e6b Mon Sep 17 00:00:00 2001 From: Nicholas Meredith Date: Sun, 12 Nov 2017 05:48:55 +1000 Subject: fix: Fix prompt pattern for model/comware.rb to handle ASCII Bell response +fix minor README.md typo (#1094) * comware.rb: update prompt to work when trailing ^G ASCII 7 (bell) is sent * README.md: correct typo 'HTT' to 'HTTP' for Configuration / Outputs paragraph * model/comware.rb: cleaning out some comments --- README.md | 2 +- lib/oxidized/model/comware.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 17b305b..2262d79 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,7 @@ Oxidized supports [CSV](docs/Configuration.md#source-csv), [SQLite](docs/Config ## Outputs -Possible outputs are either [File](docs/Configuration.md#output-file), [GIT](docs/Configuration.md#output-git), [GIT-Crypt](docs/Configuration.md#output-git-crypt) and [HTT](docs/Configuration.md#output-http). The file backend takes a destination directory as argument and will keep a file per device, with most recent running version of a device. The GIT backend (recommended) will initialize an empty GIT repository in the specified path and create a new commit on every configuration change. The GIT-Crypt backend will also initialize a GIT repository but every configuration push to it will be encrypted on the fly by using `git-crypt` tool. Take a look at the [Configuration](docs/Configuration.md) for more details. +Possible outputs are either [File](docs/Configuration.md#output-file), [GIT](docs/Configuration.md#output-git), [GIT-Crypt](docs/Configuration.md#output-git-crypt) and [HTTP](docs/Configuration.md#output-http). The file backend takes a destination directory as argument and will keep a file per device, with most recent running version of a device. The GIT backend (recommended) will initialize an empty GIT repository in the specified path and create a new commit on every configuration change. The GIT-Crypt backend will also initialize a GIT repository but every configuration push to it will be encrypted on the fly by using `git-crypt` tool. Take a look at the [Configuration](docs/Configuration.md) for more details. Maps define how to map a model's fields to model [model fields](https://github.com/ytti/oxidized/tree/master/lib/oxidized/model). Most of the settings should be self explanatory, log is ignored if `use_syslog`(requires Ruby >= 2.0) is set to `true`. diff --git a/lib/oxidized/model/comware.rb b/lib/oxidized/model/comware.rb index d926854..a5b7190 100644 --- a/lib/oxidized/model/comware.rb +++ b/lib/oxidized/model/comware.rb @@ -1,8 +1,8 @@ class Comware < Oxidized::Model # HP (A-series)/H3C/3Com Comware - # sometimes the prompt might have a leading nul - prompt /^\0*(<[\w.-]+>)$/ + # sometimes the prompt might have a leading nul or trailing ASCII Bell (^G) + prompt /^\0*(<[\w.-]+>).?$/ comment '# ' # example how to handle pager -- cgit v1.2.1 From 40cfa7b7cfba0d0a655fe2148ad9336414e89737 Mon Sep 17 00:00:00 2001 From: pv2b Date: Wed, 15 Nov 2017 23:02:27 +0100 Subject: fix: Netgear model: Permit . as valid character in prompt (#1099) --- lib/oxidized/model/netgear.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/netgear.rb b/lib/oxidized/model/netgear.rb index 38aaca7..0ab1349 100644 --- a/lib/oxidized/model/netgear.rb +++ b/lib/oxidized/model/netgear.rb @@ -1,7 +1,7 @@ class Netgear < Oxidized::Model comment '!' - prompt /^(\([\w-]+\)\s[#>])$/ + prompt /^(\([\w\-.]+\)\s[#>])$/ cmd :secret do |cfg| cfg.gsub!(/password (\S+)/, 'password ') -- cgit v1.2.1 From 77e5c874896e8f17aa32fa40b96196a8d2932ff5 Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Sat, 18 Nov 2017 03:57:16 -0600 Subject: docs: Misc Doc updates (#1107) * Move VRP-Huawei.md to new Model-Notes subdir * Update Sources.md with a few improvements: 1. Sync the example table name between the MySQL and SQLite example configs for consistency. 2. Document the very useful custom SQL query parameter (query:) including a couple of examples. * Basic README.md for Model-Notes directory with a simple table for notes/caveats * Markdown quote the Huawei config blocks and link back to README.md * Update Sources.md --- docs/Model-Notes/README.md | 17 +++++++++++++++++ docs/Model-Notes/VRP-Huawei.md | 34 ++++++++++++++++++++++++++++++++++ docs/Sources.md | 36 +++++++++++++++++++++++++++++++++--- docs/VRP-Huawei.md | 27 --------------------------- 4 files changed, 84 insertions(+), 30 deletions(-) create mode 100644 docs/Model-Notes/README.md create mode 100644 docs/Model-Notes/VRP-Huawei.md delete mode 100644 docs/VRP-Huawei.md diff --git a/docs/Model-Notes/README.md b/docs/Model-Notes/README.md new file mode 100644 index 0000000..15ab445 --- /dev/null +++ b/docs/Model-Notes/README.md @@ -0,0 +1,17 @@ + + +Model Notes +======================== + + +This directory contains implemention 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 +----------------|-----------------|---------------- +Huawei|[VRP](VRP-Huawei.md)|17 Nov 2017 + + +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/VRP-Huawei.md b/docs/Model-Notes/VRP-Huawei.md new file mode 100644 index 0000000..d03c752 --- /dev/null +++ b/docs/Model-Notes/VRP-Huawei.md @@ -0,0 +1,34 @@ +Huawei VRP Configuration +======================== + +Create a user with no privileges + +``` + system-view + [~HUAWEI] aaa + [~HUAWEI-aaa] local-user oxidized password irreversible-cipher verysecret + [*HUAWEI-aaa] local-user oxidized level 1 + [*HUAWEI-aaa] local-user oxidized service-type terminal ssh + [*HUAWEI-aaa] commit +``` + +The commands Oxidized executes are: + +1. screen-length 0 temporary +2. display version +3. display device +4. display current-configuration all + +Command 2 and 3 can be executed without issues, but 1 and 4 are only available for higher level users. Instead of making Oxidized a read/write user on your device, lower the priviledge-level for commands 1 and 4: + +``` + system-view + [~HUAWEI] command-privilege level 1 view global display current-configuration all + [*HUAWEI] command-privilege level 1 view shell screen-length + [*HUAWEI] commit +``` + +Oxidized can now retrieve your configuration! + + +Back to [Model-Notes](README.md) diff --git a/docs/Sources.md b/docs/Sources.md index 4121c89..0a6d1d7 100644 --- a/docs/Sources.md +++ b/docs/Sources.md @@ -61,8 +61,8 @@ source: default: sql sql: adapter: sqlite - database: "/var/lib/oxidized/devices.db" - table: devices + database: "/var/lib/oxidized/nodes.db" + table: nodes map: name: fqdn model: model @@ -72,6 +72,36 @@ source: enable: enable ``` +### Custom SQL Query Support + +You may also implement a custom SQL query to retreive the nodelist using SQL syntax with the `query:` configuration parameter under the `sql:` stanza. + + +#### Custom SQL Query Examples + +You may have a table named `nodes` which contains a boolean to indicate if the nodes should be enabled (fetched via oxidized). This can be used in the custom SQL query to avoid fetching from known impacted nodes. + +In your configuration, you would add the `query:` parameter and specify the SQL query. Make sure to put this within the `sql:` configuration section. + +```sql +query: "SELECT * FROM nodes WHERE enabled = True" +``` + +Since this is an SQL query, you can also provide a more advanced query to assist in more complicated oxidized deployments. The exact deployment is up to you on how you design your database and oxidized fetchers. + +In this example we limit the nodes to two "POPs" of `mypop1` and `mypop2`. We also require the nodes to have the `enabled` boolean set to `True`. + +```sql +query: "SELECT * FROM nodes WHERE pop IN ('mypop1','mypop2') AND enabled = True" +``` +The order of the nodes returned will influence the order that nodes are fetched by oxidized. You can use standard SQL `ORDER BY` clauses to influence the node order. + +You should always test your SQL query before using it in the oxidized configuration as there is no syntax or error checking performed before sending it to the database engine. + +Consult your database documentation for more information on query language and table optimization. + + + ### Source: HTTP One object per device. @@ -107,4 +137,4 @@ source: url: https://url/api scheme: https secure: false -``` \ No newline at end of file +``` diff --git a/docs/VRP-Huawei.md b/docs/VRP-Huawei.md deleted file mode 100644 index 9e97b7d..0000000 --- a/docs/VRP-Huawei.md +++ /dev/null @@ -1,27 +0,0 @@ -Huawei VRP Configuration -======================== - -Create a user with no privileges - - system-view - [~HUAWEI] aaa - [~HUAWEI-aaa] local-user oxidized password irreversible-cipher verysecret - [*HUAWEI-aaa] local-user oxidized level 1 - [*HUAWEI-aaa] local-user oxidized service-type terminal ssh - [*HUAWEI-aaa] commit - -The commands Oxidized executes are: - -1. screen-length 0 temporary -2. display version -3. display device -4. display current-configuration all - -Command 2 and 3 can be executed without issues, but 1 and 4 are only available for higher level users. Instead of making Oxidized a read/write user on your device, lower the priviledge-level for commands 1 and 4: - - system-view - [~HUAWEI] command-privilege level 1 view global display current-configuration all - [*HUAWEI] command-privilege level 1 view shell screen-length - [*HUAWEI] commit - -Oxidized can now retrieve your configuration! \ No newline at end of file -- cgit v1.2.1 From 8bef76580a3e848836f3f12fe9e6c50380dbe01e Mon Sep 17 00:00:00 2001 From: pv2b Date: Sat, 18 Nov 2017 10:59:28 +0100 Subject: model: Procurve Handle switch selection for stack commanders (#1104) When trying to connect to a HP Procurve Switch with stacking enabled, you are asked to choose which switch to connect to to manage. This patch makes it so that if this question is encountered, just press "Enter" to choose the stack commander. This won't make backing up stack members work (they still need to be configured seperately and given IP addresses, making stacking useless) but at least it makes it possible to back up a commander in a stack seperately. Fixed #1070 Credit to @stiltzkin10 for this fix. --- lib/oxidized/model/procurve.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 180b703..11d7ea9 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -21,6 +21,11 @@ class Procurve < Oxidized::Model "" end + expect /Enter switch number/ do + send "\n" + "" + end + cmd :all do |cfg| cfg = cfg.each_line.to_a[1..-2].join cfg = cfg.gsub /^\r/, '' -- cgit v1.2.1 From 115764f3b2d20b3732a8d81c38afaea19c11dad8 Mon Sep 17 00:00:00 2001 From: pv2b Date: Mon, 20 Nov 2017 09:16:44 +0100 Subject: feature: Added model information to exec hook (#1105) * Add OX_NODE_MODEL to exec hook * Update docs to reflect added OX_NODE_MSG to hook --- docs/Hooks.md | 1 + lib/oxidized/hook/exec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/Hooks.md b/docs/Hooks.md index 7d503a3..fab4025 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -26,6 +26,7 @@ OX_NODE_IP OX_NODE_FROM OX_NODE_MSG OX_NODE_GROUP +OX_NODE_MODEL OX_JOB_STATUS OX_JOB_TIME OX_REPO_COMMITREF diff --git a/lib/oxidized/hook/exec.rb b/lib/oxidized/hook/exec.rb index a9a5950..3f984c2 100644 --- a/lib/oxidized/hook/exec.rb +++ b/lib/oxidized/hook/exec.rb @@ -71,6 +71,7 @@ class Exec < Oxidized::Hook "OX_NODE_FROM" => ctx.node.from.to_s, "OX_NODE_MSG" => ctx.node.msg.to_s, "OX_NODE_GROUP" => ctx.node.group.to_s, + "OX_NODE_MODEL" => ctx.node.model.class.name, "OX_REPO_COMMITREF" => ctx.commitref.to_s, "OX_REPO_NAME" => ctx.node.repo.to_s, ) -- cgit v1.2.1 From 99220b9947946d5ad1e53cba6a343e942ce0c498 Mon Sep 17 00:00:00 2001 From: pv2b Date: Tue, 21 Nov 2017 09:03:48 +0100 Subject: model: Added support for Opnsense (#1111) * Add OPNsense model * Fix class name * Mention support for OPNsense in Supported OS types --- docs/Supported-OS-Types.md | 1 + lib/oxidized/model/opnsense.rb | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 lib/oxidized/model/opnsense.rb diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 9176f2e..99566c4 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -117,6 +117,7 @@ * [OneOS](/lib/oxidized/model/oneos.rb) * Opengear * [Opengear](/lib/oxidized/model/opengear.rb) + * [OPNsense](/lib/oxidized/model/opnsense.rb) * Palo Alto * [PANOS](/lib/oxidized/model/panos.rb) * [PLANET SG/SGS Switches](/lib/oxidized/model/planet.rb) diff --git a/lib/oxidized/model/opnsense.rb b/lib/oxidized/model/opnsense.rb new file mode 100644 index 0000000..b874fca --- /dev/null +++ b/lib/oxidized/model/opnsense.rb @@ -0,0 +1,21 @@ +class OpnSense < Oxidized::Model + + # minimum required permissions: "System: Shell account access" + # must enable SSH and password-based SSH access + + cmd :all do |cfg| + cfg.each_line.to_a[1..-1].join + end + + cmd 'cat /conf/config.xml' do |cfg| + cfg.gsub! /\s\s*