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 fd1b2c2ac903b3a8e2578a4ca0f48a61309a0493 Mon Sep 17 00:00:00 2001 From: Ilya Demyanov Date: Sun, 31 Dec 2017 09:19:49 +0300 Subject: Create snr.rb --- lib/oxidized/model/snr.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/oxidized/model/snr.rb diff --git a/lib/oxidized/model/snr.rb b/lib/oxidized/model/snr.rb new file mode 100644 index 0000000..3f1fab5 --- /dev/null +++ b/lib/oxidized/model/snr.rb @@ -0,0 +1,14 @@ +class SNR < Oxidized::Model + + comment '!' + + cmd 'show running-config' do |cfg| + cfg = cfg.each_line.to_a[1..-1] + end + + cfg :ssh do + post_login 'terminal length 0' + pre_logout 'exit' + end + +end -- cgit v1.2.1 From 9a134db581c8618c703b35960796e9b4b14c2be3 Mon Sep 17 00:00:00 2001 From: Alexandre-io Date: Thu, 12 Oct 2017 18:29:36 +0200 Subject: Fix prompt pattern for firewareos clusters and standalone --- lib/oxidized/model/firewareos.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/firewareos.rb b/lib/oxidized/model/firewareos.rb index f456c60..1b3d07c 100644 --- a/lib/oxidized/model/firewareos.rb +++ b/lib/oxidized/model/firewareos.rb @@ -1,6 +1,6 @@ class FirewareOS < Oxidized::Model - prompt /^([\w.@-]+[#>]\s?)$/ + prompt /^\[?\w*\]?\w*?(<\w*>)?(#|>)\s*$/ comment '-- ' cmd :all do |cfg| -- cgit v1.2.1 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(+) 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.1 From 72397c4f344ab97fe3db1e381a3e5e1b1a935c62 Mon Sep 17 00:00:00 2001 From: Jason Ackley Date: Tue, 27 Feb 2018 08:58:59 -0600 Subject: model: Added support for ArbOS from Arbor Networks. (#1096) * Basic support for ArbOS from Arbor Networks. ArbOS is the generic name for Arbor Networks (https://www.arbornetworks.com/) OS that runs on some of their devices. Found and imported from https://github.com/claranet/oxidized . Credit to Claranet for the creation. Locally validated on Peakflow SP v8.2+ The module is quite simple as the command 'config show' automatically disables pagination. There is a pagination-enabled version of the command as well. * Added model notes for ArbOS --- docs/Model-Notes/ArbOS.md | 10 ++++++++++ docs/Model-Notes/README.md | 1 + docs/Supported-OS-Types.md | 2 ++ lib/oxidized/model/arbos.rb | 27 +++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 docs/Model-Notes/ArbOS.md create mode 100644 lib/oxidized/model/arbos.rb diff --git a/docs/Model-Notes/ArbOS.md b/docs/Model-Notes/ArbOS.md new file mode 100644 index 0000000..0f5b628 --- /dev/null +++ b/docs/Model-Notes/ArbOS.md @@ -0,0 +1,10 @@ +Arbor Networks ArbOS notes +========================== + +If you are running ArbOS version 7 or lower then you may need to update the model to remove `exec true`: + +``` + cfg :ssh do + pre_logout 'exit' + end +``` diff --git a/docs/Model-Notes/README.md b/docs/Model-Notes/README.md index 6a64058..9d7db32 100644 --- a/docs/Model-Notes/README.md +++ b/docs/Model-Notes/README.md @@ -12,6 +12,7 @@ Use the table below for more information on the Vendor/Model caveats. Vendor | Model |Updated ----------------|-----------------|---------------- 3COM|[Comware](Comware.md)|15 Feb 2018 +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)|23 Jan 2018 diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index a12f5ef..d6d718f 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -17,6 +17,8 @@ * [BreezeACCESS](/lib/oxidized/model/alvarion.rb) * APC * [AOS](/lib/oxidized/model/apc_aos.rb) + * Arbor Networks + * [ArbOS](/lib/oxidized/model/arbos.rb) * Arista * [EOS](/lib/oxidized/model/eos.rb) * Arris diff --git a/lib/oxidized/model/arbos.rb b/lib/oxidized/model/arbos.rb new file mode 100644 index 0000000..389f3f6 --- /dev/null +++ b/lib/oxidized/model/arbos.rb @@ -0,0 +1,27 @@ +class ARBOS < Oxidized::Model + + # Arbor OS model # + + prompt /^[\S\s]+\n([\w.@-]+[:\/#>]+)\s?$/ + comment '# ' + + cmd 'system hardware' do |cfg| + cfg.gsub! /^Boot\ time\:\s.+/, '' # Remove boot timer + cfg.gsub! /^Load\ averages\:\s.+/, '' # Remove CPU load info + cfg = cfg.each_line.to_a[2..-1].join + comment cfg + end + + cmd 'system version' do |cfg| + comment cfg + end + + cmd 'config show' do |cfg| + cfg + end + + cfg :ssh do + exec true + pre_logout 'exit' + end +end -- cgit v1.2.1 From 34cdbeb75f3c74d803fb60c509fc06e4f6365f0c Mon Sep 17 00:00:00 2001 From: Zachary Puls Date: Tue, 27 Feb 2018 09:22:32 -0600 Subject: model: Added "commands" flag to "show configuration" on VyOS/Vyatta/EdgeOS (#1164) --- lib/oxidized/model/edgeos.rb | 2 +- lib/oxidized/model/vyatta.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/oxidized/model/edgeos.rb b/lib/oxidized/model/edgeos.rb index 2a8d663..bb0aab5 100644 --- a/lib/oxidized/model/edgeos.rb +++ b/lib/oxidized/model/edgeos.rb @@ -13,7 +13,7 @@ class Edgeos < Oxidized::Model cfg end - cmd 'show configuration | no-more' + cmd 'show configuration commands | no-more' cfg :telnet do username /login:\s/ diff --git a/lib/oxidized/model/vyatta.rb b/lib/oxidized/model/vyatta.rb index 8d977aa..aa0bc74 100644 --- a/lib/oxidized/model/vyatta.rb +++ b/lib/oxidized/model/vyatta.rb @@ -13,7 +13,7 @@ class Vyatta < Oxidized::Model cfg end - cmd 'show configuration | no-more' + cmd 'show configuration commands | no-more' cfg :telnet do username /login:\s/ -- cgit v1.2.1 From 692a5c0d61f4900c07b859afff5affa86ccb8505 Mon Sep 17 00:00:00 2001 From: Adam Furman Date: Sat, 10 Mar 2018 12:55:39 -0800 Subject: Add fortios fields to be masked by remove_secret flag --- lib/oxidized/model/fortios.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb index bffaf3c..23370c4 100644 --- a/lib/oxidized/model/fortios.rb +++ b/lib/oxidized/model/fortios.rb @@ -15,7 +15,7 @@ class FortiOS < Oxidized::Model end cmd :secret do |cfg| - cfg.gsub! /(set (?:passwd|password|psksecret|secret|key|group-password|secondary-secret|tertiary-secret|auth-password-l1|auth-password-l2|rsso|history0|history1|inter-controller-key ENC)).*/, '\\1 ' + cfg.gsub! /(set (?:passwd|password|psksecret|secret|key|group-password|secondary-secret|tertiary-secret|auth-password-l1|auth-password-l2|rsso|history0|history1|inter-controller-key ENC|passphrase ENC|login-passwd ENC)).*/, '\\1 ' cfg.gsub! /(set private-key).*-+END ENCRYPTED PRIVATE KEY-*"$/m , '\\1 ' cfg.gsub! /(set ca ).*-+END CERTIFICATE-*"$/m , '\\1 ' cfg.gsub! /(set csr ).*-+END CERTIFICATE REQUEST-*"$/m , '\\1 ' @@ -63,4 +63,3 @@ cfg << cmd('end') if @vdom_enabled end end - -- cgit v1.2.1 From 04c61e0a5cf4ee21158cbc5d827682bda525f82a Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sun, 11 Mar 2018 22:21:04 +0100 Subject: Refresh Dockerfile Refresh Dockerfile to resolve multiple issues: * Bump base image from 0.9.18 to 0.10.0 (now xenial based). * Remove dependency on ppa:brightbox and use xenial ruby2.3 * Split build into 2 stages to backport libssh2 1.7.0 which is needed for githubrepo hook but is not available in xenial * Misc cleanup and comments --- Dockerfile | 56 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index e72a449..36c650c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,38 @@ -FROM phusion/baseimage:0.9.18 -MAINTAINER Samer Abdel-Hafez - -RUN add-apt-repository ppa:brightbox/ruby-ng && \ - apt-get update && \ - apt-get install -y ruby2.3 ruby2.3-dev libsqlite3-dev libssl-dev pkg-config make cmake libssh2-1-dev git g++ libffi-dev - -RUN mkdir -p /tmp/oxidized +# -- stage 1: backport libssh2 1.7.0 from zesty for xenial, as githubrepo hook requires it +FROM ubuntu:xenial as libssh2-backport + +# set up dependencies for the build process +RUN apt-get -yq update && \ + apt-get -yq install build-essential chrpath debhelper dh-autoreconf libgcrypt20-dev zlib1g-dev + +# build libssh2 1.7.0 +WORKDIR /tmp/libssh2-build +ADD https://launchpad.net/ubuntu/+archive/primary/+files/libssh2_1.7.0-1ubuntu1.debian.tar.xz . +ADD https://launchpad.net/ubuntu/+archive/primary/+files/libssh2_1.7.0.orig.tar.gz . +RUN tar xvf libssh2_1.7.0.orig.tar.gz +WORKDIR /tmp/libssh2-build/libssh2-1.7.0 +RUN tar xvf ../libssh2_1.7.0-1ubuntu1.debian.tar.xz + +WORKDIR /tmp/libssh2-build/libssh2-1.7.0 +ENV DEB_BUILD_OPTIONS nocheck +RUN dpkg-buildpackage -b + +# -- stage 2: build the actual oxidized container +FROM phusion/baseimage:0.10.0 +LABEL maintainer="Samer Abdel-Hafez " + +# set up dependencies for the build process +RUN apt-get -yq update && \ + apt-get -yq install ruby2.3 ruby2.3-dev libsqlite3-dev libssl-dev pkg-config make cmake libssh2-1-dev git g++ libffi-dev + +# upgrade libssh2 to self-built backport from stage 1 +COPY --from=libssh2-backport \ + /tmp/libssh2-build/libssh2-1_1.7.0-1ubuntu1_amd64.deb \ + /tmp/libssh2-build/libssh2-1-dev_1.7.0-1ubuntu1_amd64.deb \ + /tmp/ +RUN dpkg -i /tmp/*.deb + +# build and install oxidized COPY . /tmp/oxidized/ WORKDIR /tmp/oxidized @@ -16,16 +43,15 @@ RUN gem install oxidized-*.gem RUN gem install oxidized-web --no-ri --no-rdoc # dependencies for hooks -RUN gem install aws-sdk -RUN gem install slack-api -RUN gem install xmpp4r +RUN gem install aws-sdk slack-api xmpp4r +# clean up +WORKDIR / RUN rm -rf /tmp/oxidized +RUN rm /tmp/*.deb +RUN apt-get -yq --purge autoremove ruby-dev pkg-config make cmake -RUN apt-get remove -y ruby-dev pkg-config make cmake - -RUN apt-get -y autoremove - +# add runit services ADD extra/oxidized.runit /etc/service/oxidized/run ADD extra/auto-reload-config.runit /etc/service/auto-reload-config/run ADD extra/update-ca-certificates.runit /etc/service/update-ca-certificates/run -- cgit v1.2.1 From ad2a0675edee605bda8fe460b3656857eb050129 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sun, 11 Mar 2018 23:11:13 +0100 Subject: Introduce support for OXIDIZED_SSH_PASSPHRASE --- docs/Hooks.md | 2 ++ lib/oxidized/hook/githubrepo.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Hooks.md b/docs/Hooks.md index fab4025..080d301 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -67,6 +67,8 @@ This hook configures the repository `remote` and _push_ the code when the specif * `publickey`: publickey for repository auth. * `privatekey`: privatekey 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. ``` yaml diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb index d33e54e..f74b22a 100644 --- a/lib/oxidized/hook/githubrepo.rb +++ b/lib/oxidized/hook/githubrepo.rb @@ -51,7 +51,7 @@ class GithubRepo < Oxidized::Hook else if cfg.has_key?('publickey') && cfg.has_key?('privatekey') log "Using ssh auth with key", :debug - Rugged::Credentials::SshKey.new(username: 'git', publickey: File.expand_path(cfg.publickey), privatekey: File.expand_path(cfg.privatekey)) + Rugged::Credentials::SshKey.new(username: 'git', publickey: File.expand_path(cfg.publickey), privatekey: File.expand_path(cfg.privatekey), passphrase: ENV["OXIDIZED_SSH_PASSPHRASE"]) else log "Using ssh auth with agentforwarding", :debug Rugged::Credentials::SshKeyFromAgent.new(username: 'git') -- cgit v1.2.1 From 87600b1f5f12711afe29c408e02dbbd927e3f25d Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Mon, 12 Mar 2018 00:19:20 +0100 Subject: Lint and standardize markdown documentation --- CHANGELOG.md | 610 ++++++++++++++++++++------------------ README.md | 83 +++--- TODO.md | 52 ++-- docs/Configuration.md | 58 ++-- docs/Hooks.md | 78 ++--- docs/Model-Notes/AireOS.md | 8 +- docs/Model-Notes/ArbOS.md | 2 +- docs/Model-Notes/Comware.md | 10 +- docs/Model-Notes/JunOS.md | 14 +- docs/Model-Notes/README.md | 8 +- docs/Model-Notes/VRP-Huawei.md | 5 +- docs/Model-Notes/XGS4600-Zyxel.md | 13 +- docs/Outputs.md | 42 ++- docs/Ruby-API.md | 46 ++- docs/Sources.md | 48 +-- docs/Supported-OS-Types.md | 317 ++++++++++---------- 16 files changed, 736 insertions(+), 658 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e77026..0e03883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,286 +1,324 @@ -# 0.21.0 -- FEATURE: routeros include system history (@InsaneSplash) -- FEATURE: vrp added support for removing secrets (@bheum) -- FEATURE: hirschmann model (@OCangrand) -- FEATURE: asa added multiple context support (@marnovdm) -- FEATURE: procurve added additional output (@davama) -- FEATURE: Updated git commits to bare repo + drop need for temp dir during clone (@asenci) -- FEATURE: asyncos model (@cd67-usrt) -- FEATURE: ciscosma model (@cd67-usrt) -- FEATURE: procurve added transceiver info (@davama) -- FEATURE: routeros added remove_secret option (@spinza) -- FEATURE: Updated net-ssh version (@Fauli83) -- FEATURE: audiocodes model (@Fauli83) -- FEATURE: Added docs for Huawei VRP devices (@tuxis-ie) -- FEATURE: ciscosmb added radius key detection (@davama) -- FEATURE: radware model (@sfini) -- FEATURE: enterasys model (@koenvdheuvel) -- FEATURE: weos model (@ignaqui) -- FEATURE: hpemsa model (@aschaber1) -- FEATURE: Added nodes_done hook (@danilopopeye) -- FEATURE: ucs model (@WiXZlo) -- FEATURE: acsw model (@sfini) -- FEATURE: aen model (@ZacharyPuls) -- FEATURE: coriantgroove model (@nickhilliard) -- FEATURE: sgos model (@seekerOK) -- FEATURE: powerconnect support password removal (@tobbez) -- FEATURE: Added haproxy example for Ubuntu (@denvera) -- BUGFIX: fiberdriver remove configuration generated on from diff (@emjemj) -- BUGFIX: Fix email pass through (@ZacharyPuls) -- BUGFIX: iosxr suppress timestamp (@ja-frog) -- BUGFIX: ios allow lowercase user/pass prompt (@deepseth) -- BUGFIX: Use git show instead of git diff (@asenci) -- BUGFIX: netgear fixed sending enable password and exit/quit (@candlerb) -- BUGFIX: ironware removed space requirement from password prompt (@crami) -- BUGFIX: dlink removed uptime from diff (@rfdrake) -- BUGFIX: planet removed temp from diff (@flokli) -- BUGFIX: ironware removed fan, temp and flash from diff (@Punicaa) -- BUGFIX: panos changed exit to quit (@goebelmeier) -- BUGFIX: fortios remove FDS address from diffs (@bheum) -- BUGFIX: fortios remove additional secrets from diffs (@brunobritocarvalho) -- BUGFIX: fortios remove IPS URL DB (@brunobritocarvalho) -- BUGFIX: voss remove temperature, power and uptime from diff (@ospfbgp) - -# 0.20.0 -- FEATURE: gpg support for CSV source (@elmobp) -- FEATURE: slackdiff (@natm) -- FEATURE: gitcrypt output model (@clement-parisot) -- FEATURE: model specific credentials (@davromaniak) -- FEATURE: hierarchical json in http source model -- FEATURE: next-adds-job config toggle (to add new job when ever /next is called) -- FEATURE: netgear model (@aschaber1) -- FEATURE: zhone model (@rfdrake) -- FEATURE: tplink model (@mediumo) -- FEATURE: oneos model (@crami) -- FEATURE: cisco NGA model (@udhos) -- FEATURE: voltaire model (@clement-parisot) -- FEATURE: siklu model (@bdg-robert) -- FEATURE: voss model (@ospfbgp) -- BUGFIX: ios, cumulus, ironware, nxos, fiberdiver, aosw, fortios, comware, procurve, opengear, timos, routeros, junos, asa, aireos, mlnxos, pfsense, saos, powerconnect, firewareos, quantaos - -# 0.19.0 -- FEATURE: allow setting ssh_keys (not relying on openssh config) (@denvera) -- FEATURE: fujitsupy model (@stokbaek) -- FEATURE: fiberdriver model (@emjemj) -- FEATURE: hpbladesystems model (@flokli) -- FEATURE: planetsgs model (@flokli) -- FEATURE: trango model (@rfdrake) -- FEATURE: casa model (@rfdrake) -- FEATURE: dlink model (@rfdrake) -- FEATURE: hatteras model (@rfdrake) -- FEATURE: ability to ignore SSL certs in http (@laf) -- FEATURE: awsns hooks, publish messages to AWS SNS topics (@natm) -- BUGFIX: pfsense, dnos, powerconnect, ciscosmb, eos, aosw - -# 0.18.0 -- FEATURE: APC model (by @davromaniak ) -- BUGFIX: ironware, aosw -- BUGFIX: interpolate nil, false, true for node vars too - -# 0 17.0 -- FEATURE: "nil", "false" and "true" in source (e.g. router.db) are interpeted as nil, false, true. Empty is now always considered empty string, instead of in some cases nil and some cases empty string. -- FEATURE: support tftp as input model (@MajesticFalcon) -- FEATURE: add alvarion model (@MajesticFalcon) -- FEATURE: detect if ssh wants password terminal/CLI prompt or not -- FEATURE: node (group, model, username, password) resolution refactoring, supports wider range of use-cases -- BUGFIX: fetch for file output (@danilopopeye) -- BUGFIX: net-ssh version specification -- BUGFIX: routeros, catos, pfsense - -# 0.16.3 -- FEATURE: pfsense support (by @stokbaek) -- BUGFIX: cumulus prompt not working with default switch configs (by @nertwork) -- BUGFIX: disconnect ssh when prompt wasn't found (by @andir) -- BUGFIX: saos, asa, acos, timos updates, cumulus - -# 0.16.2 -- BUGFIX: when not using git (by @danilopopeye) -- BUGFIX: screenos update - -# 0.16.1 -- BUGFIX: unnecessary puts statement removed from git.rb - -# 0.16.0 -- FEATURE: support Gaia OS devices (by @totosh) -- BUGFIX: #fetch, #version fixes in nodes.rb (by @danilopopeye) -- BUGFIX: procurve - -# 0.15.0 -- FEATURE: disable periodic collection, only on demand (by Adam Winberg) -- FEATURE: allow disabling ssh exec mode always (mainly for oxidized-script) (by @nickhilliard) -- FEATURE: support mellanox devices (by @ham5ter) -- FEATURE: support firewireos devices (by @alexandre-io) -- FEATURE: support quanta devices (by @f0o) -- FEATURE: support tellabs coriant8800, coriant8600 (by @udhos) -- FEATURE: support brocade6910 (by @cardboardpig) -- BUGFIX: debugging, tests (by @ElvinEfendi) -- BUGFIX: nos, panos, acos, procurve, eos, edgeswitch, aosw, fortios updates - -# 0.14.3 -- BUGFIX: fix git when using multiple groups without single_repo - -# 0.14.2 -- BUGFIX: git expand path for all groups -- BUGFIX: git get_version, teletubbies do it again -- BUGFIX: comware, acos, procurve models - -# 0.14.1 -- BUGFIX: git get_version when groups and single_repo are used - -# 0.14.0 -- FEATURE: support supermicro swithes (by @funzoneq) -- FEATURE: support catos switches -- BUGFIX: git+groups+singlerepo (by @PANZERBARON) -- BUGFIX: asa, tmos, ironware, ios-xr -- BUGFIX: mandate net-ssh 3.0.x, don't accept 3.1 (numerous issues) - -# 0.13.1 -- BUGFIX: file permissions (Sigh...) - -# 0.13.0 -- FEATURE: http post for configs (by @jgroom33) -- FEATURE: support ericsson redbacks (by @roedie) -- FEATURE: support motorola wireless controllers (by @roadie) -- FEATURE: support citrix netscaler (by @roadie) -- FEATURE: support datacom devices (by @danilopopeye) -- FEATURE: support netonix devices -- FEATURE: support specifying ssh cipher and kex (by @roadie) -- FEATURE: rename proxy to ssh_proxy (by @roadie) -- FEATURE: support ssh keys on ssh_proxy (by @awix) -- BUGFIX: various (by @danilopopeye) -- BUGFIX: Node#repo with groups (by @danilopopeye) -- BUGFIX: githubrepohoook (by @danilopopeye) -- BUGFIX: fortios, airos, junos, xos, edgeswitch, nos, tmos, procurve, ipos models - -# 0.12.2 -- BUGFIX: more MRV model fixes (by @natm) - -# 0.12.1 -- BUGFIX: set term to vty100 -- BUGFIX: MRV model fixes (by @natm) - -# 0.12.0 -- FEATURE: enhance AOSW (by @mikebryant) -- FEATURE: F5 TMOS support (by @mikebryant) -- FEATURE: Opengear support (by @mikebryant) -- FEATURE: EdgeSwitch support (by @doogieconsulting) -- BUGFIX: rename input debug log files -- BUGFIX: powerconnect model fixes (by @Madpilot0) -- BUGFIX: fortigate model fixes (by @ElvinEfendi) -- BUGFIX: various (by @mikebryant) -- BUGFIX: write SSH debug to file without buffering -- BUGFIX: fix IOS XR prompt handling - -# 0.11.0 -- FEATURE: ssh proxycommand (by @ElvinEfendi) -- FEATURE: basic auth in HTTP source (by @laf) -- BUGFIX: do not inject string to output before model gets it -- BUGFIX: store pidfile in oxidized root - -# 0.10.0 -- FEATURE: Various refactoring (by @ElvinEfendi) -- FEATURE: Ciena SOAS support (by @jgroom33) -- FEATURE: support group variables (by @supertylerc) -- BUGFIX: various ((orly)) (by @marnovdm, @danbaugher, @MrRJ45, @asynet, @nickhilliard) - -# 0.9.0 -- FEATURE: input log now uses devices name as file, instead of string from config (by @skoef) -- FEATURE: Dell Networkign OS (dnos) support (by @erefre) -- BUGFIX: CiscoSMB, powerconnect, comware, xos, ironware, nos fixes - -# 0.8.1 -- BUGFIX: restore ruby 1.9.3 compatibility - -# 0.8.0 -- FEATURE: hooks (by @aakso) -- FEATURE: MRV MasterOS support (by @kwibbly) -- FEATURE: EdgeOS support (by @laf) -- FEATURE: FTP input and Zyxel ZynOS support (by @ytti) -- FEATURE: version and diffs API For oxidized-web (by @FlorianDoublet) -- BUGFIX: aosw, ironware, routeros, xos models -- BUGFIX: crash with 0 nodes -- BUGFIX: ssh auth fail without keyboard-interactive -- Full changelog https://github.com/ytti/oxidized/compare/0.7.1...HEAD - -# 0.7.0 -- FEATURE: support http source (by @laf) -- FEATURE: support Palo Alto PANOS (by @rixxxx) -- BUGFIX: screenos fixes (by @rixxxx) -- BUGFIX: allow 'none' auth in ssh (spotted by @SaldoorMike, needed by ciscosmb+aireos) - -# 0.6.0 -- FEATURE: support cumulus linux (by @FlorianDoublet) -- FEATURE: support HP Comware SMB siwtches (by @sid3windr) -- FEATURE: remove secret additions (by @rodecker) -- FEATURE: option to put all groups in single repo (by @ytti) -- FEATURE: expand path in source: csv: (so that ~/foo/bar works) (by @ytti) -- BUGFIX: screenos fixes (by @rixxxx) -- BUGFIX: ironware fixes (by @FlorianDoublet) -- BUGFIX: powerconnect fixes (by @sid3windr) -- BUGFIX: don't ask interactive password in new net/ssh (by @ytti) - -# 0.5.0 -- FEATURE: Mikrotik RouterOS model (by @emjemj) -- FEATURE: add support for Cisco VSS (by @MrRJ45) -- BUGFIX: general fixes to powerconnect model (by @MrRJ45) -- BUGFIX: fix initial commit issues with rugged (by @MrRJ45) -- BUGFIX: pager error for old dell powerconnect switches (by @emjemj) -- BUGFIX: logout error for old dell powerconnect switches (by @emjemj) - -# 0.4.1 -- BUGFIX: handle missing output file (by @brandt) -- BUGFIX: fix passwordless enable on Arista EOS model (by @brandt) - -# 0.4.0 -- FEATURE: allow setting IP address in addition to name in source (SQL/CSV) -- FEATURE: approximate how long it takes to get node from larger view than 1 -- FEATURE: unconditionally start new job if too long has passed since previous start -- FEATURE: add enable to Arista EOS model -- FEATURE: add rugged dependency in gemspec -- FEATURE: log prompt detection failures -- BUGFIX: xos while using telnet (by @fhibler) -- BUGFIX: ironware logout on some models (by @fhibler) -- BUGFIX: allow node to be removed while it is being collected -- BUGFIX: if model returns non string value, return empty string -- BUGFIX: better prompt for Arista EOS model (by @rodecker) -- BUGFIX: improved configuration handling for Arista EOS model (by @rodecker) - -# 0.3.0 -- FEATURE: *FIXME* bunch of stuff I did for richih, docs needed -- FEATURE: ComWare model (by erJasp) -- FEATURE: Add comment support for router.db file -- FEATURE: Add input debugging and related configuration options -- BUGFIX: Fix ASA model prompt -- BUGFIX: Fix Aruba model display -- BUGFIX: Fix changing output in PowerConnect model - -# 0.2.4 -- FEATURE: Cisco SMB (Nikola series VxWorks) model by @thetamind -- FEATURE: Extreme Networks XOS model (access by sjm) -- FEATURE: Brocade NOS (Network Operating System) (access by sjm) -- BUGFIX: Match exactly to node[:name] if node[name] is an ip address. - -# 0.2.3 -- BUGFIX: rescue @ssh.close when far end closes disgracefully (ALU ISAM) -- BUGFIX: bugfixes to models -- FEATURE: Alcatel-Lucent ISAM 7302/7330 model added by @jalmargyyk -- FEATURE: Huawei VRP model added by @jalmargyyk -- FEATURE: Ubiquiti AirOS added by @willglyn -- FEATURE: Support 'input' debug in config, ssh/telnet use it to write session log - -# 0.2.2 -- BUGFIX: mark node as failure if unknown error is raised - -# 0.2.1 -- BUGFIX: vars variable resolving for main level vars - -# 0.2.0 -- FEATURE: Force10 model added by @lysiszegerman -- FEATURE: ScreenOS model added by @lysiszegerman -- FEATURE: FabricOS model added by @thakala -- FEATURE: ASA model added by @thakala -- FEATURE: Vyattamodel added by @thakala -- BUGFIX: Oxidized::String convenience methods for models fixed - -# 0.1.1 -- BUGFIX: vars needs to return value of r, not value of evaluation +# Changelog + +## 0.21.0 + +* FEATURE: routeros include system history (@InsaneSplash) +* FEATURE: vrp added support for removing secrets (@bheum) +* FEATURE: hirschmann model (@OCangrand) +* FEATURE: asa added multiple context support (@marnovdm) +* FEATURE: procurve added additional output (@davama) +* FEATURE: Updated git commits to bare repo + drop need for temp dir during clone (@asenci) +* FEATURE: asyncos model (@cd67-usrt) +* FEATURE: ciscosma model (@cd67-usrt) +* FEATURE: procurve added transceiver info (@davama) +* FEATURE: routeros added remove_secret option (@spinza) +* FEATURE: Updated net-ssh version (@Fauli83) +* FEATURE: audiocodes model (@Fauli83) +* FEATURE: Added docs for Huawei VRP devices (@tuxis-ie) +* FEATURE: ciscosmb added radius key detection (@davama) +* FEATURE: radware model (@sfini) +* FEATURE: enterasys model (@koenvdheuvel) +* FEATURE: weos model (@ignaqui) +* FEATURE: hpemsa model (@aschaber1) +* FEATURE: Added nodes_done hook (@danilopopeye) +* FEATURE: ucs model (@WiXZlo) +* FEATURE: acsw model (@sfini) +* FEATURE: aen model (@ZacharyPuls) +* FEATURE: coriantgroove model (@nickhilliard) +* FEATURE: sgos model (@seekerOK) +* FEATURE: powerconnect support password removal (@tobbez) +* FEATURE: Added haproxy example for Ubuntu (@denvera) +* BUGFIX: fiberdriver remove configuration generated on from diff (@emjemj) +* BUGFIX: Fix email pass through (@ZacharyPuls) +* BUGFIX: iosxr suppress timestamp (@ja-frog) +* BUGFIX: ios allow lowercase user/pass prompt (@deepseth) +* BUGFIX: Use git show instead of git diff (@asenci) +* BUGFIX: netgear fixed sending enable password and exit/quit (@candlerb) +* BUGFIX: ironware removed space requirement from password prompt (@crami) +* BUGFIX: dlink removed uptime from diff (@rfdrake) +* BUGFIX: planet removed temp from diff (@flokli) +* BUGFIX: ironware removed fan, temp and flash from diff (@Punicaa) +* BUGFIX: panos changed exit to quit (@goebelmeier) +* BUGFIX: fortios remove FDS address from diffs (@bheum) +* BUGFIX: fortios remove additional secrets from diffs (@brunobritocarvalho) +* BUGFIX: fortios remove IPS URL DB (@brunobritocarvalho) +* BUGFIX: voss remove temperature, power and uptime from diff (@ospfbgp) + +## 0.20.0 + +* FEATURE: gpg support for CSV source (@elmobp) +* FEATURE: slackdiff (@natm) +* FEATURE: gitcrypt output model (@clement-parisot) +* FEATURE: model specific credentials (@davromaniak) +* FEATURE: hierarchical json in http source model +* FEATURE: next-adds-job config toggle (to add new job when ever /next is called) +* FEATURE: netgear model (@aschaber1) +* FEATURE: zhone model (@rfdrake) +* FEATURE: tplink model (@mediumo) +* FEATURE: oneos model (@crami) +* FEATURE: cisco NGA model (@udhos) +* FEATURE: voltaire model (@clement-parisot) +* FEATURE: siklu model (@bdg-robert) +* FEATURE: voss model (@ospfbgp) +* BUGFIX: ios, cumulus, ironware, nxos, fiberdiver, aosw, fortios, comware, procurve, opengear, timos, routeros, junos, asa, aireos, mlnxos, pfsense, saos, powerconnect, firewareos, quantaos + +## 0.19.0 + +* FEATURE: allow setting ssh_keys (not relying on openssh config) (@denvera) +* FEATURE: fujitsupy model (@stokbaek) +* FEATURE: fiberdriver model (@emjemj) +* FEATURE: hpbladesystems model (@flokli) +* FEATURE: planetsgs model (@flokli) +* FEATURE: trango model (@rfdrake) +* FEATURE: casa model (@rfdrake) +* FEATURE: dlink model (@rfdrake) +* FEATURE: hatteras model (@rfdrake) +* FEATURE: ability to ignore SSL certs in http (@laf) +* FEATURE: awsns hooks, publish messages to AWS SNS topics (@natm) +* BUGFIX: pfsense, dnos, powerconnect, ciscosmb, eos, aosw + +## 0.18.0 + +* FEATURE: APC model (by @davromaniak ) +* BUGFIX: ironware, aosw +* BUGFIX: interpolate nil, false, true for node vars too + +## 0 17.0 + +* FEATURE: "nil", "false" and "true" in source (e.g. router.db) are interpeted as nil, false, true. Empty is now always considered empty string, instead of in some cases nil and some cases empty string. +* FEATURE: support tftp as input model (@MajesticFalcon) +* FEATURE: add alvarion model (@MajesticFalcon) +* FEATURE: detect if ssh wants password terminal/CLI prompt or not +* FEATURE: node (group, model, username, password) resolution refactoring, supports wider range of use-cases +* BUGFIX: fetch for file output (@danilopopeye) +* BUGFIX: net-ssh version specification +* BUGFIX: routeros, catos, pfsense + +## 0.16.3 + +* FEATURE: pfsense support (by @stokbaek) +* BUGFIX: cumulus prompt not working with default switch configs (by @nertwork) +* BUGFIX: disconnect ssh when prompt wasn't found (by @andir) +* BUGFIX: saos, asa, acos, timos updates, cumulus + +## 0.16.2 + +* BUGFIX: when not using git (by @danilopopeye) +* BUGFIX: screenos update + +## 0.16.1 + +* BUGFIX: unnecessary puts statement removed from git.rb + +## 0.16.0 + +* FEATURE: support Gaia OS devices (by @totosh) +* BUGFIX: #fetch, #version fixes in nodes.rb (by @danilopopeye) +* BUGFIX: procurve + +## 0.15.0 + +* FEATURE: disable periodic collection, only on demand (by Adam Winberg) +* FEATURE: allow disabling ssh exec mode always (mainly for oxidized-script) (by @nickhilliard) +* FEATURE: support mellanox devices (by @ham5ter) +* FEATURE: support firewireos devices (by @alexandre-io) +* FEATURE: support quanta devices (by @f0o) +* FEATURE: support tellabs coriant8800, coriant8600 (by @udhos) +* FEATURE: support brocade6910 (by @cardboardpig) +* BUGFIX: debugging, tests (by @ElvinEfendi) +* BUGFIX: nos, panos, acos, procurve, eos, edgeswitch, aosw, fortios updates + +## 0.14.3 + +* BUGFIX: fix git when using multiple groups without single_repo + +## 0.14.2 + +* BUGFIX: git expand path for all groups +* BUGFIX: git get_version, teletubbies do it again +* BUGFIX: comware, acos, procurve models + +## 0.14.1 + +* BUGFIX: git get_version when groups and single_repo are used + +## 0.14.0 + +* FEATURE: support supermicro swithes (by @funzoneq) +* FEATURE: support catos switches +* BUGFIX: git+groups+singlerepo (by @PANZERBARON) +* BUGFIX: asa, tmos, ironware, ios-xr +* BUGFIX: mandate net-ssh 3.0.x, don't accept 3.1 (numerous issues) + +## 0.13.1 + +* BUGFIX: file permissions (Sigh...) + +## 0.13.0 + +* FEATURE: http post for configs (by @jgroom33) +* FEATURE: support ericsson redbacks (by @roedie) +* FEATURE: support motorola wireless controllers (by @roadie) +* FEATURE: support citrix netscaler (by @roadie) +* FEATURE: support datacom devices (by @danilopopeye) +* FEATURE: support netonix devices +* FEATURE: support specifying ssh cipher and kex (by @roadie) +* FEATURE: rename proxy to ssh_proxy (by @roadie) +* FEATURE: support ssh keys on ssh_proxy (by @awix) +* BUGFIX: various (by @danilopopeye) +* BUGFIX: Node#repo with groups (by @danilopopeye) +* BUGFIX: githubrepohoook (by @danilopopeye) +* BUGFIX: fortios, airos, junos, xos, edgeswitch, nos, tmos, procurve, ipos models + +## 0.12.2 + +* BUGFIX: more MRV model fixes (by @natm) + +## 0.12.1 + +* BUGFIX: set term to vty100 +* BUGFIX: MRV model fixes (by @natm) + +## 0.12.0 + +* FEATURE: enhance AOSW (by @mikebryant) +* FEATURE: F5 TMOS support (by @mikebryant) +* FEATURE: Opengear support (by @mikebryant) +* FEATURE: EdgeSwitch support (by @doogieconsulting) +* BUGFIX: rename input debug log files +* BUGFIX: powerconnect model fixes (by @Madpilot0) +* BUGFIX: fortigate model fixes (by @ElvinEfendi) +* BUGFIX: various (by @mikebryant) +* BUGFIX: write SSH debug to file without buffering +* BUGFIX: fix IOS XR prompt handling + +## 0.11.0 + +* FEATURE: ssh proxycommand (by @ElvinEfendi) +* FEATURE: basic auth in HTTP source (by @laf) +* BUGFIX: do not inject string to output before model gets it +* BUGFIX: store pidfile in oxidized root + +## 0.10.0 + +* FEATURE: Various refactoring (by @ElvinEfendi) +* FEATURE: Ciena SOAS support (by @jgroom33) +* FEATURE: support group variables (by @supertylerc) +* BUGFIX: various ((orly)) (by @marnovdm, @danbaugher, @MrRJ45, @asynet, @nickhilliard) + +## 0.9.0 + +* FEATURE: input log now uses devices name as file, instead of string from config (by @skoef) +* FEATURE: Dell Networkign OS (dnos) support (by @erefre) +* BUGFIX: CiscoSMB, powerconnect, comware, xos, ironware, nos fixes + +## 0.8.1 + +* BUGFIX: restore ruby 1.9.3 compatibility + +## 0.8.0 + +* FEATURE: hooks (by @aakso) +* FEATURE: MRV MasterOS support (by @kwibbly) +* FEATURE: EdgeOS support (by @laf) +* FEATURE: FTP input and Zyxel ZynOS support (by @ytti) +* FEATURE: version and diffs API For oxidized-web (by @FlorianDoublet) +* BUGFIX: aosw, ironware, routeros, xos models +* BUGFIX: crash with 0 nodes +* BUGFIX: ssh auth fail without keyboard-interactive +* Full changelog https://github.com/ytti/oxidized/compare/0.7.1...HEAD + +## 0.7.0 + +* FEATURE: support http source (by @laf) +* FEATURE: support Palo Alto PANOS (by @rixxxx) +* BUGFIX: screenos fixes (by @rixxxx) +* BUGFIX: allow 'none' auth in ssh (spotted by @SaldoorMike, needed by ciscosmb+aireos) + +## 0.6.0 + +* FEATURE: support cumulus linux (by @FlorianDoublet) +* FEATURE: support HP Comware SMB siwtches (by @sid3windr) +* FEATURE: remove secret additions (by @rodecker) +* FEATURE: option to put all groups in single repo (by @ytti) +* FEATURE: expand path in source: csv: (so that ~/foo/bar works) (by @ytti) +* BUGFIX: screenos fixes (by @rixxxx) +* BUGFIX: ironware fixes (by @FlorianDoublet) +* BUGFIX: powerconnect fixes (by @sid3windr) +* BUGFIX: don't ask interactive password in new net/ssh (by @ytti) + +## 0.5.0 + +* FEATURE: Mikrotik RouterOS model (by @emjemj) +* FEATURE: add support for Cisco VSS (by @MrRJ45) +* BUGFIX: general fixes to powerconnect model (by @MrRJ45) +* BUGFIX: fix initial commit issues with rugged (by @MrRJ45) +* BUGFIX: pager error for old dell powerconnect switches (by @emjemj) +* BUGFIX: logout error for old dell powerconnect switches (by @emjemj) + +## 0.4.1 + +* BUGFIX: handle missing output file (by @brandt) +* BUGFIX: fix passwordless enable on Arista EOS model (by @brandt) + +## 0.4.0 + +* FEATURE: allow setting IP address in addition to name in source (SQL/CSV) +* FEATURE: approximate how long it takes to get node from larger view than 1 +* FEATURE: unconditionally start new job if too long has passed since previous start +* FEATURE: add enable to Arista EOS model +* FEATURE: add rugged dependency in gemspec +* FEATURE: log prompt detection failures +* BUGFIX: xos while using telnet (by @fhibler) +* BUGFIX: ironware logout on some models (by @fhibler) +* BUGFIX: allow node to be removed while it is being collected +* BUGFIX: if model returns non string value, return empty string +* BUGFIX: better prompt for Arista EOS model (by @rodecker) +* BUGFIX: improved configuration handling for Arista EOS model (by @rodecker) + +## 0.3.0 + +* FEATURE: *FIXME* bunch of stuff I did for richih, docs needed +* FEATURE: ComWare model (by erJasp) +* FEATURE: Add comment support for router.db file +* FEATURE: Add input debugging and related configuration options +* BUGFIX: Fix ASA model prompt +* BUGFIX: Fix Aruba model display +* BUGFIX: Fix changing output in PowerConnect model + +## 0.2.4 + +* FEATURE: Cisco SMB (Nikola series VxWorks) model by @thetamind +* FEATURE: Extreme Networks XOS model (access by sjm) +* FEATURE: Brocade NOS (Network Operating System) (access by sjm) +* BUGFIX: Match exactly to node[:name] if node[name] is an ip address. + +## 0.2.3 + +* BUGFIX: rescue @ssh.close when far end closes disgracefully (ALU ISAM) +* BUGFIX: bugfixes to models +* FEATURE: Alcatel-Lucent ISAM 7302/7330 model added by @jalmargyyk +* FEATURE: Huawei VRP model added by @jalmargyyk +* FEATURE: Ubiquiti AirOS added by @willglyn +* FEATURE: Support 'input' debug in config, ssh/telnet use it to write session log + +## 0.2.2 + +* BUGFIX: mark node as failure if unknown error is raised + +## 0.2.1 + +* BUGFIX: vars variable resolving for main level vars + +## 0.2.0 + +* FEATURE: Force10 model added by @lysiszegerman +* FEATURE: ScreenOS model added by @lysiszegerman +* FEATURE: FabricOS model added by @thakala +* FEATURE: ASA model added by @thakala +* FEATURE: Vyattamodel added by @thakala +* BUGFIX: Oxidized::String convenience methods for models fixed + +## 0.1.1 + +* BUGFIX: vars needs to return value of r, not value of evaluation diff --git a/README.md b/README.md index d501cb5..f733906 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen [Youtube Video: Oxidized TREX 2014 presentation](http://youtu.be/kBQ_CTUuqeU#t=3h) -#### Index +## Index + 1. [Supported OS Types](docs/Supported-OS-Types.md) 2. [Installation](#installation) * [Debian](#debian) @@ -54,9 +55,10 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen * [Source](docs/Ruby-API.md#source) * [Model](docs/Ruby-API.md#model) -# Installation +## Installation + +### Debian -## Debian Install all required packages and gems. ```shell @@ -65,7 +67,8 @@ gem install oxidized gem install oxidized-script oxidized-web # if you don't install oxidized-web, make sure you remove "rest" from your config ``` -## CentOS, Oracle Linux, Red Hat Linux +### CentOS, Oracle Linux, Red Hat Linux + On CentOS 6 / RHEL 6, install Ruby greater than 1.9.3 (for Ruby 2.1.2 installation instructions see [Installing Ruby 2.1.2 using RVM](#installing-ruby-212-using-rvm)), then install Oxidized dependencies ```shell @@ -85,7 +88,8 @@ gem install oxidized gem install oxidized-script oxidized-web ``` -## FreeBSD +### FreeBSD + [Use RVM to install Ruby v2.1.2](#installing-ruby-2.1.2-using-rvm) Install all required packages and gems. @@ -96,7 +100,8 @@ gem install oxidized gem install oxidized-script oxidized-web ``` -## Build from Git +### Build from Git + ```shell git clone https://github.com/ytti/oxidized.git cd oxidized/ @@ -104,38 +109,40 @@ gem build *.gemspec gem install pkg/*.gem ``` -# Running with Docker +## Running with Docker clone git repo: -``` +```shell git clone https://github.com/ytti/oxidized ``` build container locally: -``` +```shell docker build -q -t oxidized/oxidized:latest oxidized/ ``` create config directory in main system: -``` +```shell mkdir /etc/oxidized ``` run container the first time: _Note: this step in only needed for creating Oxidized's configuration file and can be skipped if you already have it -``` +```shell docker run --rm -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest oxidized ``` + If the RESTful API and Web Interface are enabled, on the docker host running the container edit /etc/oxidized/config and modify 'rest: 127.0.0.1:8888' by 'rest: 0.0.0.0:8888' this will bind port 8888 to all interfaces then expose port out. [Issue #445](https://github.com/ytti/oxidized/issues/445) You can also use docker-compose to launch oxidized container: -``` + +```yaml # docker-compose.yml # docker-compose file example for oxidized that will start along with docker daemon oxidized: @@ -151,13 +158,13 @@ oxidized: create the `/etc/oxidized/router.db` [See CSV Source for further info](docs/Configuration.md#source-csv) -``` +```shell vim /etc/oxidized/router.db ``` run container again: -``` +```shell docker run -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest oxidized[1]: Oxidized starting, running as pid 1 oxidized[1]: Loaded 1 nodes @@ -169,43 +176,47 @@ Puma 2.13.4 starting... If you want to have the config automatically reloaded (e.g. when using a http source that changes) -``` +```shell docker run -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -e CONFIG_RELOAD_INTERVAL=3600 -t oxidized/oxidized:latest ``` If you need to use an internal CA (e.g. to connect to an private github instance) -``` +```shell docker run -v /etc/oxidized:/root/.config/oxidized -v /path/to/MY-CA.crt:/usr/local/share/ca-certificates/MY-CA.crt -p 8888:8888/tcp -e UPDATE_CA_CERTIFICATES=true -t oxidized/oxidized:latest ``` -# Installing Ruby 2.1.2 using RVM +## Installing Ruby 2.1.2 using RVM Install Ruby 2.1.2 build dependencies -``` + +```shell yum install curl gcc-c++ patch readline readline-devel zlib zlib-devel yum install libyaml-devel libffi-devel openssl-devel make cmake yum install bzip2 autoconf automake libtool bison iconv-devel libssh2-devel ``` Install RVM -``` + +```shell curl -L get.rvm.io | bash -s stable ``` Setup RVM environment and compile and install Ruby 2.1.2 and set it as default -``` + +```shell source /etc/profile.d/rvm.sh rvm install 2.1.2 rvm use --default 2.1.2 ``` -# Configuration +## Configuration + Oxidized configuration is in YAML format. Configuration files are subsequently sourced from `/etc/oxidized/config` then `~/.config/oxidized/config`. The hashes will be merged, this might be useful for storing source information in a system wide file and user specific configuration in the home directory (to only include a staff specific username and password). Eg. if many users are using `oxs`, see [Oxidized::Script](https://github.com/ytti/oxidized-script). It is recommended practice to run Oxidized using its own username. This username can be added using standard command-line tools: -``` +```shell useradd oxidized ``` @@ -215,7 +226,7 @@ To initialize a default configuration in your home directory `~/.config/oxidized You can set the env variable `OXIDIZED_HOME` to change its home directory. -``` +```shell OXIDIZED_HOME=/etc/oxidized $ tree -L 1 /etc/oxidized @@ -239,14 +250,15 @@ Possible outputs are either [File](docs/Configuration.md#output-file), [GIT](doc 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`. First create the directory where the CSV `output` is going to store device configs and start Oxidized once. -``` + +```shell mkdir -p ~/.config/oxidized/configs oxidized ``` Now tell Oxidized where it finds a list of network devices to backup configuration from. You can either use CSV or SQLite as source. To create a CSV source add the following snippet: -``` +```yaml source: default: csv csv: @@ -267,9 +279,9 @@ router02.example.com:ios Run `oxidized` again to take the first backups. -# Extra +## Extra -## Ubuntu SystemV init setup +### Ubuntu SystemV init setup The init script assumes that you have a used named 'oxidized' and that oxidized is in one of the following paths: @@ -284,26 +296,26 @@ The init script assumes that you have a used named 'oxidized' and that oxidized 1. Copy init script from extra/ folder to /etc/init.d/oxidized 2. Setup /var/run/ -``` +```shell mkdir /var/run/oxidized chown oxidized:oxidized /var/run/oxidized ``` 3. Make oxidized start on boot -``` +```shell update-rc.d oxidized defaults ``` -# Help +## Help If you need help with Oxidized then we have a few methods you can use to get in touch. - - [Gitter](https://gitter.im/oxidized/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - You can join the Lobby on gitter to chat to other Oxidized users. - - [GitHub](https://github.com/ytti/oxidized/) - For help and requests for code changes / updates. - - [Forum](https://community.librenms.org/c/help/oxidized) - A user forum run by [LibreNMS](https://github.com/librenms/librenms) where you can ask for help and support. +* [Gitter](https://gitter.im/oxidized/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - You can join the Lobby on gitter to chat to other Oxidized users. +* [GitHub](https://github.com/ytti/oxidized/) - For help and requests for code changes / updates. +* [Forum](https://community.librenms.org/c/help/oxidized) - A user forum run by [LibreNMS](https://github.com/librenms/librenms) where you can ask for help and support. -# Help Needed +## Help Needed As things stand right now, `oxidized` is maintained by a single person. A great many [contributors](https://github.com/ytti/oxidized/graphs/contributors) have @@ -338,13 +350,12 @@ Brian Anderson (from Rust fame) wrote an [excellent post](http://brson.github.io/2017/04/05/minimally-nice-maintainer) on what it means to be a maintainer. -# License and Copyright +## License and Copyright Copyright 2013-2015 Saku Ytti 2013-2015 Samer Abdel-Hafez - Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/TODO.md b/TODO.md index 337639e..d1af9d0 100644 --- a/TODO.md +++ b/TODO.md @@ -1,23 +1,29 @@ -# refactor core - * move state from memory to disk, sqlite probably - * allows us to retain stats etc over restart - * simplifies code - * keep only running nodes in memory - * negligible I/O cost, as majority is I/O wait getting config - -# separate login to owon package - * oxidized-script is not only use-case - * it would be good to have minimal package used to login to routers - * oxidized just one consumer of that functionality - * what to do with models, we need model to know how to login. Should models be separated to another package? oxidized-core, oxidized-models and oxidized-login? - * how can we allow interactive login in oxidized-login? With functional VTY etc? REPL loop in input/ssh and input/telnet? - -# thread number - * think about algo - * if job ended later than now-iteration have rand(node.size) == 0 to add thread - * if now is less than job_ended+iteration same chance to remove thread? - * should we try to avoid max threads from being hit? (like maybe non-success thread is pulling average?) - -# docs, testing - * yard docs - * minitest tests +# To Do + +## refactor core + +* move state from memory to disk, sqlite probably +* allows us to retain stats etc over restart +* simplifies code +* keep only running nodes in memory +* negligible I/O cost, as majority is I/O wait getting config + +## separate login to own package + +* oxidized-script is not only use-case +* it would be good to have minimal package used to login to routers +* oxidized just one consumer of that functionality +* what to do with models, we need model to know how to login. Should models be separated to another package? oxidized-core, oxidized-models and oxidized-login? +* how can we allow interactive login in oxidized-login? With functional VTY etc? REPL loop in input/ssh and input/telnet? + +## thread number + +* think about algo +* if job ended later than now-iteration have rand(node.size) == 0 to add thread +* if now is less than job_ended+iteration same chance to remove thread? +* should we try to avoid max threads from being hit? (like maybe non-success thread is pulling average?) + +## docs, testing + +* yard docs +* minitest tests diff --git a/docs/Configuration.md b/docs/Configuration.md index e2db05e..59e3f6d 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -1,10 +1,12 @@ -## Configuration -### Debugging +# Configuration + +## Debugging + 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! -``` +```yaml log: /home/oxidized/.config/oxidized/log ... @@ -16,20 +18,20 @@ input: secure: false ``` -### Privileged mode +## Privileged mode To start privileged mode before pulling the configuration, Oxidized needs to send the enable command. You can globally enable this, by adding the following snippet to the global section of the configuration file. -``` +```yaml vars: enable: S3cre7 ``` -### Removing secrets +## 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. -``` +```yaml vars: remove_secret: true ``` @@ -38,32 +40,33 @@ Device models can contain substitution filters to remove potentially sensitive d As a partial example from ios.rb: -``` +```yaml cmd :secret do |cfg| cfg.gsub! /^(snmp-server community).*/, '\\1 ' (...) cfg end ``` + The above strips out snmp community strings from your saved configs. **NOTE:** Removing secrets reduces the usefulness as a full configuration backup, but it may make sharing configs easier. -### Disabling SSH exec channels +## Disabling SSH exec channels Oxidized uses exec channels to make information extraction simpler, but there are some situations where this doesn't work well, e.g. configuring devices. This feature can be turned off by setting the `ssh_no_exec` variable. -``` +```yaml vars: ssh_no_exec: true ``` -### SSH Proxy Command +## SSH Proxy Command Oxidized can `ssh` through a proxy as well. To do so we just need to set `ssh_proxy` variable. -``` +```yaml ... map: name: 0 @@ -74,20 +77,21 @@ vars_map: ... ``` -### FTP Passive Mode +## 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 -``` + +```yaml input: ftp: passive: false ``` -### Advanced Configuration +## Advanced Configuration Below is an advanced example configuration. You will be able to (optionally) override options per device. The router.db format used is `hostname:model:username:password:enable_password`. Hostname and model will be the only required options, all others override the global configuration sections. -``` +```yaml --- username: oxidized password: S3cr3tx @@ -130,14 +134,13 @@ source: model_map: cisco: ios juniper: junos - ``` -### Advanced Group Configuration +## Advanced Group Configuration For group specific credentials -``` +```yaml groups: mikrotik: username: admin @@ -146,16 +149,19 @@ groups: username: ubnt password: ubnt ``` + and add group mapping -``` + +```yaml map: model: 0 name: 1 group: 2 ``` + For model specific credentials -``` +```yaml models: junos: username: admin @@ -170,26 +176,26 @@ models: password: password ``` -### RESTful API and Web Interface +## RESTful API and Web Interface The RESTful API and Web Interface is enabled by configuring the `rest:` parameter in the config file. This parameter can optionally contain a relative URI. -``` +```yaml # Listen on http://127.0.0.1:8888/ rest: 127.0.0.1:8888 ``` -``` +```yaml # Listen on http://10.0.0.1:8000/oxidized/ rest: 10.0.0.1:8000/oxidized ``` -### Triggered backups +## Triggered backups A node can be moved to head-of-queue via the REST API `GET/POST /node/next/[NODE]`. 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: -``` +```yaml next_adds_job: true ``` diff --git a/docs/Hooks.md b/docs/Hooks.md index fab4025..d52ee08 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -1,25 +1,30 @@ # 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. ## Configuration + 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`: 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 - * `node_success`: triggered when configuration is succesfully pulled from a node and right before storing the configuration. - * `node_fail`: triggered after `retries` amount of failed node pulls. - * `post_store`: triggered after node configuration is stored (this is executed only when the configuration has changed). - * `nodes_done`: triggered after finished fetching all nodes. + +* `node_success`: triggered when configuration is succesfully pulled from a node and right before storing the configuration. +* `node_fail`: triggered after `retries` amount of failed node pulls. +* `post_store`: triggered after node configuration is stored (this is executed only when the configuration has changed). +* `nodes_done`: triggered after finished fetching all nodes. ## Hook type: exec + The `exec` hook type allows users to run an arbitrary shell command or a binary when triggered. The command is executed on a separate child process either in synchronous or asynchronous fashion. Non-zero exit values cause errors to be logged. STDOUT and STDERR are currently not collected. Command is executed with the following environment: -``` + +```text OX_EVENT OX_NODE_NAME OX_NODE_IP @@ -35,13 +40,13 @@ OX_REPO_NAME Exec hook recognizes 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 - * `cmd`: command to run. +* `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 +* `cmd`: command to run. +## exec hook configuration example -## Hook configuration example -``` +```yaml hooks: name_for_example_hook1: type: exec @@ -55,21 +60,21 @@ hooks: timeout: 120 ``` -### githubrepo +### Hook type: githubrepo This hook configures the repository `remote` and _push_ the code when the specified event is triggerd. If the `username` and `password` are not provided, the `Rugged::Credentials::SshKeyFromAgent` will be used. `githubrepo` hook recognizes 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. +* `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. When using groups repositories, each group must have its own `remote` in the `remote_repo` config. -``` yaml +```yaml hooks: push_to_remote: remote_repo: @@ -78,10 +83,9 @@ hooks: firewalls: git@git.intranet:oxidized/firewalls.git ``` +## githubrepo hook configuration example -## Hook configuration example - -``` yaml +```yaml hooks: push_to_remote: type: githubrepo @@ -97,14 +101,14 @@ The `awssns` hook publishes messages to AWS SNS topics. This allows you to notif Fields sent in the message: - * `event`: Event type (e.g. `node_success`) - * `group`: Group name - * `model`: Model name (e.g. `eos`) - * `node`: Device hostname +* `event`: Event type (e.g. `node_success`) +* `group`: Group name +* `model`: Model name (e.g. `eos`) +* `node`: Device hostname -Configuration example: +## awssns hook configuration example -``` yaml +```yaml hooks: hook_script: type: awssns @@ -115,8 +119,8 @@ hooks: AWS SNS hook requires the following configuration keys: - * `region`: AWS Region name - * `topic_arn`: ASN Topic reference +* `region`: AWS Region name +* `topic_arn`: ASN Topic reference Your AWS credentials should be stored in `~/.aws/credentials`. @@ -126,13 +130,13 @@ The `slackdiff` hook posts colorized config diffs to a [Slack](http://www.slack. You will need to manually install the `slack-api` gem on your system: -``` +```shell gem install slack-api ``` -Configuration example: +## slackdiff hook configuration example -``` yaml +```yaml hooks: slack: type: slackdiff @@ -143,7 +147,7 @@ hooks: 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 +```yaml hooks: slack: type: slackdiff @@ -162,13 +166,13 @@ The `xmppdiff` hook posts config diffs to a [XMPP](https://en.wikipedia.org/wiki You will need to manually install the `xmpp4r` gem on your system: -``` +```shell gem install xmpp4r ``` -Configuration example: +## xmppdiff hook configuration example -``` yaml +```yaml hooks: xmpp: type: xmppdiff diff --git a/docs/Model-Notes/AireOS.md b/docs/Model-Notes/AireOS.md index 0da9b57..9962f31 100644 --- a/docs/Model-Notes/AireOS.md +++ b/docs/Model-Notes/AireOS.md @@ -1,12 +1,12 @@ -Cisco WLC Configuration -======================== +Cisco WLC Configuration +======================= Create a user with read-write privilege : -``` +```text mgmtuser add oxidized **** read-write ``` -Oxidized needs read-write privilege in order to execute 'config paging disable'. +Oxidized needs read-write privilege in order to execute 'config paging disable'. Back to [Model-Notes](README.md) diff --git a/docs/Model-Notes/ArbOS.md b/docs/Model-Notes/ArbOS.md index 0f5b628..f68467f 100644 --- a/docs/Model-Notes/ArbOS.md +++ b/docs/Model-Notes/ArbOS.md @@ -3,7 +3,7 @@ Arbor Networks ArbOS notes If you are running ArbOS version 7 or lower then you may need to update the model to remove `exec true`: -``` +```ruby cfg :ssh do pre_logout 'exit' end diff --git a/docs/Model-Notes/Comware.md b/docs/Model-Notes/Comware.md index 31eb002..0da019a 100644 --- a/docs/Model-Notes/Comware.md +++ b/docs/Model-Notes/Comware.md @@ -1,10 +1,12 @@ Comware Configuration ===================== -If you find 3Com comware devices aren't being backed up this may be due to prompt detection not matching -because a previous login message is disabled after the first prompt. You can disable this on the devices -themselves by running this command: +If you find 3Com comware devices aren't being backed up this may be due to prompt detection not matching because a previous login message is disabled after the first prompt. -`info-center source default channel 1 log state off debug state off` +You can disable this on the devices themselves by running this command: + +```text +info-center source default channel 1 log state off debug state off +``` [Reference](https://github.com/ytti/oxidized/issues/1171) diff --git a/docs/Model-Notes/JunOS.md b/docs/Model-Notes/JunOS.md index ed8dbca..8093df0 100644 --- a/docs/Model-Notes/JunOS.md +++ b/docs/Model-Notes/JunOS.md @@ -1,9 +1,9 @@ JunOS Configuration -======================== +=================== Create login class cfg-view -``` +```text set system login class cfg-view permissions view-configuration set system login class cfg-view allow-commands "(show)|(set cli screen-length)|(set cli screen-width)" set system login class cfg-view deny-commands "(clear)|(file)|(file show)|(help)|(load)|(monitor)|(op)|(request)|(save)|(set)|(start)|(test)" @@ -12,7 +12,7 @@ set system login class cfg-view deny-configuration all Create a user with cfg-view class -``` +```text set system login user oxidized class cfg-view set system login user oxidized authentication plain-text-password "verysecret" ``` @@ -25,14 +25,10 @@ The commands Oxidized executes are: 4. show version 5. show chassis hardware 6. show system license -7. show system license keys -ex22|ex33|ex4|ex8|qfx only -8. show virtual-chassis -MX960 only +7. show system license keys (ex22|ex33|ex4|ex8|qfx only) +8. show virtual-chassis (MX960 only) 9. show chassis fabric reachability - Oxidized can now retrieve your configuration! - Back to [Model-Notes](README.md) diff --git a/docs/Model-Notes/README.md b/docs/Model-Notes/README.md index 9d7db32..8dcabd3 100644 --- a/docs/Model-Notes/README.md +++ b/docs/Model-Notes/README.md @@ -1,21 +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 ----------------|-----------------|---------------- 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)|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/docs/Model-Notes/VRP-Huawei.md b/docs/Model-Notes/VRP-Huawei.md index d03c752..e68a959 100644 --- a/docs/Model-Notes/VRP-Huawei.md +++ b/docs/Model-Notes/VRP-Huawei.md @@ -3,7 +3,7 @@ Huawei VRP Configuration Create a user with no privileges -``` +```text system-view [~HUAWEI] aaa [~HUAWEI-aaa] local-user oxidized password irreversible-cipher verysecret @@ -21,7 +21,7 @@ The commands Oxidized executes are: 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: -``` +```text system-view [~HUAWEI] command-privilege level 1 view global display current-configuration all [*HUAWEI] command-privilege level 1 view shell screen-length @@ -30,5 +30,4 @@ Command 2 and 3 can be executed without issues, but 1 and 4 are only available f Oxidized can now retrieve your configuration! - Back to [Model-Notes](README.md) diff --git a/docs/Model-Notes/XGS4600-Zyxel.md b/docs/Model-Notes/XGS4600-Zyxel.md index 0ff2e7d..17cb2b5 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 @@ -20,5 +22,4 @@ input: Oxidized can now retrieve your configuration! - Back to [Model-Notes](README.md) diff --git a/docs/Outputs.md b/docs/Outputs.md index e3bd42d..92c672c 100644 --- a/docs/Outputs.md +++ b/docs/Outputs.md @@ -1,23 +1,22 @@ +# Outputs -## Output - -### Output: File +## Output: File Parent directory needs to be created manually, one file per device, with most recent running config. -``` +```yaml output: file: directory: /var/lib/oxidized/configs ``` -### Output: Git +## Output: Git 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: -``` yaml +```yaml output: default: git git: @@ -28,7 +27,7 @@ output: And for groups repositories: -``` yaml +```yaml output: default: git git: @@ -40,14 +39,14 @@ output: Oxidized will create a repository for each group in the same directory as the `default.git`. For example: -``` csv +```csv host1:ios:first host2:nxos:second ``` This will generate the following repositories: -``` bash +```bash $ ls /var/lib/oxidized/git-repos default.git first.git second.git @@ -55,7 +54,7 @@ default.git first.git second.git If you would like to use groups and a single repository, you can force this with the `single_repo` config. -``` yaml +```yaml output: default: git git: @@ -64,15 +63,14 @@ output: ``` -### Output: Git-Crypt +## Output: Git-Crypt 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: -``` yaml +```yaml output: default: gitcrypt gitcrypt: @@ -86,7 +84,7 @@ output: And for groups repositories: -``` yaml +```yaml output: default: gitcrypt gitcrypt: @@ -101,14 +99,14 @@ output: Oxidized will create a repository for each group in the same directory as the `default`. For example: -``` csv +```csv host1:ios:first host2:nxos:second ``` This will generate the following repositories: -``` bash +```bash $ ls /var/lib/oxidized/git-repos default.git first.git second.git @@ -116,7 +114,7 @@ default.git first.git second.git If you would like to use groups and a single repository, you can force this with the `single_repo` config. -``` yaml +```yaml output: default: gitcrypt gitcrypt: @@ -130,11 +128,11 @@ output: Please note that user list is only updated once at creation. -### Output: Http +## Output: Http POST a config to the specified URL -``` +```yaml output: default: http http: @@ -143,13 +141,13 @@ output: url: "http://192.168.162.50:8080/db/coll" ``` -### Output types +## Output types If you prefer to have different outputs in different files and/or directories, you can easily do this by modifying the corresponding model. To change the behaviour for IOS, you would edit `lib/oxidized/model/ios.rb` (run `gem contents oxidized` to find out the full file path). For example, let's say you want to split out `show version` and `show inventory` into separate files in a directory called `nodiff` which your tools will not send automated diffstats for. You can apply a patch along the lines of -``` +```text - cmd 'show version' do |cfg| - comment cfg.lines.first + cmd 'show version' do |state| @@ -183,7 +181,7 @@ For example, let's say you want to split out `show version` and `show inventory` which will result in the following layout -``` +```text diff/$FQDN--show_running_config nodiff/$FQDN--show_version nodiff/$FQDN--show_inventory diff --git a/docs/Ruby-API.md b/docs/Ruby-API.md index 2dbc10e..8621870 100644 --- a/docs/Ruby-API.md +++ b/docs/Ruby-API.md @@ -3,33 +3,39 @@ The following objects exist in Oxidized. ## Input - * gets config from nodes - * must implement 'connect', 'get', 'cmd' - * 'ssh', 'telnet, ftp, and tftp' implemented + +* gets config from nodes +* must implement 'connect', 'get', 'cmd' +* 'ssh', 'telnet, ftp, and tftp' implemented ## Output - * stores config - * must implement 'store' (may implement 'fetch') - * 'git' and 'file' (store as flat ascii) implemented + +* stores config +* must implement 'store' (may implement 'fetch') +* 'git' and 'file' (store as flat ascii) implemented ## Source - * 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) - * 'sql', 'csv' and 'http' (supports any format with single entry per line, like router.db) + +* 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) +* 'sql', 'csv' and 'http' (supports any format with single entry per line, like router.db) ## Model + ### 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. @@ -38,6 +44,7 @@ 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: @@ -69,18 +76,21 @@ 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. @@ -90,26 +100,32 @@ The passed data is replaced by the return value of the block. 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. diff --git a/docs/Sources.md b/docs/Sources.md index 7029b72..5599409 100644 --- a/docs/Sources.md +++ b/docs/Sources.md @@ -1,10 +1,10 @@ -## Source +# Sources -### Source: CSV +## Source: CSV One line per device, colon seperated. If `ip` isn't present, a DNS lookup will be done against `name`. For large installations, setting `ip` will dramatically reduce startup time. -``` +```yaml source: default: csv csv: @@ -22,7 +22,7 @@ source: Example csv `/var/lib/oxidized/router.db`: -``` +```text rtr01.local:192.168.1.1:ios:oxidized:5uP3R53cR3T:T0p53cR3t ``` @@ -41,25 +41,31 @@ source: model: 1 ``` -> Please note, if you are running GPG v2 then you will be prompted for your gpg password on start up, if you use GPG >= 2.1 then you can add the following config to stop that behaviour: +Please note, if you are running GPG v2 then you will be prompted for your gpg password on start up, if you use GPG >= 2.1 then you can add the following config to stop that behaviour: -> Within `~/.gnupg/gpg-agent.conf` +Within `~/.gnupg/gpg-agent.conf` + +```text +allow-loopback-pinentry +``` -> `allow-loopback-pinentry` +and within: `~/.gnupg/gpg.conf` -> and within: `~/.gnupg/gpg.conf` +```text +pinentry-mode loopback +``` -> `pinentry-mode loopback` +## Source: SQL -### Source: SQL 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! -### Source: MYSQL + +## Source: MYSQL `sudo apt-get install libmysqlclient-dev` The values correspond to your fields in the DB such that ip, model, etc are field names in the DB -``` +```yaml source: default: sql sql: @@ -77,11 +83,11 @@ source: enable: enable ``` -### Source: SQLite +## Source: SQLite One row per device, filtered by hostname. -``` +```yaml source: default: sql sql: @@ -97,12 +103,11 @@ source: enable: enable ``` -### Custom SQL Query Support +## 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 +### 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. @@ -119,21 +124,20 @@ In this example we limit the nodes to two "POPs" of `mypop1` and `mypop2`. We al ```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 +## Source: HTTP One object per device. HTTP Supports basic auth, configure the user and pass you want to use under the http: section. -``` +```yaml source: default: http http: @@ -155,7 +159,7 @@ source: You can also pass `secure: false` if you want to disable ssl certificate verification: -``` +```yaml source: default: http http: diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index d6d718f..a0ca66b 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -1,159 +1,160 @@ # Supported OS types - * Vendor - * OS model - * A10 Networks - * [ACOS](/lib/oxidized/model/acos.rb) - * Accedian Performance Elements (NIDs) - * [AEN](/lib/oxidized/model/aen.rb) - * Alcatel-Lucent - * [AOS](/lib/oxidized/model/aos.rb) - * [AOS7](/lib/oxidized/model/aos7.rb) - * [ISAM](/lib/oxidized/model/isam.rb) - * [SR OS (Formerly TiMOS)](/lib/oxidized/model/timos.rb) - * Wireless - * Allied Telesis - * [Alliedware Plus](/lib/oxidized/model/awplus.rb) - * Alvarion - * [BreezeACCESS](/lib/oxidized/model/alvarion.rb) - * APC - * [AOS](/lib/oxidized/model/apc_aos.rb) - * Arbor Networks - * [ArbOS](/lib/oxidized/model/arbos.rb) - * Arista - * [EOS](/lib/oxidized/model/eos.rb) - * Arris - * [C4CMTS](/lib/oxidized/model/c4cmts.rb) - * Aruba - * [AOSW](/lib/oxidized/model/aosw.rb) - * AudioCodes - * [AudioCodes](/lib/oxdized/model/audiocodes.rb) - * Avaya - * [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) - * Casa - * [Casa](/lib/oxidized/model/casa.rb) - * Check Point - * [GaiaOS](/lib/oxidized/model/gaiaos.rb) - * Ciena - * [SAOS](/lib/oxidized/model/saos.rb) - * Cisco - * [ACSW](/lib/oxidized/model/acsw.rb) - * [AireOS](/lib/oxidized/model/aireos.rb) - * [ASA](/lib/oxidized/model/asa.rb) - * [AsyncOS](/lib/oxidized/model/asyncos.rb) - * [CatOS](/lib/oxidized/model/catos.rb) - * [IOS](/lib/oxidized/model/ios.rb) - * [IOSXR](/lib/oxidized/model/iosxr.rb) - * [NGA](/lib/oxidized/model/cisconga.rb) - * [NXOS](/lib/oxidized/model/nxos.rb) - * [SMA](/lib/oxidized/model/ciscosma.rb) - * [SMB (Nikola series)](/lib/oxidized/model/ciscosmb.rb) - * [UCS](/lib/oxidized/model/ucs.rb) - * Citrix - * [NetScaler (Virtual Applicance)](/lib/oxidized/model/netscaler.rb) - * Coriant (former Tellabs) - * [TMOS (8800)](/lib/oxidized/model/corianttmos.rb) - * [8600](/lib/oxidized/model/coriant8600.rb) - * [Groove](/lib/oxidized/model/coriantgroove.rb) - * Cumulus - * [Linux](/lib/oxidized/model/cumulus.rb) - * DataCom - * [DmSwitch 3000](/lib/oxidized/model/datacom.rb) - * DCN - * [DCN](/lib/oxidized/model/ios.rb) - Map this to ios. - * DELL - * [PowerConnect](/lib/oxidized/model/powerconnect.rb) - * [AOSW](/lib/oxidized/model/aosw.rb) - * D-Link - * [D-Link](/lib/oxidized/model/dlink.rb) - * Ericsson/Redback - * [IPOS (former SEOS)](/lib/oxidized/model/ipos.rb) - * Extreme Networks - * [Enterasys](/lib/oxidized/model/enterasys.rb) - * [WM](/lib/oxidized/model/mtrlrfs.rb) - * [XOS](/lib/oxidized/model/xos.rb) - * F5 - * [TMOS](/lib/oxidized/model/tmos.rb) - * Fiberstore - * [S3800](/lib/oxidized/model/gcombnps.rb) - * Force10 - * [DNOS](/lib/oxidized/model/dnos.rb) - * [FTOS](/lib/oxidized/model/ftos.rb) - * FortiGate - * [FortiOS](/lib/oxidized/model/fortios.rb) - * Fujitsu - * [PRIMERGY Blade switch 1/10Gbe](/lib/oxidized/model/fujitsupy.rb) - * GCOM Technologies - * [Broadband Network Platform Software](/lib/oxidized/model/gcombnps.rb) - * Hatteras - * [Hatteras](/lib/oxidized/model/hatteras.rb) - * Hirschmann - * [HiOS](/lib/oxidized/model/hirschmann.rb) - * HP - * [Comware (HP A-series, H3C, 3Com)](/lib/oxidized/model/comware.rb) - * [Procurve](/lib/oxidized/model/procurve.rb) - * [BladeSystem (Onboard Administrator)](/lib/oxidized/model/hpebladesystem.rb) - * [MSA](/lib/oxidized/model/hpemsa.rb) - * Huawei - * [VRP](/lib/oxidized/model/vrp.rb) - * Juniper - * [JunOS](/lib/oxidized/model/junos.rb) - * [ScreenOS (Netscreen)](/lib/oxidized/model/screenos.rb) - * Mellanox - * [MLNX-OS](/lib/oxidized/model/mlnxos.rb) - * [Voltaire](/lib/oxidized/model/voltaire.rb) - * Mikrotik - * [RouterOS](/lib/oxidized/model/routeros.rb) - * Motorola - * [RFS](/lib/oxidized/model/mtrlrfs.rb) - * MRV - * [MasterOS](/lib/oxidized/model/masteros.rb) - * [FiberDriver](/lib/oxidized/model/fiberdriver.rb) - * Netgear - * [Netgear](/lib/oxidized/model/netgear.rb) - * Netonix - * [WISP Switch (As Netonix)](/lib/oxidized/model/netonix.rb) - * Nokia (formerly TiMetra, Alcatel, Alcatel-Lucent) - * [SR OS (TiMOS)](/lib/oxidized/model/timos.rb) - * OneAccess - * [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) - * [pfSense](/lib/oxidized/model/pfsense.rb) - * Radware - * [AlteonOS](/lib/oxidized/model/alteonos.rb) - * Quanta - * [Quanta / VxWorks 6.6 (1.1.0.8)](/lib/oxidized/model/quantaos.rb) - * Siklu - * [EtherHaul](/lib/oxidized/model/siklu.rb) - * Supermicro - * [Supermicro](/lib/oxidized/model/supermicro.rb) - * Symantec - * [Blue Coat ProxySG / Security Gateway OS (SGOS)](/lib/oxidized/model/sgos.rb) - * Trango Systems - * [Trango](/lib/oxidized/model/trango.rb) - * TPLink - * [TPLink](/lib/oxidized/model/tplink.rb) - * Ubiquiti - * [AirOS](/lib/oxidized/model/airos.rb) - * [Edgeos](/lib/oxidized/model/edgeos.rb) - * [EdgeSwitch](/lib/oxidized/model/edgeswitch.rb) - * Watchguard - * [Fireware OS](/lib/oxidized/model/firewareos.rb) - * Westell - * [Westell 8178G, Westell 8266G](/lib/oxidized/model/weos.rb) - * Zhone - * [Zhone (OLT and MX)](/lib/oxidized/model/zhoneolt.rb) - * Zyxel - * [ZyNOS](/lib/oxidized/model/zynos.rb) + +* Vendor + * OS model +* A10 Networks + * [ACOS](/lib/oxidized/model/acos.rb) +* Accedian Performance Elements (NIDs) + * [AEN](/lib/oxidized/model/aen.rb) +* Alcatel-Lucent + * [AOS](/lib/oxidized/model/aos.rb) + * [AOS7](/lib/oxidized/model/aos7.rb) + * [ISAM](/lib/oxidized/model/isam.rb) + * [SR OS (Formerly TiMOS)](/lib/oxidized/model/timos.rb) + * Wireless +* Allied Telesis + * [Alliedware Plus](/lib/oxidized/model/awplus.rb) +* Alvarion + * [BreezeACCESS](/lib/oxidized/model/alvarion.rb) +* APC + * [AOS](/lib/oxidized/model/apc_aos.rb) +* Arbor Networks + * [ArbOS](/lib/oxidized/model/arbos.rb) +* Arista + * [EOS](/lib/oxidized/model/eos.rb) +* Arris + * [C4CMTS](/lib/oxidized/model/c4cmts.rb) +* Aruba + * [AOSW](/lib/oxidized/model/aosw.rb) +* AudioCodes + * [AudioCodes](/lib/oxdized/model/audiocodes.rb) +* Avaya + * [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) +* Casa + * [Casa](/lib/oxidized/model/casa.rb) +* Check Point + * [GaiaOS](/lib/oxidized/model/gaiaos.rb) +* Ciena + * [SAOS](/lib/oxidized/model/saos.rb) +* Cisco + * [ACSW](/lib/oxidized/model/acsw.rb) + * [AireOS](/lib/oxidized/model/aireos.rb) + * [ASA](/lib/oxidized/model/asa.rb) + * [AsyncOS](/lib/oxidized/model/asyncos.rb) + * [CatOS](/lib/oxidized/model/catos.rb) + * [IOS](/lib/oxidized/model/ios.rb) + * [IOSXR](/lib/oxidized/model/iosxr.rb) + * [NGA](/lib/oxidized/model/cisconga.rb) + * [NXOS](/lib/oxidized/model/nxos.rb) + * [SMA](/lib/oxidized/model/ciscosma.rb) + * [SMB (Nikola series)](/lib/oxidized/model/ciscosmb.rb) + * [UCS](/lib/oxidized/model/ucs.rb) +* Citrix + * [NetScaler (Virtual Applicance)](/lib/oxidized/model/netscaler.rb) +* Coriant (former Tellabs) + * [TMOS (8800)](/lib/oxidized/model/corianttmos.rb) + * [8600](/lib/oxidized/model/coriant8600.rb) + * [Groove](/lib/oxidized/model/coriantgroove.rb) +* Cumulus + * [Linux](/lib/oxidized/model/cumulus.rb) +* DataCom + * [DmSwitch 3000](/lib/oxidized/model/datacom.rb) +* DCN + * [DCN](/lib/oxidized/model/ios.rb) - Map this to ios. +* DELL + * [PowerConnect](/lib/oxidized/model/powerconnect.rb) + * [AOSW](/lib/oxidized/model/aosw.rb) +* D-Link + * [D-Link](/lib/oxidized/model/dlink.rb) +* Ericsson/Redback + * [IPOS (former SEOS)](/lib/oxidized/model/ipos.rb) +* Extreme Networks + * [Enterasys](/lib/oxidized/model/enterasys.rb) + * [WM](/lib/oxidized/model/mtrlrfs.rb) + * [XOS](/lib/oxidized/model/xos.rb) +* F5 + * [TMOS](/lib/oxidized/model/tmos.rb) +* Fiberstore + * [S3800](/lib/oxidized/model/gcombnps.rb) +* Force10 + * [DNOS](/lib/oxidized/model/dnos.rb) + * [FTOS](/lib/oxidized/model/ftos.rb) +* FortiGate + * [FortiOS](/lib/oxidized/model/fortios.rb) +* Fujitsu + * [PRIMERGY Blade switch 1/10Gbe](/lib/oxidized/model/fujitsupy.rb) +* GCOM Technologies + * [Broadband Network Platform Software](/lib/oxidized/model/gcombnps.rb) +* Hatteras + * [Hatteras](/lib/oxidized/model/hatteras.rb) +* Hirschmann + * [HiOS](/lib/oxidized/model/hirschmann.rb) +* HP + * [Comware (HP A-series, H3C, 3Com)](/lib/oxidized/model/comware.rb) + * [Procurve](/lib/oxidized/model/procurve.rb) + * [BladeSystem (Onboard Administrator)](/lib/oxidized/model/hpebladesystem.rb) + * [MSA](/lib/oxidized/model/hpemsa.rb) +* Huawei + * [VRP](/lib/oxidized/model/vrp.rb) +* Juniper + * [JunOS](/lib/oxidized/model/junos.rb) + * [ScreenOS (Netscreen)](/lib/oxidized/model/screenos.rb) +* Mellanox + * [MLNX-OS](/lib/oxidized/model/mlnxos.rb) + * [Voltaire](/lib/oxidized/model/voltaire.rb) +* Mikrotik + * [RouterOS](/lib/oxidized/model/routeros.rb) +* Motorola + * [RFS](/lib/oxidized/model/mtrlrfs.rb) +* MRV + * [MasterOS](/lib/oxidized/model/masteros.rb) + * [FiberDriver](/lib/oxidized/model/fiberdriver.rb) +* Netgear + * [Netgear](/lib/oxidized/model/netgear.rb) +* Netonix + * [WISP Switch (As Netonix)](/lib/oxidized/model/netonix.rb) +* Nokia (formerly TiMetra, Alcatel, Alcatel-Lucent) + * [SR OS (TiMOS)](/lib/oxidized/model/timos.rb) +* OneAccess + * [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) +* [pfSense](/lib/oxidized/model/pfsense.rb) +* Radware + * [AlteonOS](/lib/oxidized/model/alteonos.rb) +* Quanta + * [Quanta / VxWorks 6.6 (1.1.0.8)](/lib/oxidized/model/quantaos.rb) +* Siklu + * [EtherHaul](/lib/oxidized/model/siklu.rb) +* Supermicro + * [Supermicro](/lib/oxidized/model/supermicro.rb) +* Symantec + * [Blue Coat ProxySG / Security Gateway OS (SGOS)](/lib/oxidized/model/sgos.rb) +* Trango Systems + * [Trango](/lib/oxidized/model/trango.rb) +* TPLink + * [TPLink](/lib/oxidized/model/tplink.rb) +* Ubiquiti + * [AirOS](/lib/oxidized/model/airos.rb) + * [Edgeos](/lib/oxidized/model/edgeos.rb) + * [EdgeSwitch](/lib/oxidized/model/edgeswitch.rb) +* Watchguard + * [Fireware OS](/lib/oxidized/model/firewareos.rb) +* Westell + * [Westell 8178G, Westell 8266G](/lib/oxidized/model/weos.rb) +* Zhone + * [Zhone (OLT and MX)](/lib/oxidized/model/zhoneolt.rb) +* Zyxel + * [ZyNOS](/lib/oxidized/model/zynos.rb) -- cgit v1.2.1 From 6aca017378874993a2e4b34fc5ed947e4c62046c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Mon, 12 Mar 2018 21:45:21 +0100 Subject: Refresh docker section in readme --- README.md | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f733906..1d75611 100644 --- a/README.md +++ b/README.md @@ -109,38 +109,42 @@ gem build *.gemspec gem install pkg/*.gem ``` -## Running with Docker +### Running with Docker -clone git repo: +Currently, Docker Hub automatcally builds the master branch as [oxidized/oxidized](https://hub.docker.com/r/oxidized/oxidized/), you can make use of this container or build your own. + +To build your own, clone git repo: ```shell git clone https://github.com/ytti/oxidized ``` -build container locally: +Then, build the container locally (requires docker 17.05.0-ce or higher): ```shell docker build -q -t oxidized/oxidized:latest oxidized/ ``` -create config directory in main system: +Once you've built the container (or chosen to make use of the automatically built container in Docker Hub, which will be downloaded for you by docker on the first `run` command had you not built it), proceed as follows: + +Create a configuration directory in the host system: ```shell mkdir /etc/oxidized ``` -run container the first time: -_Note: this step in only needed for creating Oxidized's configuration file and can be skipped if you already have it +Run the container for the first time to initialize the config: + +_Note: this step in only required for creating the Oxidized configuration file and can be skipped if you already have one._ ```shell docker run --rm -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest oxidized ``` If the RESTful API and Web Interface are enabled, on the docker host running the container -edit /etc/oxidized/config and modify 'rest: 127.0.0.1:8888' by 'rest: 0.0.0.0:8888' -this will bind port 8888 to all interfaces then expose port out. [Issue #445](https://github.com/ytti/oxidized/issues/445) +edit `/etc/oxidized/config` and modify `rest: 127.0.0.1:8888` to `rest: 0.0.0.0:8888`. This will bind port 8888 to all interfaces, and expose the port so that it could be accessed externally. [(Issue #445)](https://github.com/ytti/oxidized/issues/445) -You can also use docker-compose to launch oxidized container: +Alternatively, you can use docker-compose to launch the oxidized container: ```yaml # docker-compose.yml @@ -156,13 +160,13 @@ oxidized: - /etc/oxidized:/root/.config/oxidized ``` -create the `/etc/oxidized/router.db` [See CSV Source for further info](docs/Configuration.md#source-csv) +Create the `/etc/oxidized/router.db` (see [CSV Source](docs/Sources.md#source-csv) for futher info): ```shell vim /etc/oxidized/router.db ``` -run container again: +Run container again to start oxidized with your configuration: ```shell docker run -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest @@ -174,19 +178,19 @@ Puma 2.13.4 starting... * Listening on tcp://0.0.0.0:8888 ``` -If you want to have the config automatically reloaded (e.g. when using a http source that changes) +If you want to have the config automatically reloaded (e.g. when using a http source that changes): ```shell docker run -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -e CONFIG_RELOAD_INTERVAL=3600 -t oxidized/oxidized:latest ``` -If you need to use an internal CA (e.g. to connect to an private github instance) +If you need to use an internal CA (e.g. to connect to an private github instance): ```shell docker run -v /etc/oxidized:/root/.config/oxidized -v /path/to/MY-CA.crt:/usr/local/share/ca-certificates/MY-CA.crt -p 8888:8888/tcp -e UPDATE_CA_CERTIFICATES=true -t oxidized/oxidized:latest ``` -## Installing Ruby 2.1.2 using RVM +### Installing Ruby 2.1.2 using RVM Install Ruby 2.1.2 build dependencies @@ -271,7 +275,7 @@ source: Now lets create a file based device database (you might want to switch to SQLite later on). Put your routers in `~/.config/oxidized/router.db` (file format is compatible with rancid). Simply add an item per line: -``` +```text router01.example.com:ios switch01.example.com:procurve router02.example.com:ios @@ -285,7 +289,7 @@ Run `oxidized` again to take the first backups. The init script assumes that you have a used named 'oxidized' and that oxidized is in one of the following paths: -``` +```text /sbin /bin /usr/sbin -- cgit v1.2.1 From 1d4e44f28fab2567f3f2692b281c4163c0e9f6ba Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 14 Mar 2018 22:00:25 +0100 Subject: Document the process of extending models --- README.md | 5 ++-- docs/Extending-Models.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 docs/Extending-Models.md diff --git a/README.md b/README.md index 1d75611..b3c1912 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,9 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen * [Advanced Configuration](docs/Configuration.md#advanced-configuration) * [Advanced Group Configuration](docs/Configuration.md#advanced-group-configuration) * [Hooks](docs/Hooks.md) -5. [Help](#help) -6. [Ruby API](docs/Ruby-API.md#ruby-api) +5. [Extending Models](docs/Extending-Models.md) +6. [Help](#help) +7. [Ruby API](docs/Ruby-API.md#ruby-api) * [Input](docs/Ruby-API.md#input) * [Output](docs/Ruby-API.md#output) * [Source](docs/Ruby-API.md#source) diff --git a/docs/Extending-Models.md b/docs/Extending-Models.md new file mode 100644 index 0000000..4f59f69 --- /dev/null +++ b/docs/Extending-Models.md @@ -0,0 +1,73 @@ +# Extending and Customizing Oxidized Models + +Oxidized supports a growing list of [operating system types](Supported-Os-Types.md). Out of the box, most model implementations collect configuration data. Some implementations also include a conservative set of additional commands that collect basic device information (device make and model, software version, licensing information, ...) which are appended to the configuration as comments. + +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. + +## 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. + +Create the file `~/.config/oxidized/model/junos.rb` with the following contents: + +```ruby +require 'oxidized/mode/junos.rb' + + +class JunOS + + + cmd 'show interfaces diagnostics optics' do |cfg| + comment cfg + end + + +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. + +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 completely new model, with a new name, for a new operating system type. + +## Advanced features + +The loosely-coupled architecture of Oxidized allows for easy extensibility in more advanced use cases as well. + +The example below extends the functionality of the `JunOS` model further to collect `display set` formatted configuration from the device, and utilizes the multi-output functionality of the `git` output to place the returned configuration in a separate file within a git repository. + +It is possible to configure the `git` output to create new subdirectories under an existing repository instead of creating new repositories for each new defined output type (the default) by including the following configuration in the `~/.config/oxidized/config` file: + +```yaml +output: + git: + type_as_directory: true +``` + +Then, `~/.config/oxidized/model/junos.rb` is adapted as following: + +```ruby +require 'oxidized/mode/junos.rb' + + +class JunOS + + + cmd 'show interface diagnostic optics' do |cfg| + comment cfg + end + + cmd 'show configuration | display set' do |cfg| + cfg.type = "junos-set" + cfg.name = "set" + cfg + end + + +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 -- cgit v1.2.1 From 94b6638542d98169f9502089f153c0b5e63b3b5f Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 14 Mar 2018 22:05:07 +0100 Subject: fix a typo that broke a link within new documentation --- docs/Extending-Models.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Extending-Models.md b/docs/Extending-Models.md index 4f59f69..0707157 100644 --- a/docs/Extending-Models.md +++ b/docs/Extending-Models.md @@ -1,6 +1,6 @@ # Extending and Customizing Oxidized Models -Oxidized supports a growing list of [operating system types](Supported-Os-Types.md). Out of the box, most model implementations collect configuration data. Some implementations also include a conservative set of additional commands that collect basic device information (device make and model, software version, licensing information, ...) which are appended to the configuration as comments. +Oxidized supports a growing list of [operating system types](Supported-OS-Types.md). Out of the box, most model implementations collect configuration data. Some implementations also include a conservative set of additional commands that collect basic device information (device make and model, software version, licensing information, ...) which are appended to the configuration as comments. 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. -- cgit v1.2.1 From f1048f9b9616a2307d0de6c53847d52a16458bb8 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 14 Mar 2018 22:14:38 +0100 Subject: rename extending to creating models and correct typos --- README.md | 2 +- docs/Creating-Models.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/Extending-Models.md | 73 ------------------------------------------------ 3 files changed, 74 insertions(+), 74 deletions(-) create mode 100644 docs/Creating-Models.md delete mode 100644 docs/Extending-Models.md diff --git a/README.md b/README.md index b3c1912..336c05a 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen * [Advanced Configuration](docs/Configuration.md#advanced-configuration) * [Advanced Group Configuration](docs/Configuration.md#advanced-group-configuration) * [Hooks](docs/Hooks.md) -5. [Extending Models](docs/Extending-Models.md) +5. [Creating and Extending Models](docs/Creating-Models.md) 6. [Help](#help) 7. [Ruby API](docs/Ruby-API.md#ruby-api) * [Input](docs/Ruby-API.md#input) diff --git a/docs/Creating-Models.md b/docs/Creating-Models.md new file mode 100644 index 0000000..3c343e6 --- /dev/null +++ b/docs/Creating-Models.md @@ -0,0 +1,73 @@ +# Creating and Extending Oxidized Models + +Oxidized supports a growing list of [operating system types](Supported-OS-Types.md). Out of the box, most model implementations collect configuration data. Some implementations also include a conservative set of additional commands that collect basic device information (device make and model, software version, licensing information, ...) which are appended to the configuration as comments. + +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. + +## 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. + +Create the file `~/.config/oxidized/model/junos.rb` with the following contents: + +```ruby +require 'oxidized/model/junos.rb' + + +class JunOS + + + cmd 'show interfaces diagnostics optics' do |cfg| + comment cfg + end + + +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. + +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 completely new model, with a new name, for a new operating system type. + +## Advanced features + +The loosely-coupled architecture of Oxidized allows for easy extensibility in more advanced use cases as well. + +The example below extends the functionality of the `JunOS` model further to collect `display set` formatted configuration from the device, and utilizes the multi-output functionality of the `git` output to place the returned configuration in a separate file within a git repository. + +It is possible to configure the `git` output to create new subdirectories under an existing repository instead of creating new repositories for each new defined output type (the default) by including the following configuration in the `~/.config/oxidized/config` file: + +```yaml +output: + git: + type_as_directory: true +``` + +Then, `~/.config/oxidized/model/junos.rb` is adapted as following: + +```ruby +require 'oxidized/model/junos.rb' + + +class JunOS + + + cmd 'show interface diagnostic optics' do |cfg| + comment cfg + end + + cmd 'show configuration | display set' do |cfg| + cfg.type = "junos-set" + cfg.name = "set" + cfg + end + + +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 diff --git a/docs/Extending-Models.md b/docs/Extending-Models.md deleted file mode 100644 index 0707157..0000000 --- a/docs/Extending-Models.md +++ /dev/null @@ -1,73 +0,0 @@ -# Extending and Customizing Oxidized Models - -Oxidized supports a growing list of [operating system types](Supported-OS-Types.md). Out of the box, most model implementations collect configuration data. Some implementations also include a conservative set of additional commands that collect basic device information (device make and model, software version, licensing information, ...) which are appended to the configuration as comments. - -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. - -## 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. - -Create the file `~/.config/oxidized/model/junos.rb` with the following contents: - -```ruby -require 'oxidized/mode/junos.rb' - - -class JunOS - - - cmd 'show interfaces diagnostics optics' do |cfg| - comment cfg - end - - -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. - -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 completely new model, with a new name, for a new operating system type. - -## Advanced features - -The loosely-coupled architecture of Oxidized allows for easy extensibility in more advanced use cases as well. - -The example below extends the functionality of the `JunOS` model further to collect `display set` formatted configuration from the device, and utilizes the multi-output functionality of the `git` output to place the returned configuration in a separate file within a git repository. - -It is possible to configure the `git` output to create new subdirectories under an existing repository instead of creating new repositories for each new defined output type (the default) by including the following configuration in the `~/.config/oxidized/config` file: - -```yaml -output: - git: - type_as_directory: true -``` - -Then, `~/.config/oxidized/model/junos.rb` is adapted as following: - -```ruby -require 'oxidized/mode/junos.rb' - - -class JunOS - - - cmd 'show interface diagnostic optics' do |cfg| - comment cfg - end - - cmd 'show configuration | display set' do |cfg| - cfg.type = "junos-set" - cfg.name = "set" - cfg - end - - -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 -- cgit v1.2.1 From 577128f962f02e81ce7664e32fb97a46f2c220e8 Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Thu, 15 Mar 2018 01:54:55 -0700 Subject: add removal of secrets in edgeos, vyatta --- lib/oxidized/model/edgeos.rb | 4 ++++ lib/oxidized/model/vyatta.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/oxidized/model/edgeos.rb b/lib/oxidized/model/edgeos.rb index bb0aab5..aa7a197 100644 --- a/lib/oxidized/model/edgeos.rb +++ b/lib/oxidized/model/edgeos.rb @@ -9,6 +9,10 @@ class Edgeos < Oxidized::Model end cmd :secret do |cfg| + cfg.gsub! /encrypted-password (\S+).*/, 'encrypted-password ' + cfg.gsub! /plaintext-password (\S+).*/, 'plaintext-password ' + cfg.gsub! /password (\S+).*/, 'password ' + cfg.gsub! /pre-shared-secret (\S+).*/, 'pre-shared-secret ' cfg.gsub! /community (\S+) {/, 'community {' cfg end diff --git a/lib/oxidized/model/vyatta.rb b/lib/oxidized/model/vyatta.rb index aa0bc74..57ec9d3 100644 --- a/lib/oxidized/model/vyatta.rb +++ b/lib/oxidized/model/vyatta.rb @@ -9,6 +9,10 @@ class Vyatta < Oxidized::Model end cmd :secret do |cfg| + cfg.gsub! /encrypted-password (\S+).*/, 'encrypted-password ' + cfg.gsub! /plaintext-password (\S+).*/, 'plaintext-password ' + cfg.gsub! /password (\S+).*/, 'password ' + cfg.gsub! /pre-shared-secret (\S+).*/, 'pre-shared-secret ' cfg.gsub! /community (\S+) {/, 'community {' cfg end -- cgit v1.2.1 From 05e1d505f2cc30e87b1cdcf90db966690882f610 Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Thu, 15 Mar 2018 02:18:38 -0700 Subject: add secrets to sanitize in JunOS --- lib/oxidized/model/junos.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index 2f59414..4652ab1 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -13,7 +13,9 @@ class JunOS < Oxidized::Model end cmd :secret do |cfg| - cfg.gsub!(/encrypted-password (\S+).*/, '') + cfg.gsub!(/encrypted-password (\S+).*/, 'encrypted-password ') + cfg.gsub!(/pre-shared-key ascii-text (\S+).*/, 'pre-shared-key ascii-text ') + cfg.gsub!(/authentication-key (\S+).*/, 'authentication-key ') cfg.gsub!(/community (\S+) {/, 'community {') cfg end -- cgit v1.2.1 From 227f1af00c6d43e9627fa2803d90617bebcd1d83 Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Thu, 15 Mar 2018 02:23:45 -0700 Subject: add hexadecimal for junos pre-shared-secret --- lib/oxidized/model/junos.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index 4652ab1..2ea0179 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -15,6 +15,7 @@ class JunOS < Oxidized::Model cmd :secret do |cfg| cfg.gsub!(/encrypted-password (\S+).*/, 'encrypted-password ') cfg.gsub!(/pre-shared-key ascii-text (\S+).*/, 'pre-shared-key ascii-text ') + cfg.gsub!(/pre-shared-key hexadecimal (\S+).*/, 'pre-shared-key hexadecimal ') cfg.gsub!(/authentication-key (\S+).*/, 'authentication-key ') cfg.gsub!(/community (\S+) {/, 'community {') cfg -- cgit v1.2.1 From dc28e4b352dde0b43656c93f852e744125dd708e Mon Sep 17 00:00:00 2001 From: Brian Candler Date: Thu, 15 Mar 2018 19:57:33 +0000 Subject: Skip the word 'encrypted' in Powerconnect password masking Fixes #1212 --- lib/oxidized/model/powerconnect.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb index 61e1cf2..f602a36 100644 --- a/lib/oxidized/model/powerconnect.rb +++ b/lib/oxidized/model/powerconnect.rb @@ -14,7 +14,7 @@ class PowerConnect < Oxidized::Model end cmd :secret do |cfg| - cfg.gsub! /^username (\S+) password \S+ (.*)/, 'username \1 password \2' + cfg.gsub! /^(username \S+ password (?:encrypted )?)\S+(.*)/, '\1\2' cfg end -- cgit v1.2.1 From ce0216fde8cdf562be4cc9d39aba2cf003d3c7f6 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 16 Mar 2018 16:19:21 +0100 Subject: documentation touch-ups and issue #1218 --- README.md | 20 ++++++++++++-------- docs/Creating-Models.md | 2 +- docs/Model-Notes/VRP-Huawei.md | 2 ++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 336c05a..09929af 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,26 @@ # Oxidized [![Build Status](https://travis-ci.org/Shopify/oxidized.svg)](https://travis-ci.org/Shopify/oxidized) [![Gem Version](https://badge.fury.io/rb/oxidized.svg)](http://badge.fury.io/rb/oxidized) [![Join the chat at https://gitter.im/oxidized/Lobby](https://badges.gitter.im/oxidized/Lobby.svg)](https://gitter.im/oxidized/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -> Is your company using Oxidized and has Ruby developers on staff? I'd love help from an extra maintainer! +Oxidized is a network device configuration backup tool. It's a RANCID replacement! -[WANTED: MAINTAINER](#help-needed) +Light and extensible, Oxidized supports over 90 operating system types. -Oxidized is a network device configuration backup tool. It's a RANCID replacement! +Feature highlights: * Automatically adds/removes threads to meet configured retrieval interval -* Restful API to move node immediately to head-of-queue (GET/POST /node/next/[NODE]) -* Syslog udp+file example to catch config change event (ios/junos) and trigger config fetch - * Will signal ios/junos user who made change, which output modules can use (via POST) - * The git output module uses this info - 'git blame' will for each line show who made the change and when +* Restful API to a move node immediately to head-of-queue (GET/POST /node/next/[NODE]) +* Syslog udp+file example to catch config change events (IOS/JunOS) and trigger a config fetch + * Will signal which IOS/JunOS user made the change, can then be used by output modules (via POST) + * The `git` output module uses this info - 'git blame' will show who changed each line, and when * Restful API to reload list of nodes (GET /reload) * Restful API to fetch configurations (/node/fetch/[NODE] or /node/fetch/group/[NODE]) * Restful API to show list of nodes (GET /nodes) * Restful API to show list of version for a node (/node/version[NODE]) and diffs -[Youtube Video: Oxidized TREX 2014 presentation](http://youtu.be/kBQ_CTUuqeU#t=3h) +Check out the [Oxidized TREX 2014 presentation](http://youtu.be/kBQ_CTUuqeU#t=3h) video on YouTube! + +> :warning: [Maintainer Wanted!](#help-needed) :warning: +> +> Is your company using Oxidized and has Ruby developers on staff? I'd love help from an extra maintainer! ## Index diff --git a/docs/Creating-Models.md b/docs/Creating-Models.md index 3c343e6..d7a8155 100644 --- a/docs/Creating-Models.md +++ b/docs/Creating-Models.md @@ -1,4 +1,4 @@ -# Creating and Extending Oxidized Models +# Creating and Extending Models Oxidized supports a growing list of [operating system types](Supported-OS-Types.md). Out of the box, most model implementations collect configuration data. Some implementations also include a conservative set of additional commands that collect basic device information (device make and model, software version, licensing information, ...) which are appended to the configuration as comments. diff --git a/docs/Model-Notes/VRP-Huawei.md b/docs/Model-Notes/VRP-Huawei.md index e68a959..a5c0c99 100644 --- a/docs/Model-Notes/VRP-Huawei.md +++ b/docs/Model-Notes/VRP-Huawei.md @@ -30,4 +30,6 @@ Command 2 and 3 can be executed without issues, but 1 and 4 are only available f Oxidized can now retrieve your configuration! +Caveat: Some versions of VRP default to appending a timestamp prior to the output of each `display` command, which will lead to superfluous updates. The configuration statement `timestamp disable` can be used to disable this functionality. (Issue #1218) + Back to [Model-Notes](README.md) -- cgit v1.2.1 From 720facc6f80d2b977d73b944c81c63b6d95e768b Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 16 Mar 2018 20:31:09 +0100 Subject: improve spelling in docs --- README.md | 4 ++-- docs/Configuration.md | 2 +- docs/Hooks.md | 4 ++-- docs/Model-Notes/AireOS.md | 2 +- docs/Model-Notes/Comware.md | 2 +- docs/Model-Notes/README.md | 4 ++-- docs/Model-Notes/VRP-Huawei.md | 2 +- docs/Sources.md | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 09929af..076c4d5 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ gem install pkg/*.gem ### Running with Docker -Currently, Docker Hub automatcally builds the master branch as [oxidized/oxidized](https://hub.docker.com/r/oxidized/oxidized/), you can make use of this container or build your own. +Currently, Docker Hub automatically builds the master branch as [oxidized/oxidized](https://hub.docker.com/r/oxidized/oxidized/), you can make use of this container or build your own. To build your own, clone git repo: @@ -165,7 +165,7 @@ oxidized: - /etc/oxidized:/root/.config/oxidized ``` -Create the `/etc/oxidized/router.db` (see [CSV Source](docs/Sources.md#source-csv) for futher info): +Create the `/etc/oxidized/router.db` (see [CSV Source](docs/Sources.md#source-csv) for further info): ```shell vim /etc/oxidized/router.db diff --git a/docs/Configuration.md b/docs/Configuration.md index 59e3f6d..6bbbb61 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -54,7 +54,7 @@ The above strips out snmp community strings from your saved configs. ## Disabling SSH exec channels -Oxidized uses exec channels to make information extraction simpler, but there are some situations where this doesn't work well, e.g. configuring devices. This feature can be turned off by setting the `ssh_no_exec` +Oxidized uses exec channels to make information extraction simpler, but there are some situations where this doesn't work well, e.g. configuring devices. This feature can be turned off by setting the `ssh_no_exec` variable. ```yaml diff --git a/docs/Hooks.md b/docs/Hooks.md index 1d263fb..8a0a8b9 100644 --- a/docs/Hooks.md +++ b/docs/Hooks.md @@ -11,7 +11,7 @@ Following configuration keys need to be defined for all hooks: ### Events -* `node_success`: triggered when configuration is succesfully pulled from a node and right before storing the configuration. +* `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. * `post_store`: triggered after node configuration is stored (this is executed only when the configuration has changed). * `nodes_done`: triggered after finished fetching all nodes. @@ -62,7 +62,7 @@ hooks: ### Hook type: githubrepo -This hook configures the repository `remote` and _push_ the code when the specified event is triggerd. If the `username` and `password` are not provided, the `Rugged::Credentials::SshKeyFromAgent` will be used. +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. `githubrepo` hook recognizes following configuration keys: diff --git a/docs/Model-Notes/AireOS.md b/docs/Model-Notes/AireOS.md index 9962f31..5674ae2 100644 --- a/docs/Model-Notes/AireOS.md +++ b/docs/Model-Notes/AireOS.md @@ -1,7 +1,7 @@ Cisco WLC Configuration ======================= -Create a user with read-write privilege : +Create a user with read-write privilege: ```text mgmtuser add oxidized **** read-write diff --git a/docs/Model-Notes/Comware.md b/docs/Model-Notes/Comware.md index 0da019a..e7a2198 100644 --- a/docs/Model-Notes/Comware.md +++ b/docs/Model-Notes/Comware.md @@ -1,7 +1,7 @@ Comware Configuration ===================== -If you find 3Com comware devices aren't being backed up this may be due to prompt detection not matching because a previous login message is disabled after the first prompt. +If you find 3Com Comware devices aren't being backed up this may be due to prompt detection not matching because a previous login message is disabled after the first prompt. You can disable this on the devices themselves by running this command: diff --git a/docs/Model-Notes/README.md b/docs/Model-Notes/README.md index 8dcabd3..c4b0ed1 100644 --- a/docs/Model-Notes/README.md +++ b/docs/Model-Notes/README.md @@ -1,7 +1,7 @@ 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. @@ -12,6 +12,6 @@ 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)|23 Jan 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/docs/Model-Notes/VRP-Huawei.md b/docs/Model-Notes/VRP-Huawei.md index a5c0c99..ff5426e 100644 --- a/docs/Model-Notes/VRP-Huawei.md +++ b/docs/Model-Notes/VRP-Huawei.md @@ -19,7 +19,7 @@ The commands Oxidized executes are: 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: +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 privilege-level for commands 1 and 4: ```text system-view diff --git a/docs/Sources.md b/docs/Sources.md index 5599409..6d8e19e 100644 --- a/docs/Sources.md +++ b/docs/Sources.md @@ -2,7 +2,7 @@ ## Source: CSV -One line per device, colon seperated. If `ip` isn't present, a DNS lookup will be done against `name`. For large installations, setting `ip` will dramatically reduce startup time. +One line per device, colon separated. If `ip` isn't present, a DNS lookup will be done against `name`. For large installations, setting `ip` will dramatically reduce startup time. ```yaml source: @@ -105,7 +105,7 @@ source: ## 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. +You may also implement a custom SQL query to retrieve the nodelist using SQL syntax with the `query:` configuration parameter under the `sql:` stanza. ### Custom SQL Query Examples -- cgit v1.2.1 From 7445e7ae80aa291a816fdae5fbec0594401ea9c9 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 17 Mar 2018 12:13:43 +0100 Subject: restore backward compatibility with a supermicro shim --- lib/oxidized/model/supermicro.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lib/oxidized/model/supermicro.rb diff --git a/lib/oxidized/model/supermicro.rb b/lib/oxidized/model/supermicro.rb new file mode 100644 index 0000000..9cfa0a3 --- /dev/null +++ b/lib/oxidized/model/supermicro.rb @@ -0,0 +1,7 @@ +# Backward compatibility shim for deprecated model `supermicro`. +# Migrate your source from `supermicro` to `edgecos`. + +require_relative 'edgecos.rb' + +Supermicro = EdgeCOS + -- cgit v1.2.1 From 640bdb90f096334d3c6a6e2dd7fce8d34c1fba96 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 17 Mar 2018 12:44:01 +0100 Subject: complain when backward compatibility shim is used --- lib/oxidized/model/supermicro.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/oxidized/model/supermicro.rb b/lib/oxidized/model/supermicro.rb index 9cfa0a3..518ae41 100644 --- a/lib/oxidized/model/supermicro.rb +++ b/lib/oxidized/model/supermicro.rb @@ -5,3 +5,5 @@ require_relative 'edgecos.rb' Supermicro = EdgeCOS +Oxidized.logger.warn "Using deprecated model supermicro, use edgecos instead." + -- cgit v1.2.1 From 9862cff359d6abc7bdc260600acd293d2d85dd2b Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 17 Mar 2018 13:04:20 +0100 Subject: restore dev comment of @tobbez to aricentiss model --- docs/Supported-OS-Types.md | 3 +-- lib/oxidized/model/aricentiss.rb | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 2e1de7c..1717284 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -141,8 +141,7 @@ * Supermicro * [SSE-G2252, G2252P](/lib/oxidized/model/edgecos.rb) * [SSE-G48-TG4, G24-TG4](/lib/oxidized/model/aricentiss.rb) - * [SSE-X24S, X24SR, X3348S, X3348SR, X3348T, - * X3348TR](/lib/oxidized/model/aricentiss.rb) + * [SSE-X24S, X24SR, X3348S, X3348SR, X3348T, X3348TR](/lib/oxidized/model/aricentiss.rb) * [SBM-GEM-X2C, GEM-X2C+, GEM-X3S+, XEM-X10SM](/lib/oxidized/model/aricentiss.rb) * Symantec * [Blue Coat ProxySG / Security Gateway OS (SGOS)](/lib/oxidized/model/sgos.rb) diff --git a/lib/oxidized/model/aricentiss.rb b/lib/oxidized/model/aricentiss.rb index 8675263..60c2f48 100644 --- a/lib/oxidized/model/aricentiss.rb +++ b/lib/oxidized/model/aricentiss.rb @@ -1,3 +1,8 @@ +# Developed against: +# #show version +# Switch ID Hardware Version Firmware Version +# 0 SSE-G48-TG4 (P2-01) 1.0.16-9 + class AricentISS < Oxidized::Model prompt (/^(\e\[27m)?[ \r]*\w+# ?$/) -- cgit v1.2.1 From 2978d671a195a024893150cdf27b8a136d18e003 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 17 Mar 2018 13:24:02 +0100 Subject: correct typo in command to disable pagination --- lib/oxidized/model/aricentiss.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/aricentiss.rb b/lib/oxidized/model/aricentiss.rb index 60c2f48..80735c7 100644 --- a/lib/oxidized/model/aricentiss.rb +++ b/lib/oxidized/model/aricentiss.rb @@ -8,7 +8,7 @@ class AricentISS < Oxidized::Model prompt (/^(\e\[27m)?[ \r]*\w+# ?$/) cfg :ssh do - post_login 'no cli pagignation' + post_login 'no cli pagination' pre_logout 'exit' end -- cgit v1.2.1 From d3c96a04c15ff0c6cae00d0721a6f5216357207f Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 17 Mar 2018 17:49:18 +0100 Subject: transition timos to sros --- docs/Supported-OS-Types.md | 4 +- lib/oxidized/model/sros.rb | 118 ++++++++++++++++++++++++++++++++++++++ lib/oxidized/model/supermicro.rb | 1 + lib/oxidized/model/timos.rb | 120 ++------------------------------------- 4 files changed, 127 insertions(+), 116 deletions(-) create mode 100644 lib/oxidized/model/sros.rb diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 1717284..493918d 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -10,7 +10,7 @@ * [AOS](/lib/oxidized/model/aos.rb) * [AOS7](/lib/oxidized/model/aos7.rb) * [ISAM](/lib/oxidized/model/isam.rb) - * [SR OS (Formerly TiMOS)](/lib/oxidized/model/timos.rb) + * [SR OS (Formerly TiMOS)](/lib/oxidized/model/sros.rb) * Wireless * Allied Telesis * [Alliedware Plus](/lib/oxidized/model/awplus.rb) @@ -122,7 +122,7 @@ * Netonix * [WISP Switch (As Netonix)](/lib/oxidized/model/netonix.rb) * Nokia (formerly TiMetra, Alcatel, Alcatel-Lucent) - * [SR OS (TiMOS)](/lib/oxidized/model/timos.rb) + * [SR OS (TiMOS)](/lib/oxidized/model/sros.rb) * OneAccess * [OneOS](/lib/oxidized/model/oneos.rb) * Opengear diff --git a/lib/oxidized/model/sros.rb b/lib/oxidized/model/sros.rb new file mode 100644 index 0000000..289bed3 --- /dev/null +++ b/lib/oxidized/model/sros.rb @@ -0,0 +1,118 @@ +class SROS < Oxidized::Model + + # + # Nokia SR OS (TiMOS) (formerly TiMetra, Alcatel, Alcatel-Lucent). + # Used in 7705 SAR, 7210 SAS, 7450 ESS, 7750 SR, 7950 XRS, and NSP. + # + + comment '# ' + + prompt /^([-\w\.:>\*]+\s?[#>]\s?)$/ + + cmd :all do |cfg, cmdstring| + new_cfg = comment "COMMAND: #{cmdstring}\n" + new_cfg << cfg.each_line.to_a[1..-2].join + end + + # + # Show the boot options file. + # + cmd 'show bof' do |cfg| + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' + comment cfg + end + + # + # Show the system information. + # + cmd 'show system information' do |cfg| + # + # Strip uptime. + # + cfg.sub! /^System Up Time.*\n/, '' + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' + comment cfg + end + + # + # Show the card state. + # + cmd 'show card state' do |cfg| + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' + comment cfg + end + + # + # Show the boot log. + # + cmd 'file type bootlog.txt' do |cfg| + # + # Strip carriage returns and backspaces. + # + cfg.gsub! /\r/, '' + cfg.gsub! /[\b][\b][\b]/, "\n" + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' + comment cfg + end + + # + # Show the running debug configuration. + # + cmd 'show debug' do |cfg| + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' + comment cfg + end + + # + # Show the saved debug configuration (admin debug-save). + # + cmd 'file type config.dbg' do |cfg| + # + # Strip carriage returns. + # + cfg.gsub! /\r/, '' + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' + comment cfg + end + + # + # Show the running persistent indices. + # + cmd 'admin display-config index' do |cfg| + # + # Strip carriage returns. + # + cfg.gsub! /\r/, '' + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' + comment cfg + end + + # + # Show the running configuration. + # + cmd 'admin display-config' do |cfg| + # + # Strip carriage returns. + # + cfg.gsub! /\r/, '' + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' + end + + cfg :telnet do + username /^Login: / + password /^Password: / + end + + cfg :telnet, :ssh do + post_login 'environment no more' + pre_logout 'logout' + end +end diff --git a/lib/oxidized/model/supermicro.rb b/lib/oxidized/model/supermicro.rb index 518ae41..56d5ef6 100644 --- a/lib/oxidized/model/supermicro.rb +++ b/lib/oxidized/model/supermicro.rb @@ -7,3 +7,4 @@ Supermicro = EdgeCOS Oxidized.logger.warn "Using deprecated model supermicro, use edgecos instead." +# Deprecated diff --git a/lib/oxidized/model/timos.rb b/lib/oxidized/model/timos.rb index c230a8f..e454630 100644 --- a/lib/oxidized/model/timos.rb +++ b/lib/oxidized/model/timos.rb @@ -1,118 +1,10 @@ -class TiMOS < Oxidized::Model +# Backward compatibility shim for deprecated model `timos`. +# Migrate your source from `timos` to `sros`. - # - # Nokia SR OS (TiMOS) (formerly TiMetra, Alcatel, Alcatel-Lucent). - # Used in 7705 SAR, 7210 SAS, 7450 ESS, 7750 SR, 7950 XRS, and NSP. - # +require_relative 'sros.rb' - comment '# ' +TiMOS = SROS - prompt /^([-\w\.:>\*]+\s?[#>]\s?)$/ +Oxidized.logger.warn "Using deprecated model timos, use sros instead." - cmd :all do |cfg, cmdstring| - new_cfg = comment "COMMAND: #{cmdstring}\n" - new_cfg << cfg.each_line.to_a[1..-2].join - end - - # - # Show the boot options file. - # - cmd 'show bof' do |cfg| - cfg.gsub! /# Finished .*/, '' - cfg.gsub! /# Generated .*/, '' - comment cfg - end - - # - # Show the system information. - # - cmd 'show system information' do |cfg| - # - # Strip uptime. - # - cfg.sub! /^System Up Time.*\n/, '' - cfg.gsub! /# Finished .*/, '' - cfg.gsub! /# Generated .*/, '' - comment cfg - end - - # - # Show the card state. - # - cmd 'show card state' do |cfg| - cfg.gsub! /# Finished .*/, '' - cfg.gsub! /# Generated .*/, '' - comment cfg - end - - # - # Show the boot log. - # - cmd 'file type bootlog.txt' do |cfg| - # - # Strip carriage returns and backspaces. - # - cfg.gsub! /\r/, '' - cfg.gsub! /[\b][\b][\b]/, "\n" - cfg.gsub! /# Finished .*/, '' - cfg.gsub! /# Generated .*/, '' - comment cfg - end - - # - # Show the running debug configuration. - # - cmd 'show debug' do |cfg| - cfg.gsub! /# Finished .*/, '' - cfg.gsub! /# Generated .*/, '' - comment cfg - end - - # - # Show the saved debug configuration (admin debug-save). - # - cmd 'file type config.dbg' do |cfg| - # - # Strip carriage returns. - # - cfg.gsub! /\r/, '' - cfg.gsub! /# Finished .*/, '' - cfg.gsub! /# Generated .*/, '' - comment cfg - end - - # - # Show the running persistent indices. - # - cmd 'admin display-config index' do |cfg| - # - # Strip carriage returns. - # - cfg.gsub! /\r/, '' - cfg.gsub! /# Finished .*/, '' - cfg.gsub! /# Generated .*/, '' - comment cfg - end - - # - # Show the running configuration. - # - cmd 'admin display-config' do |cfg| - # - # Strip carriage returns. - # - cfg.gsub! /\r/, '' - cfg.gsub! /# Finished .*/, '' - cfg.gsub! /# Generated .*/, '' - end - - cfg :telnet do - username /^Login: / - password /^Password: / - end - - cfg :telnet, :ssh do - post_login 'environment no more' - pre_logout 'logout' - end -end +# Deprecated -- cgit v1.2.1 From 7c5ca77a2e0349b87128fa6d143f391a9204b0f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20L=C3=B6nnemark?= Date: Mon, 19 Mar 2018 12:11:21 +0100 Subject: AricentISS: Fix pagination for old OS versions Always issue both 'no cli pagination' and 'no cli pagignation'. Conditionally issuing only the correct variant would require sending the same number of commands to the switch ('show version', 'no cli pagi(g)nation') and also require extra logic in the model. Additionally, always issuing both removes the need for storing information about what OS versions require which command in the model. --- lib/oxidized/model/aricentiss.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/oxidized/model/aricentiss.rb b/lib/oxidized/model/aricentiss.rb index 80735c7..8821801 100644 --- a/lib/oxidized/model/aricentiss.rb +++ b/lib/oxidized/model/aricentiss.rb @@ -8,7 +8,10 @@ class AricentISS < Oxidized::Model prompt (/^(\e\[27m)?[ \r]*\w+# ?$/) cfg :ssh do + # "pagination" was misspelled in some (earlier) versions (at least 1.0.16-9) + # 1.0.18-15 is known to include the corrected spelling post_login 'no cli pagination' + post_login 'no cli pagignation' pre_logout 'exit' end -- cgit v1.2.1 From 343cf3227cafe4a7de4a7be5934163eb6bd2dba9 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Tue, 20 Mar 2018 23:17:29 +0100 Subject: expand dcnos model --- lib/oxidized/model/dcnos.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index 5a39e2b..4a33fa0 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -12,6 +12,14 @@ class DCNOS < Oxidized::Model comment cfg end + cmd 'show boot-files' do |cfg| + comment cfg + end + + cmd 'show flash' do |cfg| + comment cfg + end + cmd 'show running-config' do |cfg| cfg = cfg.each_line.to_a[1..-1] end -- cgit v1.2.1 From 2d8e40344a05ac16869941c19dbcd6df8ddac80c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Tue, 20 Mar 2018 23:38:23 +0100 Subject: better comments --- lib/oxidized/model/dcnos.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index 4a33fa0..c6b2e36 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -6,7 +6,7 @@ class DCNOS < Oxidized::Model - comment '!' + comment '! ' cmd 'show version' do |cfg| comment cfg -- cgit v1.2.1 From ff0a42cdfd2bdb34d0852a0d85f63825a44fdf1b Mon Sep 17 00:00:00 2001 From: James Hannah Date: Wed, 21 Mar 2018 09:02:38 +0000 Subject: Alter DNOS config. Remove constantly changing info Gsub out the uptime which changes constantly, and remove the output of "show system" which duplicates the info from "show version" and contains fan speed data which isn't helpful. --- lib/oxidized/model/dnos.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/oxidized/model/dnos.rb b/lib/oxidized/model/dnos.rb index 5c3cd53..22e1876 100644 --- a/lib/oxidized/model/dnos.rb +++ b/lib/oxidized/model/dnos.rb @@ -6,6 +6,7 @@ class DNOS < Oxidized::Model cmd :all do |cfg| cfg.gsub! /^% Invalid input detected at '\^' marker\.$|^\s+\^$/, '' + cfg.gsub! /^Dell Networking OS uptime is\s.+/, '' # Omit constantly changing uptime info cfg.each_line.to_a[2..-2].join end @@ -27,10 +28,6 @@ class DNOS < Oxidized::Model 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 0878dd2ef1af0a731a647fc0fc4f3a245a0131a9 Mon Sep 17 00:00:00 2001 From: Uwe Werler Date: Wed, 21 Mar 2018 13:20:18 +0000 Subject: Update nxos.rb Otherwise the running config will not be stored. --- lib/oxidized/model/nxos.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oxidized/model/nxos.rb b/lib/oxidized/model/nxos.rb index e743415..60d6037 100644 --- a/lib/oxidized/model/nxos.rb +++ b/lib/oxidized/model/nxos.rb @@ -22,6 +22,7 @@ class NXOS < Oxidized::Model cmd 'show running-config' do |cfg| cfg.gsub! /^!Time:[^\n]*\n/, '' + cfg end cfg :ssh, :telnet do -- cgit v1.2.1 From 4ba96c79f7eaf5dd9c02c9488d77a5c896c96d8c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 23 Mar 2018 09:24:38 +0100 Subject: yield cfg for clarity --- lib/oxidized/model/dcnos.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index c6b2e36..f53bc0d 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -21,7 +21,8 @@ class DCNOS < Oxidized::Model end cmd 'show running-config' do |cfg| - cfg = cfg.each_line.to_a[1..-1] + cfg = cfg.each_line.to_a[1..-1].join + cfg end cfg :telnet do -- cgit v1.2.1 From 5ac9b61077ed1fcb5989b090dba79a0ef70fd2e7 Mon Sep 17 00:00:00 2001 From: Sascha Tetzel Date: Mon, 26 Mar 2018 10:00:50 +0000 Subject: Update hpebladesystem.rb - disable Last Update from NTP in Show Network, because it produced a new version with every backup (show network) - disable parsing of "----More----", it is better to user "Script Mode" (cfg :telnet, :ssh) -> post_login --- lib/oxidized/model/hpebladesystem.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/oxidized/model/hpebladesystem.rb b/lib/oxidized/model/hpebladesystem.rb index 5e34de8..27673de 100644 --- a/lib/oxidized/model/hpebladesystem.rb +++ b/lib/oxidized/model/hpebladesystem.rb @@ -4,10 +4,10 @@ class HPEBladeSystem < Oxidized::Model prompt /.*> / comment '# ' - expect /^\s*--More--\s+.*$/ do |data, re| - send ' ' - data.sub re, '' - end + #expect /^\s*--More--\s+.*$/ do |data, re| + # send ' ' + # data.sub re, '' + #end cmd :all do |cfg| cfg = cfg.delete("\r").each_line.to_a[0..-1].map{|line|line.rstrip}.join("\n") + "\n" @@ -40,6 +40,7 @@ class HPEBladeSystem < Oxidized::Model end cmd 'show network' do |cfg| + cfg.gsub! /Last Update:.*$/i, '' comment cfg end @@ -78,6 +79,7 @@ class HPEBladeSystem < Oxidized::Model end cfg :telnet, :ssh do + post_login "set script mode on" pre_logout "exit" end end -- cgit v1.2.1 From 2506abfc0e21686e53e0ae5178cd4db2cba2a8ab Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 29 Mar 2018 15:39:08 -0400 Subject: Add logrotate file Assuming `log:` is set to: > log: /var/log/oxidized/.log /var/log/oxidized will need to be owned by the user running oxidized --- extra/oxidized.logrotate | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 extra/oxidized.logrotate diff --git a/extra/oxidized.logrotate b/extra/oxidized.logrotate new file mode 100644 index 0000000..8c76dee --- /dev/null +++ b/extra/oxidized.logrotate @@ -0,0 +1,7 @@ +/var/log/oxidized/*.log { + weekly + rotate 3 + size 10M + compress + delaycompress +} -- cgit v1.2.1 From e5966308b36498b5397a97bf8f3c3fa3e4e71015 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 30 Mar 2018 20:46:02 +0200 Subject: document existence of FreeBSD package --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 076c4d5..ad2e974 100644 --- a/README.md +++ b/README.md @@ -95,9 +95,7 @@ gem install oxidized-script oxidized-web ### FreeBSD -[Use RVM to install Ruby v2.1.2](#installing-ruby-2.1.2-using-rvm) - -Install all required packages and gems. +[Use RVM to install Ruby v2.1.2](#installing-ruby-2.1.2-using-rvm), then install all required packages and gems: ```shell pkg install cmake pkgconf @@ -105,6 +103,12 @@ gem install oxidized gem install oxidized-script oxidized-web ``` +Oxidized is also available via [FreeBSD ports](https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203374): + +```shell +pkg install rubygem-oxidized rubygem-oxidized-script rubygem-oxidized-web +``` + ### Build from Git ```shell -- cgit v1.2.1 From 01aae786350764fb7b13df773a2d681c47552567 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 30 Mar 2018 20:49:10 +0200 Subject: fix broken anchor in FreeBSD docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad2e974..ce4d1a3 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ gem install oxidized-script oxidized-web ### FreeBSD -[Use RVM to install Ruby v2.1.2](#installing-ruby-2.1.2-using-rvm), then install all required packages and gems: +[Use RVM to install Ruby v2.1.2](#installing-ruby-212-using-rvm), then install all required packages and gems: ```shell pkg install cmake pkgconf -- cgit v1.2.1 From b2fcf887b3ea7e85e916ec7265a494a6efbf8fa7 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Thu, 5 Apr 2018 14:23:20 +0200 Subject: strip uptime info from show version --- lib/oxidized/model/dcnos.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index f53bc0d..ec0c7f6 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -9,6 +9,7 @@ class DCNOS < Oxidized::Model comment '! ' cmd 'show version' do |cfg| + cfg = cfg.gsub! /^(Uptime is ).*/, '' comment cfg end -- cgit v1.2.1 From b54a5e211f2127d9397e6d43c30fd47de33ee5a5 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Thu, 5 Apr 2018 15:29:00 +0200 Subject: unspeakable things took place in original PR, correcting model --- lib/oxidized/model/dcnos.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index ec0c7f6..8506280 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -8,8 +8,12 @@ class DCNOS < Oxidized::Model comment '! ' + cmd :all do |cfg| + cfg.each_line.to_a[1..-1].join + end + cmd 'show version' do |cfg| - cfg = cfg.gsub! /^(Uptime is ).*/, '' + cfg.gsub! /\s(Uptime is).*/, '' comment cfg end @@ -22,7 +26,6 @@ class DCNOS < Oxidized::Model end cmd 'show running-config' do |cfg| - cfg = cfg.each_line.to_a[1..-1].join cfg end -- cgit v1.2.1 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(-) 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.1 From cd466cc2d11c276f125d909b3196553570666537 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 6 Apr 2018 20:51:10 +0200 Subject: reorder dockerfile gem installation --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 36c650c..07adc0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,9 @@ COPY --from=libssh2-backport \ /tmp/ RUN dpkg -i /tmp/*.deb +# dependencies for hooks +RUN gem install aws-sdk slack-api xmpp4r + # build and install oxidized COPY . /tmp/oxidized/ WORKDIR /tmp/oxidized @@ -42,9 +45,6 @@ RUN gem install oxidized-*.gem # web interface RUN gem install oxidized-web --no-ri --no-rdoc -# dependencies for hooks -RUN gem install aws-sdk slack-api xmpp4r - # clean up WORKDIR / RUN rm -rf /tmp/oxidized -- cgit v1.2.1 From 265e7f55d7bf481757b12218e893231a7d6e092e Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 6 Apr 2018 21:19:07 +0200 Subject: refactor githubrepo credential handling --- lib/oxidized/hook/githubrepo.rb | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb index f74b22a..715438b 100644 --- a/lib/oxidized/hook/githubrepo.rb +++ b/lib/oxidized/hook/githubrepo.rb @@ -45,16 +45,23 @@ class GithubRepo < Oxidized::Hook private def credentials - @credentials ||= if cfg.has_key?('username') && cfg.has_key?('password') - log "Using https auth", :debug - Rugged::Credentials::UserPassword.new(username: cfg.username, password: cfg.password) - else - if cfg.has_key?('publickey') && cfg.has_key?('privatekey') - log "Using ssh auth with key", :debug - Rugged::Credentials::SshKey.new(username: 'git', publickey: File.expand_path(cfg.publickey), privatekey: File.expand_path(cfg.privatekey), passphrase: ENV["OXIDIZED_SSH_PASSPHRASE"]) + Proc.new do |url, username_from_url, allowed_types| + + if cfg.has_key?('username') + git_user = cfg.username + else + git_user = username_from_url ? username_from_url : 'git' + end + + if cfg.has_key?('password') + log "Authenticating using username and password", :debug + Rugged::Credentials::UserPassword.new(username: git_user, password: cfg.password) + elsif cfg.has_key?('publickey') && cfg.has_key?('privatekey') + log "Authenticating using ssh keys", :debug + Rugged::Credentials::SshKey.new(username: git_user, publickey: File.expand_path(cfg.publickey), privatekey: File.expand_path(cfg.privatekey), passphrase: ENV["OXIDIZED_SSH_PASSPHRASE"]) else - log "Using ssh auth with agentforwarding", :debug - Rugged::Credentials::SshKeyFromAgent.new(username: 'git') + log "Authenticating using ssh agent", :debug + Rugged::Credentials::SshKeyFromAgent.new(username: git_user) end end end -- cgit v1.2.1 From 331838fd9203dcf72e94ea218defc9a2115fabf6 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 6 Apr 2018 22:12:18 +0200 Subject: expose username in debug log --- lib/oxidized/hook/githubrepo.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb index 715438b..4cae4e6 100644 --- a/lib/oxidized/hook/githubrepo.rb +++ b/lib/oxidized/hook/githubrepo.rb @@ -54,13 +54,13 @@ class GithubRepo < Oxidized::Hook end if cfg.has_key?('password') - log "Authenticating using username and password", :debug + log "Authenticating using username and password as '#{git_user}'", :debug Rugged::Credentials::UserPassword.new(username: git_user, password: cfg.password) elsif cfg.has_key?('publickey') && cfg.has_key?('privatekey') - log "Authenticating using ssh keys", :debug + log "Authenticating using ssh keys as '#{git_user}'", :debug Rugged::Credentials::SshKey.new(username: git_user, publickey: File.expand_path(cfg.publickey), privatekey: File.expand_path(cfg.privatekey), passphrase: ENV["OXIDIZED_SSH_PASSPHRASE"]) else - log "Authenticating using ssh agent", :debug + log "Authenticating using ssh agent as '#{git_user}'", :debug Rugged::Credentials::SshKeyFromAgent.new(username: git_user) end end -- cgit v1.2.1 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(-) 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.1 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(-) 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.1 From f3c489be3d747af4608234fb55d93d8d3e037470 Mon Sep 17 00:00:00 2001 From: Martin Overgaard Hansen Date: Sat, 7 Apr 2018 21:34:18 +0200 Subject: Allowed prompt to contain hyphen --- lib/oxidized/model/aricentiss.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/aricentiss.rb b/lib/oxidized/model/aricentiss.rb index 8821801..14f8502 100644 --- a/lib/oxidized/model/aricentiss.rb +++ b/lib/oxidized/model/aricentiss.rb @@ -5,7 +5,7 @@ class AricentISS < Oxidized::Model - prompt (/^(\e\[27m)?[ \r]*\w+# ?$/) + prompt (/^(\e\[27m)?[ \r]*[\w-]+# ?$/) cfg :ssh do # "pagination" was misspelled in some (earlier) versions (at least 1.0.16-9) -- cgit v1.2.1 From 52934c5985e9f8084d2c28ad19be4fec43ef2942 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 7 Apr 2018 22:04:05 +0200 Subject: List hooks in README ToC (#1259) * add hooks to readme toc * remove unsightly colons --- README.md | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ce4d1a3..e65ca75 100644 --- a/README.md +++ b/README.md @@ -37,21 +37,26 @@ Check out the [Oxidized TREX 2014 presentation](http://youtu.be/kBQ_CTUuqeU#t=3h * [Debugging](docs/Configuration.md#debugging) * [Privileged mode](docs/Configuration.md#privileged-mode) * [Disabling SSH exec channels](docs/Configuration.md#disabling-ssh-exec-channels) - * [Sources:](docs/Sources.md) - * [Source: CSV](docs/Sources.md#source-csv) - * [Source: SQL](docs/Sources.md#source-sql) - * [Source: SQLite](docs/Sources.md#source-sqlite) - * [Source: Mysql](docs/Sources.md#source-mysql) - * [Source: HTTP](docs/Sources.md#source-http) - * [Outputs:](docs/Outputs.md) - * [Output: GIT](docs/Outputs.md#output-git) - * [Output: GIT-Crypt](docs/Outputs.md#output-git-crypt) - * [Output: HTTP](docs/Outputs.md#output-http) - * [Output: File](docs/Outputs.md#output-file) - * [Output types](docs/Outputs.md#output-types) + * [Sources](docs/Sources.md) + * [Source: CSV](docs/Sources.md#source-csv) + * [Source: SQL](docs/Sources.md#source-sql) + * [Source: SQLite](docs/Sources.md#source-sqlite) + * [Source: Mysql](docs/Sources.md#source-mysql) + * [Source: HTTP](docs/Sources.md#source-http) + * [Outputs](docs/Outputs.md) + * [Output: GIT](docs/Outputs.md#output-git) + * [Output: GIT-Crypt](docs/Outputs.md#output-git-crypt) + * [Output: HTTP](docs/Outputs.md#output-http) + * [Output: File](docs/Outputs.md#output-file) + * [Output types](docs/Outputs.md#output-types) * [Advanced Configuration](docs/Configuration.md#advanced-configuration) * [Advanced Group Configuration](docs/Configuration.md#advanced-group-configuration) * [Hooks](docs/Hooks.md) + * [Hook: exec](docs/Hooks.md#hook-type-exec) + * [Hook: githubrepo](docs/Hooks.md#hook-type-githubrepo) + * [Hook: awssns](docs/Hooks.md#hook-type-awssns) + * [Hook: slackdiff](docs/Hooks.md#hook-type-slackdiff) + * [Hook: xmppdiff](docs/Hooks.md#hook-type-xmppdiff) 5. [Creating and Extending Models](docs/Creating-Models.md) 6. [Help](#help) 7. [Ruby API](docs/Ruby-API.md#ruby-api) -- cgit v1.2.1 From a4bd3e5ca5ab747fdbf2bd876d7be7a947e74f46 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sun, 8 Apr 2018 00:35:47 +0200 Subject: eliminate inverse methods from models --- lib/oxidized/model/aosw.rb | 2 +- lib/oxidized/model/asa.rb | 2 +- lib/oxidized/model/comware.rb | 2 +- lib/oxidized/model/firewareos.rb | 2 +- lib/oxidized/model/powerconnect.rb | 4 ++-- lib/oxidized/model/procurve.rb | 2 +- lib/oxidized/model/routeros.rb | 2 +- lib/oxidized/model/vrp.rb | 2 +- lib/oxidized/model/zhoneolt.rb | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb index 71fde2e..3397305 100644 --- a/lib/oxidized/model/aosw.rb +++ b/lib/oxidized/model/aosw.rb @@ -40,7 +40,7 @@ class AOSW < Oxidized::Model end cmd 'show version' do |cfg| - cfg = cfg.each_line.select { |line| not line.match /(Switch|AP) uptime/i } + cfg = cfg.each_line.reject { |line| line.match /(Switch|AP) uptime/i } rstrip_cfg comment cfg.join end diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb index 9df4206..bea0705 100644 --- a/lib/oxidized/model/asa.rb +++ b/lib/oxidized/model/asa.rb @@ -27,7 +27,7 @@ class ASA < Oxidized::Model cmd 'show version' do |cfg| # avoid commits due to uptime / ixo-router01 up 2 mins 28 secs / ixo-router01 up 1 days 2 hours - cfg = cfg.each_line.select { |line| not line.match /(\s+up\s+\d+\s+)|(.*days.*)/ } + cfg = cfg.each_line.reject { |line| line.match /(\s+up\s+\d+\s+)|(.*days.*)/ } cfg = cfg.join comment cfg end diff --git a/lib/oxidized/model/comware.rb b/lib/oxidized/model/comware.rb index a5b7190..0ba26d5 100644 --- a/lib/oxidized/model/comware.rb +++ b/lib/oxidized/model/comware.rb @@ -47,7 +47,7 @@ class Comware < Oxidized::Model end cmd 'display version' do |cfg| - cfg = cfg.each_line.select {|l| not l.match /uptime/i }.join + cfg = cfg.each_line.reject { |l| l.match /uptime/i }.join comment cfg end diff --git a/lib/oxidized/model/firewareos.rb b/lib/oxidized/model/firewareos.rb index 1b3d07c..31770dc 100644 --- a/lib/oxidized/model/firewareos.rb +++ b/lib/oxidized/model/firewareos.rb @@ -15,7 +15,7 @@ class FirewareOS < Oxidized::Model cmd 'show sysinfo' do |cfg| # avoid commits due to uptime - cfg = cfg.each_line.select { |line| not line.match /(.*time.*)|(.*memory.*)|(.*cpu.*)/ } + cfg = cfg.each_line.reject { |line| line.match /(.*time.*)|(.*memory.*)|(.*cpu.*)/ } cfg = cfg.join comment cfg end diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb index f602a36..ca91e60 100644 --- a/lib/oxidized/model/powerconnect.rb +++ b/lib/oxidized/model/powerconnect.rb @@ -22,7 +22,7 @@ class PowerConnect < Oxidized::Model if (@stackable.nil?) @stackable = true if cfg.match /(U|u)nit\s/ end - cfg = cfg.split("\n").select { |line| not line[/Up\sTime/] } + cfg = cfg.split("\n").reject { |line| line[/Up\sTime/] } comment cfg.join("\n") + "\n" end @@ -72,7 +72,7 @@ class PowerConnect < Oxidized::Model end out << line.strip end - out = out.select { |line| not line[/Up\sTime/] } + out = out.reject { |line| line[/Up\sTime/] } out = comment out.join "\n" out << "\n" end diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 444fb5b..705a814 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -67,7 +67,7 @@ class Procurve < Oxidized::Model # not supported on all models cmd 'show system information' do |cfg| - cfg = cfg.each_line.select { |line| not line.match /(.*CPU.*)|(.*Up Time.*)|(.*Total.*)|(.*Free.*)|(.*Lowest.*)|(.*Missed.*)/ } + cfg = cfg.each_line.reject { |line| line.match /(.*CPU.*)|(.*Up Time.*)|(.*Total.*)|(.*Free.*)|(.*Lowest.*)|(.*Missed.*)/ } cfg = cfg.join comment cfg end diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb index 6717446..b62a3be 100644 --- a/lib/oxidized/model/routeros.rb +++ b/lib/oxidized/model/routeros.rb @@ -20,7 +20,7 @@ class RouterOS < Oxidized::Model cfg.gsub! /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/, '' # strip ANSI colours cfg.gsub! /\\\r\n\s+/, '' # strip new line cfg.gsub! /# inactive time\r\n/, '' # Remove time based system comment - cfg = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] } + cfg = cfg.split("\n").reject { |line| line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] } cfg.join("\n") + "\n" end end diff --git a/lib/oxidized/model/vrp.rb b/lib/oxidized/model/vrp.rb index 98229c3..e44f69e 100644 --- a/lib/oxidized/model/vrp.rb +++ b/lib/oxidized/model/vrp.rb @@ -25,7 +25,7 @@ class VRP < Oxidized::Model end cmd 'display version' do |cfg| - cfg = cfg.each_line.select {|l| not l.match /uptime/ }.join + cfg = cfg.each_line.reject { |l| l.match /uptime/ }.join comment cfg end diff --git a/lib/oxidized/model/zhoneolt.rb b/lib/oxidized/model/zhoneolt.rb index b60edb2..c50680c 100644 --- a/lib/oxidized/model/zhoneolt.rb +++ b/lib/oxidized/model/zhoneolt.rb @@ -39,7 +39,7 @@ class ZhoneOLT < Oxidized::Model end cmd 'dump console' do |cfg| - cfg = cfg.each_line.select { |line| not line.match /To Abort the operation enter Ctrl-C/ }.join + cfg = cfg.each_line.reject { |line| line.match /To Abort the operation enter Ctrl-C/ }.join end # zhone technically supports ssh, but it locks up a ton. Especially when -- cgit v1.2.1 From 0bebd8cb9ea83b4933aca702b2734e6597271fec Mon Sep 17 00:00:00 2001 From: Andre Sencioles Date: Mon, 9 Apr 2018 09:39:56 +1200 Subject: Disable paging for "show full-configuration" on FortiOS --- lib/oxidized/model/fortios.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb index 23370c4..9287dce 100644 --- a/lib/oxidized/model/fortios.rb +++ b/lib/oxidized/model/fortios.rb @@ -49,7 +49,7 @@ class FortiOS < Oxidized::Model cfg << cmd('end') if @vdom_enabled - cfg << cmd('show full-configuration') + cfg << cmd('show full-configuration | grep .') cfg.join "\n" end -- cgit v1.2.1 From 3596486a0f4c0ac2a8f92502ce0db18a5b69215b Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Mon, 9 Apr 2018 17:10:27 +0200 Subject: Delete Gemfile.lock --- Gemfile.lock | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 6ee594f..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,44 +0,0 @@ -PATH - remote: . - specs: - oxidized (0.21.0) - asetus (~> 0.1) - net-ssh (~> 3.0.2) - net-telnet (~> 0) - rugged (~> 0.21, >= 0.21.4) - slop (~> 3.5) - -GEM - remote: https://rubygems.org/ - specs: - asetus (0.3.0) - coderay (1.1.1) - git (1.3.0) - metaclass (0.0.4) - method_source (0.8.2) - minitest (5.10.1) - mocha (1.2.1) - metaclass (~> 0.0.1) - net-ssh (3.0.2) - net-telnet (0.1.1) - pry (0.11.0.pre2) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - rake (10.5.0) - rugged (0.25.1.1) - slop (3.6.0) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.10) - git (~> 1) - minitest (~> 5.8) - mocha (~> 1.1) - oxidized! - pry (~> 0) - rake (~> 10.0) - -BUNDLED WITH - 1.14.6 -- cgit v1.2.1 From 2f1b8163494547bcdf1c6ce1c4cb8600b39d40ee Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Mon, 9 Apr 2018 17:11:39 +0200 Subject: Update .gitignore to include Gemfile.lock --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0838e78..f6a2251 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /test/version_tmp/ /tmp/ .idea/ +Gemfile.lock # Used by dotenv library to load environment variables. # .env -- cgit v1.2.1 From 0e046c183afdef3be9a9f25629487817302579cf Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Tue, 10 Apr 2018 09:33:06 +0200 Subject: Update ssh_spec.rb --- spec/input/ssh_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/input/ssh_spec.rb b/spec/input/ssh_spec.rb index d86ffa0..7be9139 100644 --- a/spec/input/ssh_spec.rb +++ b/spec/input/ssh_spec.rb @@ -24,7 +24,7 @@ describe Oxidized::SSH do model = mock() model.expects(:cfg).returns({'ssh' => []}) - @node.expects(:model).returns(model) + @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) -- cgit v1.2.1 From 56ba0d670100de87f94778f434d26e87fc741fa0 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 11 Apr 2018 11:46:45 +0200 Subject: Update githubrepo_spec.rb to pass successfully --- spec/githubrepo_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/githubrepo_spec.rb b/spec/githubrepo_spec.rb index 2f84c78..e676534 100644 --- a/spec/githubrepo_spec.rb +++ b/spec/githubrepo_spec.rb @@ -32,7 +32,7 @@ describe GithubRepo do describe "#fetch_and_merge_remote" do before(:each) do Oxidized.config.hooks.github_repo_hook.remote_repo = 'git@github.com:username/foo.git' - Rugged::Credentials::SshKeyFromAgent.expects(:new).with(username: 'git').returns(credentials) + Proc.expects(:new).returns(credentials) repo_head.expects(:name).returns('refs/heads/master') gr.cfg = Oxidized.config.hooks.github_repo_hook end @@ -89,6 +89,7 @@ describe GithubRepo do end before do + Proc.expects(:new).returns(credentials) repo_head.expects(:name).twice.returns('refs/heads/master') repo.expects(:head).twice.returns(repo_head) repo.expects(:path).returns('/foo.git') @@ -108,14 +109,14 @@ describe GithubRepo do Oxidized.config.hooks.github_repo_hook.remote_repo = 'https://github.com/username/foo.git' Oxidized.config.hooks.github_repo_hook.username = 'username' Oxidized.config.hooks.github_repo_hook.password = 'password' - Rugged::Credentials::UserPassword.expects(:new).with(username: 'username', password: 'password').returns(credentials) + Proc.expects(:new).returns(credentials) gr.cfg = Oxidized.config.hooks.github_repo_hook gr.run_hook(ctx).must_equal true end it "will push to the remote repository using ssh" do Oxidized.config.hooks.github_repo_hook.remote_repo = 'git@github.com:username/foo.git' - Rugged::Credentials::SshKeyFromAgent.expects(:new).with(username: 'git').returns(credentials) + Proc.expects(:new).returns(credentials) gr.cfg = Oxidized.config.hooks.github_repo_hook gr.run_hook(ctx).must_equal true end @@ -125,7 +126,7 @@ describe GithubRepo do let(:group) { 'ggrroouupp' } before do - Rugged::Credentials::SshKeyFromAgent.expects(:new).with(username: 'git').returns(credentials) + Proc.expects(:new).returns(credentials) Rugged::Repository.expects(:new).with(repository).returns(repo) repo.expects(:remotes).twice.returns(remotes) -- cgit v1.2.1 From a58a8ed86b880988ed552772948cba60e496be7c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 11 Apr 2018 12:08:11 +0200 Subject: update build status badge to correct account --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e65ca75..ebe3d43 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Oxidized [![Build Status](https://travis-ci.org/Shopify/oxidized.svg)](https://travis-ci.org/Shopify/oxidized) [![Gem Version](https://badge.fury.io/rb/oxidized.svg)](http://badge.fury.io/rb/oxidized) [![Join the chat at https://gitter.im/oxidized/Lobby](https://badges.gitter.im/oxidized/Lobby.svg)](https://gitter.im/oxidized/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +# Oxidized [![Build Status](https://travis-ci.org/ytti/oxidized.svg)](https://travis-ci.org/ytti/oxidized) [![Gem Version](https://badge.fury.io/rb/oxidized.svg)](http://badge.fury.io/rb/oxidized) [![Join the chat at https://gitter.im/oxidized/Lobby](https://badges.gitter.im/oxidized/Lobby.svg)](https://gitter.im/oxidized/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Oxidized is a network device configuration backup tool. It's a RANCID replacement! -- cgit v1.2.1 From 9850a6b6107685c6cfc95f0411a5e61e0955bf85 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 11 Apr 2018 18:03:04 +0200 Subject: introduce rubocop and bump testing ecosystem --- .rubocop.yml | 20 + .rubocop_todo.yml | 1241 +++++++++++++++++++++++++++++++++++++++++++++++++++ Rakefile | 12 + oxidized.gemspec | 2 + spec/spec_helper.rb | 2 +- 5 files changed, 1276 insertions(+), 1 deletion(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..ad1ca31 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,20 @@ +inherit_from: .rubocop_todo.yml + +AllCops: + Include: + - Rakefile + +StringLiterals: + Enabled: false + +LineLength: + Enabled: false + +# Stick to verbose until https://bugs.ruby-lang.org/issues/10177 is closed. +Style/PreferredHashMethods: + EnforcedStyle: verbose + +AllCops: + Exclude: + - 'vendor/**/*' + - 'lib/oxidized/input/tftp.rb' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..8121015 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,1241 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2018-04-11 13:02:45 +0200 using RuboCop version 0.54.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: Include, TreatCommentsAsGroupSeparators. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'oxidized.gemspec' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'oxidized.gemspec' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: outdent, indent +Layout/AccessModifierIndentation: + Exclude: + - 'lib/oxidized/output/gitcrypt.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/AlignHash: + Exclude: + - 'spec/input/ssh_spec.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_parameter, with_fixed_indentation +Layout/AlignParameters: + Exclude: + - 'lib/oxidized/hook.rb' + - 'lib/oxidized/hook/exec.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/worker.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith. +# SupportedStylesAlignWith: either, start_of_block, start_of_line +Layout/BlockAlignment: + Exclude: + - 'lib/oxidized/model/awplus.rb' + - 'lib/oxidized/model/sgos.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Layout/BlockEndNewline: + Exclude: + - 'lib/oxidized/model/awplus.rb' + - 'lib/oxidized/model/hatteras.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Layout/CaseIndentation: + Exclude: + - 'lib/oxidized/output/http.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/ClosingParenthesisIndentation: + Exclude: + - 'lib/oxidized/output/git.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +Layout/CommentIndentation: + Exclude: + - 'lib/oxidized/model/aosw.rb' + - 'lib/oxidized/model/audiocodes.rb' + - 'lib/oxidized/model/awplus.rb' + - 'lib/oxidized/model/edgeswitch.rb' + - 'lib/oxidized/model/fujitsupy.rb' + - 'lib/oxidized/model/gcombnps.rb' + - 'lib/oxidized/model/masteros.rb' + - 'lib/oxidized/model/planet.rb' + - 'lib/oxidized/output/http.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. +# SupportedStylesAlignWith: start_of_line, def +Layout/DefEndAlignment: + Exclude: + - 'lib/oxidized/hook/xmppdiff.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Layout/ElseAlignment: + Exclude: + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/output/gitcrypt.rb' + - 'lib/oxidized/source/csv.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'oxidized.gemspec' + +# Offense count: 17 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/manager.rb' + - 'lib/oxidized/model/model.rb' + - 'lib/oxidized/nodes.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/output/gitcrypt.rb' + +# Offense count: 17 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'bin/oxidized' + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/model/acsw.rb' + - 'lib/oxidized/model/alvarion.rb' + - 'lib/oxidized/model/gaiaos.rb' + - 'lib/oxidized/model/gcombnps.rb' + - 'lib/oxidized/model/hatteras.rb' + - 'lib/oxidized/model/ironware.rb' + - 'lib/oxidized/model/planet.rb' + - 'lib/oxidized/model/voltaire.rb' + - 'lib/oxidized/nodes.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/output/gitcrypt.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'lib/oxidized/hook/githubrepo.rb' + - 'lib/oxidized/model/alvarion.rb' + - 'lib/oxidized/model/asyncos.rb' + - 'lib/oxidized/model/audiocodes.rb' + - 'lib/oxidized/model/ciscosma.rb' + - 'lib/oxidized/model/tplink.rb' + - 'spec/input/ssh_spec.rb' + - 'spec/node_spec.rb' + +# Offense count: 158 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Exclude: + - 'lib/oxidized/hook/exec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundMethodBody: + Exclude: + - 'lib/oxidized/output/http.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'lib/oxidized/input/cli.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. +# SupportedStylesAlignWith: keyword, variable, start_of_line +Layout/EndAlignment: + Exclude: + - 'lib/oxidized/output/gitcrypt.rb' + - 'lib/oxidized/source/csv.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: native, lf, crlf +Layout/EndOfLine: + Exclude: + - 'lib/oxidized/model/br6910.rb' + +# Offense count: 63 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Layout/FirstParameterIndentation: + Exclude: + - 'lib/oxidized/output/http.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/IndentHash: + Exclude: + - 'lib/oxidized/hook/awssns.rb' + - 'lib/oxidized/hook/githubrepo.rb' + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/output/http.rb' + - 'spec/githubrepo_spec.rb' + - 'spec/node_spec.rb' + +# Offense count: 21 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, rails +Layout/IndentationConsistency: + Exclude: + - 'lib/oxidized/model/acsw.rb' + - 'lib/oxidized/model/awplus.rb' + - 'lib/oxidized/model/fortios.rb' + - 'lib/oxidized/model/hpebladesystem.rb' + - 'lib/oxidized/model/masteros.rb' + - 'lib/oxidized/model/sgos.rb' + - 'lib/oxidized/model/slxos.rb' + - 'lib/oxidized/output/git.rb' + +# Offense count: 116 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Enabled: false + +# Offense count: 109 +# Cop supports --auto-correct. +Layout/LeadingCommentSpace: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/MultilineBlockLayout: + Exclude: + - 'lib/oxidized/model/hatteras.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineMethodCallBraceLayout: + Exclude: + - 'lib/oxidized/hook/slackdiff.rb' + - 'lib/oxidized/output/git.rb' + +# Offense count: 14 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Exclude: + - 'lib/oxidized/hook.rb' + - 'lib/oxidized/model/awplus.rb' + - 'lib/oxidized/model/hatteras.rb' + - 'lib/oxidized/model/quantaos.rb' + - 'lib/oxidized/model/trango.rb' + +# Offense count: 33 +# Cop supports --auto-correct. +Layout/SpaceAfterComma: + Enabled: false + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleInsidePipes. +# SupportedStylesInsidePipes: space, no_space +Layout/SpaceAroundBlockParameters: + Exclude: + - 'lib/oxidized/model/aos.rb' + - 'lib/oxidized/model/aos7.rb' + - 'lib/oxidized/model/c4cmts.rb' + - 'lib/oxidized/model/coriantgroove.rb' + - 'lib/oxidized/model/dlink.rb' + - 'lib/oxidized/model/enterasys.rb' + - 'lib/oxidized/model/hpebladesystem.rb' + - 'lib/oxidized/model/mtrlrfs.rb' + - 'lib/oxidized/model/xos.rb' + - 'lib/oxidized/model/zhoneolt.rb' + - 'lib/oxidized/node.rb' + +# Offense count: 32 +# Cop supports --auto-correct. +# Configuration parameters: . +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + EnforcedStyle: no_space + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/SpaceAroundKeyword: + Exclude: + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/model/xos.rb' + +# Offense count: 49 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceAroundOperators: + Enabled: false + +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Exclude: + - 'lib/oxidized/cli.rb' + - 'lib/oxidized/model/aos.rb' + - 'lib/oxidized/model/aos7.rb' + - 'lib/oxidized/model/c4cmts.rb' + - 'lib/oxidized/model/coriantgroove.rb' + - 'lib/oxidized/model/dlink.rb' + - 'lib/oxidized/model/enterasys.rb' + - 'lib/oxidized/model/hpebladesystem.rb' + - 'lib/oxidized/model/mtrlrfs.rb' + - 'lib/oxidized/model/xos.rb' + - 'lib/oxidized/model/zhoneolt.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/output/output.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Layout/SpaceBeforeComma: + Exclude: + - 'lib/oxidized/hook/exec.rb' + - 'lib/oxidized/model/fortios.rb' + +# Offense count: 25 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceBeforeFirstArg: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/input/telnet.rb' + - 'oxidized.gemspec' + +# Offense count: 31 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Enabled: false + +# Offense count: 23 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'lib/oxidized/hook/slackdiff.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/output/gitcrypt.rb' + - 'lib/oxidized/output/http.rb' + - 'spec/githubrepo_spec.rb' + - 'spec/input/ssh_spec.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +Layout/SpaceInsideParens: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/model/asa.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Layout/SpaceInsidePercentLiteralDelimiters: + Exclude: + - 'oxidized.gemspec' + +# Offense count: 6 +# Cop supports --auto-correct. +Layout/SpaceInsideRangeLiteral: + Exclude: + - 'lib/oxidized/input/telnet.rb' + +# Offense count: 302 +# Cop supports --auto-correct. +# Configuration parameters: IndentationWidth. +Layout/Tab: + Exclude: + - 'lib/oxidized/model/asyncos.rb' + - 'lib/oxidized/model/ciscosma.rb' + - 'lib/oxidized/model/cumulus.rb' + - 'lib/oxidized/output/gitcrypt.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingBlankLines: + Exclude: + - 'lib/oxidized/model/aen.rb' + - 'lib/oxidized/model/apc_aos.rb' + - 'lib/oxidized/model/firewareos.rb' + - 'lib/oxidized/model/gcombnps.rb' + - 'lib/oxidized/model/hpemsa.rb' + - 'lib/oxidized/model/mtrlrfs.rb' + - 'lib/oxidized/model/tplink.rb' + - 'lib/oxidized/output/http.rb' + +# Offense count: 165 +# Cop supports --auto-correct. +Layout/TrailingWhitespace: + Enabled: false + +# Offense count: 4 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'lib/oxidized/model/model.rb' + - 'lib/oxidized/model/nos.rb' + +# Offense count: 648 +Lint/AmbiguousRegexpLiteral: + Enabled: false + +# Offense count: 8 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Lint/DeprecatedClassMethods: + Exclude: + - 'lib/oxidized/cli.rb' + - 'lib/oxidized/output/file.rb' + - 'lib/oxidized/output/gitcrypt.rb' + +# Offense count: 3 +Lint/HandleExceptions: + Exclude: + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 2 +Lint/LiteralAsCondition: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/core.rb' + +# Offense count: 4 +Lint/ParenthesesAsGroupedExpression: + Exclude: + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/model/aricentiss.rb' + - 'lib/oxidized/model/asa.rb' + - 'lib/oxidized/model/ios.rb' + +# Offense count: 3 +Lint/ShadowingOuterLocalVariable: + Exclude: + - 'lib/oxidized/model/fortios.rb' + - 'lib/oxidized/model/planet.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Lint/StringConversionInInterpolation: + Exclude: + - 'lib/oxidized/hook/slackdiff.rb' + - 'lib/oxidized/hook/xmppdiff.rb' + +# Offense count: 10 +Lint/UnderscorePrefixedVariableName: + Exclude: + - 'lib/oxidized/input/cli.rb' + - 'lib/oxidized/manager.rb' + - 'lib/oxidized/model/model.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'lib/oxidized/hook/githubrepo.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'lib/oxidized/core.rb' + - 'lib/oxidized/hook.rb' + - 'lib/oxidized/output/file.rb' + +# Offense count: 12 +Lint/UselessAssignment: + Exclude: + - 'lib/oxidized/model/cumulus.rb' + - 'lib/oxidized/model/edgeos.rb' + - 'lib/oxidized/model/gaiaos.rb' + - 'lib/oxidized/model/mlnxos.rb' + - 'lib/oxidized/model/procurve.rb' + - 'lib/oxidized/model/trango.rb' + - 'lib/oxidized/model/voltaire.rb' + - 'lib/oxidized/model/vyatta.rb' + - 'lib/oxidized/model/zhoneolt.rb' + - 'lib/oxidized/output/gitcrypt.rb' + - 'lib/oxidized/output/http.rb' + - 'lib/oxidized/source/csv.rb' + +# Offense count: 1 +# Configuration parameters: CheckForMethodsWithNoSideEffects. +Lint/Void: + Exclude: + - 'lib/oxidized/model/voss.rb' + +# Offense count: 60 +Metrics/AbcSize: + Max: 86 + +# Offense count: 15 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 143 + +# Offense count: 4 +# Configuration parameters: CountBlocks. +Metrics/BlockNesting: + Max: 4 + +# Offense count: 7 +# Configuration parameters: CountComments. +Metrics/ClassLength: + Max: 210 + +# Offense count: 13 +Metrics/CyclomaticComplexity: + Max: 28 + +# Offense count: 53 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 72 + +# Offense count: 2 +# Configuration parameters: CountKeywordArgs. +Metrics/ParameterLists: + Max: 6 + +# Offense count: 14 +Metrics/PerceivedComplexity: + Max: 32 + +# Offense count: 1 +Naming/AccessorMethodName: + Exclude: + - 'lib/oxidized/string.rb' + +# Offense count: 1 +Naming/ClassAndModuleCamelCase: + Exclude: + - 'lib/oxidized/model/apc_aos.rb' + +# Offense count: 8 +Naming/ConstantName: + Exclude: + - 'extra/rest_client.rb' + - 'lib/oxidized/config.rb' + - 'lib/oxidized/hook.rb' + - 'lib/oxidized/input/ftp.rb' + - 'lib/oxidized/input/input.rb' + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/input/telnet.rb' + +# Offense count: 1 +Naming/MemoizedInstanceVariableName: + Exclude: + - 'lib/oxidized/string.rb' + +# Offense count: 3 +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'spec/**/*' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/worker.rb' + +# Offense count: 11 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: io, id, to +Naming/UncommunicativeMethodParamName: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/input/cli.rb' + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/model/model.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/Casecmp: + Exclude: + - 'lib/oxidized/manager.rb' + +# Offense count: 57 +# Cop supports --auto-correct. +Performance/RedundantMatch: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: MaxKeyValuePairs. +Performance/RedundantMerge: + Exclude: + - 'lib/oxidized/hook/exec.rb' + - 'lib/oxidized/input/telnet.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +Performance/StringReplacement: + Exclude: + - 'lib/oxidized/model/awplus.rb' + - 'lib/oxidized/model/comware.rb' + - 'lib/oxidized/model/sros.rb' + +# Offense count: 1 +Security/Eval: + Exclude: + - 'Rakefile' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect. +Security/JSONLoad: + Exclude: + - 'extra/nagios_check_failing_nodes.rb' + +# Offense count: 5 +Security/Open: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/cli.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/output/file.rb' + - 'lib/oxidized/source/csv.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: prefer_alias, prefer_alias_method +Style/Alias: + Exclude: + - 'lib/oxidized/node.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 46 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Enabled: false + +# Offense count: 1 +# Configuration parameters: AllowedChars. +Style/AsciiComments: + Exclude: + - 'lib/oxidized/hook/slackdiff.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'lib/oxidized/hook/xmppdiff.rb' + - 'lib/oxidized/model/aricentiss.rb' + - 'lib/oxidized/model/hatteras.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: + Exclude: + - 'lib/oxidized/hook/awssns.rb' + - 'lib/oxidized/hook/githubrepo.rb' + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/model/procurve.rb' + - 'lib/oxidized/output/http.rb' + - 'spec/githubrepo_spec.rb' + - 'spec/input/ssh_spec.rb' + - 'spec/node_spec.rb' + +# Offense count: 3 +Style/CaseEquality: + Exclude: + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/model/model.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'lib/oxidized/config/vars.rb' + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: is_a?, kind_of? +Style/ClassCheck: + Exclude: + - 'lib/oxidized/input/telnet.rb' + +# Offense count: 2 +Style/ClassVars: + Exclude: + - 'lib/oxidized.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'lib/oxidized/hook/xmppdiff.rb' + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/input/telnet.rb' + +# Offense count: 1 +Style/CommentedKeyword: + Exclude: + - 'lib/oxidized/input/telnet.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'lib/oxidized/hook/githubrepo.rb' + - 'lib/oxidized/model/model.rb' + +# Offense count: 142 +Style/Documentation: + Enabled: false + +# Offense count: 2 +Style/DoubleNegation: + Exclude: + - 'lib/oxidized/cli.rb' + - 'lib/oxidized/hook/exec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'lib/oxidized/hook.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Encoding: + Exclude: + - 'oxidized.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'bin/console' + - 'oxidized.gemspec' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: format, sprintf, percent +Style/FormatString: + Exclude: + - 'lib/oxidized/hook/slackdiff.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 16 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: annotated, template, unannotated +Style/FormatStringToken: + Exclude: + - 'lib/oxidized/node.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 15 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'lib/oxidized/cli.rb' + - 'lib/oxidized/hook/slackdiff.rb' + - 'lib/oxidized/hook/xmppdiff.rb' + - 'lib/oxidized/input/cli.rb' + - 'lib/oxidized/jobs.rb' + - 'lib/oxidized/nodes.rb' + - 'lib/oxidized/output/file.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/output/gitcrypt.rb' + - 'lib/oxidized/output/http.rb' + - 'lib/oxidized/source/http.rb' + - 'lib/oxidized/source/sql.rb' + - 'lib/oxidized/string.rb' + +# Offense count: 104 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Enabled: false + +# Offense count: 1 +Style/IfInsideElse: + Exclude: + - 'lib/oxidized/output/file.rb' + +# Offense count: 38 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Enabled: false + +# Offense count: 1 +Style/IfUnlessModifierOfIfUnless: + Exclude: + - 'lib/oxidized/input/ssh.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/InfiniteLoop: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/core.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'lib/oxidized/model/aosw.rb' + - 'lib/oxidized/model/asa.rb' + - 'lib/oxidized/model/comware.rb' + - 'lib/oxidized/model/firewareos.rb' + - 'lib/oxidized/model/powerconnect.rb' + - 'lib/oxidized/model/procurve.rb' + - 'lib/oxidized/model/routeros.rb' + - 'lib/oxidized/model/vrp.rb' + - 'lib/oxidized/model/zhoneolt.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/LineEndConcatenation: + Exclude: + - 'lib/oxidized/hook.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'spec/githubrepo_spec.rb' + - 'spec/input/ssh_spec.rb' + +# Offense count: 131 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline +Style/MethodDefParentheses: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/MultilineIfThen: + Exclude: + - 'lib/oxidized/model/aricentiss.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Style/MutableConstant: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/hook.rb' + - 'lib/oxidized/input/ftp.rb' + - 'lib/oxidized/input/input.rb' + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/version.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: both, prefix, postfix +Style/NegatedIf: + Exclude: + - 'lib/oxidized/model/ios.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/output/gitcrypt.rb' + - 'lib/oxidized/worker.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinBodyLength. +# SupportedStyles: skip_modifier_ifs, always +Style/Next: + Exclude: + - 'lib/oxidized/model/trango.rb' + - 'lib/oxidized/output/git.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NilComparison: + Exclude: + - 'lib/oxidized/input/ssh.rb' + +# Offense count: 31 +# Cop supports --auto-correct. +Style/Not: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedOctalStyle. +# SupportedOctalStyles: zero_with_o, zero_only +Style/NumericLiteralPrefix: + Exclude: + - 'lib/oxidized/output/git.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/oxidized/cli.rb' + - 'lib/oxidized/core.rb' + - 'lib/oxidized/jobs.rb' + - 'lib/oxidized/nodes.rb' + - 'lib/oxidized/worker.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/OrAssignment: + Exclude: + - 'lib/oxidized/manager.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/ParallelAssignment: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/hook/exec.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/output/gitcrypt.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: AllowSafeAssignment. +Style/ParenthesesAroundCondition: + Exclude: + - 'lib/oxidized/model/ios.rb' + - 'lib/oxidized/model/powerconnect.rb' + - 'lib/oxidized/source/http.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'lib/oxidized/config.rb' + - 'lib/oxidized/input/ssh.rb' + - 'oxidized.gemspec' + - 'spec/nodes_spec.rb' + +# Offense count: 22 +# Cop supports --auto-correct. +Style/PerlBackrefs: + Exclude: + - 'lib/oxidized/model/acos.rb' + - 'lib/oxidized/model/aos7.rb' + - 'lib/oxidized/model/ios.rb' + - 'lib/oxidized/model/junos.rb' + - 'lib/oxidized/model/powerconnect.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Exclude: + - 'lib/oxidized/manager.rb' + - 'lib/oxidized/source/csv.rb' + - 'lib/oxidized/source/http.rb' + - 'lib/oxidized/source/sql.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Proc: + Exclude: + - 'lib/oxidized/hook/githubrepo.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/manager.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/output/gitcrypt.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Style/RedundantParentheses: + Exclude: + - 'lib/oxidized/model/aricentiss.rb' + - 'lib/oxidized/model/ios.rb' + - 'lib/oxidized/model/powerconnect.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'lib/oxidized/node.rb' + - 'lib/oxidized/output/file.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/RedundantSelf: + Exclude: + - 'lib/oxidized/hook.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 29 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +Style/RescueModifier: + Exclude: + - 'bin/oxidized' + - 'extra/syslog.rb' + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 19 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'bin/oxidized' + - 'extra/rest_client.rb' + - 'extra/syslog.rb' + - 'lib/oxidized/cli.rb' + - 'lib/oxidized/config.rb' + - 'lib/oxidized/hook.rb' + - 'lib/oxidized/hook/exec.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/output/gitcrypt.rb' + - 'lib/oxidized/worker.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'lib/oxidized/model/ios.rb' + - 'lib/oxidized/output/git.rb' + - 'lib/oxidized/output/gitcrypt.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + Exclude: + - 'lib/oxidized/cli.rb' + +# Offense count: 1 +Style/StructInheritance: + Exclude: + - 'lib/oxidized/hook.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: MinSize. +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: brackets + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: respond_to, define_method +Style/SymbolProc: + Exclude: + - 'lib/oxidized/model/datacom.rb' + - 'lib/oxidized/model/hpebladesystem.rb' + - 'lib/oxidized/model/junos.rb' + - 'lib/oxidized/model/outputs.rb' + - 'lib/oxidized/nodes.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArguments: + Exclude: + - 'lib/oxidized/hook/exec.rb' + - 'lib/oxidized/output/git.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'lib/oxidized/input/input.rb' + - 'lib/oxidized/input/ssh.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'extra/syslog.rb' + - 'lib/oxidized/config.rb' + - 'lib/oxidized/input/ftp.rb' + - 'lib/oxidized/input/input.rb' + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/node/stats.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowNamedUnderscoreVariables. +Style/TrailingUnderscoreVariable: + Exclude: + - 'lib/oxidized/node.rb' + - 'lib/oxidized/output/git.rb' + - 'spec/node_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. +# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +Style/TrivialAccessors: + Exclude: + - 'lib/oxidized/cli.rb' + - 'lib/oxidized/input/ssh.rb' + - 'lib/oxidized/model/model.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/UnneededInterpolation: + Exclude: + - 'bin/oxidized' + - 'lib/oxidized/cli.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 3 + +# Offense count: 4 +# Cop supports --auto-correct. +Style/ZeroLengthPredicate: + Exclude: + - 'lib/oxidized/core.rb' + - 'lib/oxidized/input/telnet.rb' + - 'lib/oxidized/model/ciscosmb.rb' + - 'lib/oxidized/output/git.rb' + +# Offense count: 275 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 257 diff --git a/Rakefile b/Rakefile index de6ba82..6f792d5 100644 --- a/Rakefile +++ b/Rakefile @@ -4,6 +4,18 @@ require 'rake/testtask' gemspec = eval(File.read(Dir['*.gemspec'].first)) file = [gemspec.name, gemspec.version].join('-') + '.gem' +# Integrate Rubocop if available +begin + require 'rubocop/rake_task' + + RuboCop::RakeTask.new + task(:default).prerequisites << task(:rubocop) +rescue LoadError + task :rubocop do + puts 'Install rubocop to run its rake tasks' + end +end + desc 'Validate gemspec' task :gemspec do gemspec.validate diff --git a/oxidized.gemspec b/oxidized.gemspec index a8e3eb5..6019842 100644 --- a/oxidized.gemspec +++ b/oxidized.gemspec @@ -34,4 +34,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'minitest', '~> 5.8' s.add_development_dependency 'mocha', '~> 1.1' s.add_development_dependency 'git', '~> 1' + s.add_development_dependency 'rubocop', '~> 0.54' + s.add_development_dependency 'rails_best_practices', '~> 1.19' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 28eb9d4..2b49a6c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ require 'minitest/autorun' -require 'mocha/mini_test' +require 'mocha/minitest' require 'oxidized' Oxidized.mgr = Oxidized::Manager.new -- cgit v1.2.1 From 01d7f29905fd9ca712e8b640408425cf2d3ad64d Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 11 Apr 2018 19:58:30 +0200 Subject: standardize on verbose hash methods --- .rubocop_todo.yml | 11 ----------- lib/oxidized/manager.rb | 4 ++-- lib/oxidized/source/csv.rb | 2 +- lib/oxidized/source/http.rb | 2 +- lib/oxidized/source/sql.rb | 2 +- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8121015..3724d84 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1033,17 +1033,6 @@ Style/PerlBackrefs: - 'lib/oxidized/model/junos.rb' - 'lib/oxidized/model/powerconnect.rb' -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: short, verbose -Style/PreferredHashMethods: - Exclude: - - 'lib/oxidized/manager.rb' - - 'lib/oxidized/source/csv.rb' - - 'lib/oxidized/source/http.rb' - - 'lib/oxidized/source/sql.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/Proc: diff --git a/lib/oxidized/manager.rb b/lib/oxidized/manager.rb index bf28ae7..d2ef4d2 100644 --- a/lib/oxidized/manager.rb +++ b/lib/oxidized/manager.rb @@ -49,13 +49,13 @@ module Oxidized @model.merge! _model end def add_source _source - return nil if @source.key? _source + return nil if @source.has_key? _source _source = Manager.load Config::SourceDir, _source return false if _source.empty? @source.merge! _source end def add_hook _hook - return nil if @hook.key? _hook + return nil if @hook.has_key? _hook name = _hook _hook = Manager.load File.join(Config::Root, 'hook'), name _hook = Manager.load Config::HookDir, name if _hook.empty? diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index 4814bd7..b61525e 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -36,7 +36,7 @@ class CSV < Source @cfg.map.each do |key, position| keys[key.to_sym] = node_var_interpolate data[position] end - keys[:model] = map_model keys[:model] if keys.key? :model + keys[:model] = map_model keys[:model] if keys.has_key? :model # map node specific vars vars = {} diff --git a/lib/oxidized/source/http.rb b/lib/oxidized/source/http.rb index 6c12f29..56a575b 100644 --- a/lib/oxidized/source/http.rb +++ b/lib/oxidized/source/http.rb @@ -43,7 +43,7 @@ class HTTP < Source want_positions = want_position.split('.') keys[key.to_sym] = node_var_interpolate node.dig(*want_positions) end - keys[:model] = map_model keys[:model] if keys.key? :model + keys[:model] = map_model keys[:model] if keys.has_key? :model # map node specific vars vars = {} diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb index 13fc39b..ca3bcc3 100644 --- a/lib/oxidized/source/sql.rb +++ b/lib/oxidized/source/sql.rb @@ -27,7 +27,7 @@ class SQL < Source # map node parameters keys = {} @cfg.map.each { |key, sql_column| keys[key.to_sym] = node_var_interpolate node[sql_column.to_sym] } - keys[:model] = map_model keys[:model] if keys.key? :model + keys[:model] = map_model keys[:model] if keys.has_key? :model # map node specific vars vars = {} -- cgit v1.2.1 From 7cd3568c90e2aaeaa17863ba14e2af6c23b08b0c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 11 Apr 2018 20:03:41 +0200 Subject: adapt rubocop todo --- .rubocop_todo.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8121015..76e23a3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -882,21 +882,6 @@ Style/InfiniteLoop: - 'extra/syslog.rb' - 'lib/oxidized/core.rb' -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: InverseMethods, InverseBlocks. -Style/InverseMethods: - Exclude: - - 'lib/oxidized/model/aosw.rb' - - 'lib/oxidized/model/asa.rb' - - 'lib/oxidized/model/comware.rb' - - 'lib/oxidized/model/firewareos.rb' - - 'lib/oxidized/model/powerconnect.rb' - - 'lib/oxidized/model/procurve.rb' - - 'lib/oxidized/model/routeros.rb' - - 'lib/oxidized/model/vrp.rb' - - 'lib/oxidized/model/zhoneolt.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/LineEndConcatenation: -- cgit v1.2.1 From 36f31e7d053365fe9f5d6b64bae4ac485677c93c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 11 Apr 2018 21:14:56 +0200 Subject: eliminate tabs in favor of double space --- .rubocop_todo.yml | 10 - lib/oxidized/model/asyncos.rb | 88 ++++---- lib/oxidized/model/ciscosma.rb | 80 +++---- lib/oxidized/model/cumulus.rb | 2 +- lib/oxidized/output/gitcrypt.rb | 484 ++++++++++++++++++++-------------------- 5 files changed, 327 insertions(+), 337 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8121015..8167e2a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -414,16 +414,6 @@ Layout/SpaceInsideRangeLiteral: Exclude: - 'lib/oxidized/input/telnet.rb' -# Offense count: 302 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -Layout/Tab: - Exclude: - - 'lib/oxidized/model/asyncos.rb' - - 'lib/oxidized/model/ciscosma.rb' - - 'lib/oxidized/model/cumulus.rb' - - 'lib/oxidized/output/gitcrypt.rb' - # Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/oxidized/model/asyncos.rb b/lib/oxidized/model/asyncos.rb index 875690b..ac19e34 100644 --- a/lib/oxidized/model/asyncos.rb +++ b/lib/oxidized/model/asyncos.rb @@ -1,49 +1,49 @@ class AsyncOS < Oxidized::Model - # ESA prompt "(mail.example.com)> " - prompt /^\r*([(][\w. ]+[)][#>]\s+)$/ - comment '! ' - - # Select passphrase display option - expect /\[\S+\]>\s/ do |data, re| - send "3\n" - data.sub re, '' - end - - # handle paging - expect /-Press Any Key For More-+.*$/ do |data, re| - send " " - data.sub re, '' - end - - cmd 'version' do |cfg| - comment cfg - end + # ESA prompt "(mail.example.com)> " + prompt /^\r*([(][\w. ]+[)][#>]\s+)$/ + comment '! ' + + # Select passphrase display option + expect /\[\S+\]>\s/ do |data, re| + send "3\n" + data.sub re, '' + end + + # handle paging + expect /-Press Any Key For More-+.*$/ do |data, re| + send " " + data.sub re, '' + end + + cmd 'version' do |cfg| + comment cfg + end - cmd 'showconfig' do |cfg| - #Delete hour and date which change each run - #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' - # Delete select passphrase display option - cfg.gsub! /Choose the passphrase option:/, '' - cfg.gsub! /1. Mask passphrases \(Files with masked passphrases cannot be loaded using/, '' - cfg.gsub! /loadconfig command\)/, '' - cfg.gsub! /2. Encrypt passphrases/, '' - cfg.gsub! /3. Plain passphrases/, '' - cfg.gsub! /^3$/, '' - #Delete space - cfg.gsub! /\n\s{25,26}/, '' - #Delete after line - cfg.gsub! /([-\\\/,.\w><@]+)(\s{25,27})/,"\\1" - # Add a carriage return - cfg.gsub! /([-\\\/,.\w><@]+)(\s{6})([-\\\/,.\w><@]+)/,"\\1\n\\2\\3" - # Delete prompt - cfg.gsub! /^\r*([(][\w. ]+[)][#>]\s+)$/, '' - cfg + cmd 'showconfig' do |cfg| + #Delete hour and date which change each run + #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' + # Delete select passphrase display option + cfg.gsub! /Choose the passphrase option:/, '' + cfg.gsub! /1. Mask passphrases \(Files with masked passphrases cannot be loaded using/, '' + cfg.gsub! /loadconfig command\)/, '' + cfg.gsub! /2. Encrypt passphrases/, '' + cfg.gsub! /3. Plain passphrases/, '' + cfg.gsub! /^3$/, '' + #Delete space + cfg.gsub! /\n\s{25,26}/, '' + #Delete after line + cfg.gsub! /([-\\\/,.\w><@]+)(\s{25,27})/,"\\1" + # Add a carriage return + cfg.gsub! /([-\\\/,.\w><@]+)(\s{6})([-\\\/,.\w><@]+)/,"\\1\n\\2\\3" + # Delete prompt + cfg.gsub! /^\r*([(][\w. ]+[)][#>]\s+)$/, '' + cfg - end - - cfg :ssh do - pre_logout "exit" - end - + end + + cfg :ssh do + pre_logout "exit" + end + end diff --git a/lib/oxidized/model/ciscosma.rb b/lib/oxidized/model/ciscosma.rb index a52e38a..6777ad5 100644 --- a/lib/oxidized/model/ciscosma.rb +++ b/lib/oxidized/model/ciscosma.rb @@ -1,45 +1,45 @@ class CiscoSMA < Oxidized::Model - # SMA prompt "mail.example.com> " - prompt /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/ - comment '! ' - - # Select passphrase display option - expect /using loadconfig command\. \[Y\]\>/ do |data, re| - send "y\n" - data.sub re, '' - end - - # handle paging - expect /-Press Any Key For More-+.*$/ do |data, re| - send " " - data.sub re, '' - end - - cmd 'version' do |cfg| - comment cfg - end + # SMA prompt "mail.example.com> " + prompt /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/ + comment '! ' + + # Select passphrase display option + expect /using loadconfig command\. \[Y\]\>/ do |data, re| + send "y\n" + data.sub re, '' + end + + # handle paging + expect /-Press Any Key For More-+.*$/ do |data, re| + send " " + data.sub re, '' + end + + cmd 'version' do |cfg| + comment cfg + end - cmd 'showconfig' do |cfg| - #Delete hour and date which change each run - #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' - # Delete select passphrase display option - cfg.gsub! /Do you want to mask the password\? Files with masked passwords cannot be loaded/, '' - cfg.gsub! /^\s+y/, '' - # Delete space - cfg.gsub! /\n\s{25}/, '' - # Delete after line - cfg.gsub! /([\/\-,.\w><@]+)(\s{27})/,"\\1" - # Add a carriage return - cfg.gsub! /([\/\-,.\w><@]+)(\s{6,8})([\/\-,.\w><@]+)/,"\\1\n\\2\\3" - # Delete prompt - cfg.gsub! /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/, '' - cfg + cmd 'showconfig' do |cfg| + #Delete hour and date which change each run + #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' + # Delete select passphrase display option + cfg.gsub! /Do you want to mask the password\? Files with masked passwords cannot be loaded/, '' + cfg.gsub! /^\s+y/, '' + # Delete space + cfg.gsub! /\n\s{25}/, '' + # Delete after line + cfg.gsub! /([\/\-,.\w><@]+)(\s{27})/,"\\1" + # Add a carriage return + cfg.gsub! /([\/\-,.\w><@]+)(\s{6,8})([\/\-,.\w><@]+)/,"\\1\n\\2\\3" + # Delete prompt + cfg.gsub! /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/, '' + cfg - end - - cfg :ssh do - pre_logout "exit" - end - + end + + cfg :ssh do + pre_logout "exit" + end + end diff --git a/lib/oxidized/model/cumulus.rb b/lib/oxidized/model/cumulus.rb index 20acb8a..09f3955 100644 --- a/lib/oxidized/model/cumulus.rb +++ b/lib/oxidized/model/cumulus.rb @@ -68,7 +68,7 @@ class Cumulus < Oxidized::Model cfg += add_comment 'TRAFFIC' cfg += cmd 'cat /etc/cumulus/datapath/traffic.conf' - + cfg += add_comment 'ACL' cfg += cmd 'iptables -L -n' diff --git a/lib/oxidized/output/gitcrypt.rb b/lib/oxidized/output/gitcrypt.rb index b0d80f2..0567458 100644 --- a/lib/oxidized/output/gitcrypt.rb +++ b/lib/oxidized/output/gitcrypt.rb @@ -1,244 +1,244 @@ module Oxidized - class GitCrypt < Output - class GitCryptError < OxidizedError; end - begin - require 'git' - rescue LoadError - raise OxidizedError, 'git not found: sudo gem install ruby-git' - end - - attr_reader :commitref - - def initialize - @cfg = Oxidized.config.output.gitcrypt - @gitcrypt_cmd = "/usr/bin/git-crypt" - @gitcrypt_init = @gitcrypt_cmd + " init" - @gitcrypt_unlock = @gitcrypt_cmd + " unlock" - @gitcrypt_lock = @gitcrypt_cmd + " lock" - @gitcrypt_adduser = @gitcrypt_cmd + " add-gpg-user --trusted " - end - - def setup - if @cfg.empty? - Oxidized.asetus.user.output.gitcrypt.user = 'Oxidized' - Oxidized.asetus.user.output.gitcrypt.email = 'o@example.com' - Oxidized.asetus.user.output.gitcrypt.repo = File.join(Config::Root, 'oxidized.git') - Oxidized.asetus.save :user - raise NoConfig, 'no output git config, edit ~/.config/oxidized/config' - end - - if @cfg.repo.respond_to?(:each) - @cfg.repo.each do |group, repo| - @cfg.repo["#{group}="] = File.expand_path repo - end - else - @cfg.repo = File.expand_path @cfg.repo - end - end - - def crypt_init repo - repo.chdir do - system(@gitcrypt_init) - @cfg.users.each do |user| - system("#{@gitcrypt_adduser} #{user}") - end - File.write(".gitattributes", "* filter=git-crypt diff=git-crypt\n.gitattributes !filter !diff") - repo.add(".gitattributes") - repo.commit("Initial commit: crypt all config files") - end - end - - def lock repo - repo.chdir do - system(@gitcrypt_lock) - end - end - - def unlock repo - repo.chdir do - system(@gitcrypt_unlock) - end - end - - def store file, outputs, opt={} - @msg = opt[:msg] - @user = (opt[:user] or @cfg.user) - @email = (opt[:email] or @cfg.email) - @opt = opt - @commitref = nil - repo = @cfg.repo - - outputs.types.each do |type| - type_cfg = '' - type_repo = File.join(File.dirname(repo), type + '.git') - outputs.type(type).each do |output| - (type_cfg << output; next) if not output.name - type_file = file + '--' + output.name - if @cfg.type_as_directory? - type_file = type + '/' + type_file - type_repo = repo - end - update type_repo, type_file, output - end - update type_repo, file, type_cfg - end - - update repo, file, outputs.to_cfg - end - - - def fetch node, group - begin - repo, path = yield_repo_and_path(node, group) - repo = Git.open repo - unlock repo - index = repo.index - # Empty repo ? - empty = File.exists? index.path - if empty - raise 'Empty git repo' - else - File.read path - end - lock repo - rescue - 'node not found' - end - end - - # give a hash of all oid revision for the given node, and the date of the commit - def version node, group - begin - repo, path = yield_repo_and_path(node, group) - - repo = Git.open repo - unlock repo - walker = repo.log.path(path) - i = -1 - tab = [] - walker.each do |commit| - hash = {} - hash[:date] = commit.date.to_s - hash[:oid] = commit.objectish - hash[:author] = commit.author - hash[:message] = commit.message - tab[i += 1] = hash - end - walker.reset - tab - rescue - 'node not found' - end - end - - #give the blob of a specific revision - def get_version node, group, oid - begin - repo, path = yield_repo_and_path(node, group) - repo = Git.open repo - unlock repo - repo.gtree(oid).files[path].contents - rescue - 'version not found' - ensure - lock repo - end - end - - #give a hash with the patch of a diff between 2 revision and the stats (added and deleted lines) - def get_diff node, group, oid1, oid2 - begin - diff_commits = nil - repo, path = yield_repo_and_path(node, group) - repo = Git.open repo - unlock repo - commit = repo.gcommit(oid1) - - if oid2 - commit_old = repo.gcommit(oid2) - diff = repo.diff(commit_old, commit) - stats = [diff.stats[:files][node.name][:insertions], diff.stats[:files][node.name][:deletions]] - diff.each do |patch| - if /#{node.name}\s+/.match(patch.patch.to_s.lines.first) - diff_commits = {:patch => patch.patch.to_s, :stat => stats} - break - end - end - else - stat = commit.parents[0].diff(commit).stats - stat = [stat[:files][node.name][:insertions],stat[:files][node.name][:deletions]] - patch = commit.parents[0].diff(commit).patch - diff_commits = {:patch => patch, :stat => stat} - end - lock repo - diff_commits - rescue - 'no diffs' - ensure - lock repo - end - end - - private - - def yield_repo_and_path(node, group) - repo, path = node.repo, node.name - - if group and @cfg.single_repo? - path = "#{group}/#{node.name}" - end - - [repo, path] - end - - def update repo, file, data - return if data.empty? - - if @opt[:group] - if @cfg.single_repo? - file = File.join @opt[:group], file - else - repo = if repo.is_a?(::String) - File.join File.dirname(repo), @opt[:group] + '.git' - else - repo[@opt[:group]] - end - end - end - - begin - update_repo repo, file, data, @msg, @user, @email - rescue Git::GitExecuteError, ArgumentError => open_error - Oxidized.logger.debug "open_error #{open_error} #{file}" - begin - grepo = Git.init repo - crypt_init grepo - rescue => create_error - raise GitCryptError, "first '#{open_error.message}' was raised while opening git repo, then '#{create_error.message}' was while trying to create git repo" - end - retry - end - end - - def update_repo repo, file, data, msg, user, email - grepo = Git.open repo - grepo.config('user.name', user) - grepo.config('user.email', email) - grepo.chdir do - unlock grepo - File.write(file, data) - grepo.add(file) - if grepo.status[file].nil? - grepo.commit(msg) - @commitref = grepo.log(1).first.objectish - true - elsif !grepo.status[file].type.nil? - grepo.commit(msg) - @commitref = grepo.log(1).first.objectish - true - end - lock grepo - end - end - end + class GitCrypt < Output + class GitCryptError < OxidizedError; end + begin + require 'git' + rescue LoadError + raise OxidizedError, 'git not found: sudo gem install ruby-git' + end + + attr_reader :commitref + + def initialize + @cfg = Oxidized.config.output.gitcrypt + @gitcrypt_cmd = "/usr/bin/git-crypt" + @gitcrypt_init = @gitcrypt_cmd + " init" + @gitcrypt_unlock = @gitcrypt_cmd + " unlock" + @gitcrypt_lock = @gitcrypt_cmd + " lock" + @gitcrypt_adduser = @gitcrypt_cmd + " add-gpg-user --trusted " + end + + def setup + if @cfg.empty? + Oxidized.asetus.user.output.gitcrypt.user = 'Oxidized' + Oxidized.asetus.user.output.gitcrypt.email = 'o@example.com' + Oxidized.asetus.user.output.gitcrypt.repo = File.join(Config::Root, 'oxidized.git') + Oxidized.asetus.save :user + raise NoConfig, 'no output git config, edit ~/.config/oxidized/config' + end + + if @cfg.repo.respond_to?(:each) + @cfg.repo.each do |group, repo| + @cfg.repo["#{group}="] = File.expand_path repo + end + else + @cfg.repo = File.expand_path @cfg.repo + end + end + + def crypt_init repo + repo.chdir do + system(@gitcrypt_init) + @cfg.users.each do |user| + system("#{@gitcrypt_adduser} #{user}") + end + File.write(".gitattributes", "* filter=git-crypt diff=git-crypt\n.gitattributes !filter !diff") + repo.add(".gitattributes") + repo.commit("Initial commit: crypt all config files") + end + end + + def lock repo + repo.chdir do + system(@gitcrypt_lock) + end + end + + def unlock repo + repo.chdir do + system(@gitcrypt_unlock) + end + end + + def store file, outputs, opt={} + @msg = opt[:msg] + @user = (opt[:user] or @cfg.user) + @email = (opt[:email] or @cfg.email) + @opt = opt + @commitref = nil + repo = @cfg.repo + + outputs.types.each do |type| + type_cfg = '' + type_repo = File.join(File.dirname(repo), type + '.git') + outputs.type(type).each do |output| + (type_cfg << output; next) if not output.name + type_file = file + '--' + output.name + if @cfg.type_as_directory? + type_file = type + '/' + type_file + type_repo = repo + end + update type_repo, type_file, output + end + update type_repo, file, type_cfg + end + + update repo, file, outputs.to_cfg + end + + + def fetch node, group + begin + repo, path = yield_repo_and_path(node, group) + repo = Git.open repo + unlock repo + index = repo.index + # Empty repo ? + empty = File.exists? index.path + if empty + raise 'Empty git repo' + else + File.read path + end + lock repo + rescue + 'node not found' + end + end + + # give a hash of all oid revision for the given node, and the date of the commit + def version node, group + begin + repo, path = yield_repo_and_path(node, group) + + repo = Git.open repo + unlock repo + walker = repo.log.path(path) + i = -1 + tab = [] + walker.each do |commit| + hash = {} + hash[:date] = commit.date.to_s + hash[:oid] = commit.objectish + hash[:author] = commit.author + hash[:message] = commit.message + tab[i += 1] = hash + end + walker.reset + tab + rescue + 'node not found' + end + end + + #give the blob of a specific revision + def get_version node, group, oid + begin + repo, path = yield_repo_and_path(node, group) + repo = Git.open repo + unlock repo + repo.gtree(oid).files[path].contents + rescue + 'version not found' + ensure + lock repo + end + end + + #give a hash with the patch of a diff between 2 revision and the stats (added and deleted lines) + def get_diff node, group, oid1, oid2 + begin + diff_commits = nil + repo, path = yield_repo_and_path(node, group) + repo = Git.open repo + unlock repo + commit = repo.gcommit(oid1) + + if oid2 + commit_old = repo.gcommit(oid2) + diff = repo.diff(commit_old, commit) + stats = [diff.stats[:files][node.name][:insertions], diff.stats[:files][node.name][:deletions]] + diff.each do |patch| + if /#{node.name}\s+/.match(patch.patch.to_s.lines.first) + diff_commits = {:patch => patch.patch.to_s, :stat => stats} + break + end + end + else + stat = commit.parents[0].diff(commit).stats + stat = [stat[:files][node.name][:insertions],stat[:files][node.name][:deletions]] + patch = commit.parents[0].diff(commit).patch + diff_commits = {:patch => patch, :stat => stat} + end + lock repo + diff_commits + rescue + 'no diffs' + ensure + lock repo + end + end + + private + + def yield_repo_and_path(node, group) + repo, path = node.repo, node.name + + if group and @cfg.single_repo? + path = "#{group}/#{node.name}" + end + + [repo, path] + end + + def update repo, file, data + return if data.empty? + + if @opt[:group] + if @cfg.single_repo? + file = File.join @opt[:group], file + else + repo = if repo.is_a?(::String) + File.join File.dirname(repo), @opt[:group] + '.git' + else + repo[@opt[:group]] + end + end + end + + begin + update_repo repo, file, data, @msg, @user, @email + rescue Git::GitExecuteError, ArgumentError => open_error + Oxidized.logger.debug "open_error #{open_error} #{file}" + begin + grepo = Git.init repo + crypt_init grepo + rescue => create_error + raise GitCryptError, "first '#{open_error.message}' was raised while opening git repo, then '#{create_error.message}' was while trying to create git repo" + end + retry + end + end + + def update_repo repo, file, data, msg, user, email + grepo = Git.open repo + grepo.config('user.name', user) + grepo.config('user.email', email) + grepo.chdir do + unlock grepo + File.write(file, data) + grepo.add(file) + if grepo.status[file].nil? + grepo.commit(msg) + @commitref = grepo.log(1).first.objectish + true + elsif !grepo.status[file].type.nil? + grepo.commit(msg) + @commitref = grepo.log(1).first.objectish + true + end + lock grepo + end + end + end end -- cgit v1.2.1 From cfbc50afe8a7c1e182fb6b0b4a8dbafdd33c5ce2 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 11 Apr 2018 21:41:04 +0200 Subject: ensure asetus is initialized regardless of test execution order --- spec/cli_spec.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index eb9872e..bf6058a 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -2,8 +2,14 @@ require 'spec_helper' require 'oxidized/cli' describe Oxidized::CLI do - before { @original = ARGV } - after { ARGV.replace @original } + before(:each) do + @original = ARGV + Oxidized.asetus = Asetus.new + end + + after(:each) do + ARGV.replace @original + end %w[-v --version].each do |option| describe option do -- cgit v1.2.1 From cc5c846b3b88cafd8c01c645e6ada3bab714ae91 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sun, 15 Apr 2018 13:08:53 +0200 Subject: restructure xmppdiff.rb to comply with rubocop --- .rubocop_todo.yml | 12 ------ lib/oxidized/hook/xmppdiff.rb | 86 +++++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 56 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8121015..0ff8dce 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -94,14 +94,6 @@ Layout/CommentIndentation: - 'lib/oxidized/model/planet.rb' - 'lib/oxidized/output/http.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. -# SupportedStylesAlignWith: start_of_line, def -Layout/DefEndAlignment: - Exclude: - - 'lib/oxidized/hook/xmppdiff.rb' - # Offense count: 3 # Cop supports --auto-correct. Layout/ElseAlignment: @@ -504,7 +496,6 @@ Lint/ShadowingOuterLocalVariable: Lint/StringConversionInInterpolation: Exclude: - 'lib/oxidized/hook/slackdiff.rb' - - 'lib/oxidized/hook/xmppdiff.rb' # Offense count: 10 Lint/UnderscorePrefixedVariableName: @@ -716,7 +707,6 @@ Style/AsciiComments: # IgnoredMethods: lambda, proc, it Style/BlockDelimiters: Exclude: - - 'lib/oxidized/hook/xmppdiff.rb' - 'lib/oxidized/model/aricentiss.rb' - 'lib/oxidized/model/hatteras.rb' @@ -768,7 +758,6 @@ Style/ClassVars: # Cop supports --auto-correct. Style/ColonMethodCall: Exclude: - - 'lib/oxidized/hook/xmppdiff.rb' - 'lib/oxidized/input/ssh.rb' - 'lib/oxidized/input/telnet.rb' @@ -841,7 +830,6 @@ Style/GuardClause: Exclude: - 'lib/oxidized/cli.rb' - 'lib/oxidized/hook/slackdiff.rb' - - 'lib/oxidized/hook/xmppdiff.rb' - 'lib/oxidized/input/cli.rb' - 'lib/oxidized/jobs.rb' - 'lib/oxidized/nodes.rb' diff --git a/lib/oxidized/hook/xmppdiff.rb b/lib/oxidized/hook/xmppdiff.rb index 396d1b3..52cc0e0 100644 --- a/lib/oxidized/hook/xmppdiff.rb +++ b/lib/oxidized/hook/xmppdiff.rb @@ -7,54 +7,52 @@ class XMPPDiff < Oxidized::Hook raise KeyError, 'hook.password is required' unless cfg.has_key?('password') raise KeyError, 'hook.channel is required' unless cfg.has_key?('channel') raise KeyError, 'hook.nick is required' unless cfg.has_key?('nick') - end + end def run_hook(ctx) - if ctx.node - if ctx.event.to_s == "post_store" - begin - Timeout::timeout(15) do - gitoutput = ctx.node.output.new - diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil - - interesting = diff[:patch].lines.to_a[4..-1].any? { |line| - ["+", "-"].include?(line[0]) and not ["#", "!"].include?(line[1]) - } - interesting &&= diff[:patch].lines.to_a[5..-1].any? { |line| line[0] == '-' } - interesting &&= diff[:patch].lines.to_a[5..-1].any? { |line| line[0] == '+' } - - if interesting - log "Connecting to XMPP" - client = Jabber::Client.new(Jabber::JID.new(cfg.jid)) - client.connect - sleep 1 - client.auth(cfg.password) - sleep 1 - - log "Connected" - - m = Jabber::MUC::SimpleMUCClient.new(client) - m.join(cfg.channel + "/" + cfg.nick) - - log "Joined" - - title = "#{ctx.node.name.to_s} #{ctx.node.group.to_s} #{ctx.node.model.class.name.to_s.downcase}" - log "Posting diff as snippet to #{cfg.channel}" - - m.say(title + "\n\n" + diff[:patch].lines.to_a[4..-1].join) - - sleep 1 - - client.close - - log "Finished" - - end - end - rescue Timeout::Error - log "timed out" + return unless ctx.node + return unless ctx.event.to_s == "post_store" + begin + Timeout.timeout(15) do + gitoutput = ctx.node.output.new + diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil + + interesting = diff[:patch].lines.to_a[4..-1].any? do |line| + ["+", "-"].include?(line[0]) and not ["#", "!"].include?(line[1]) + end + interesting &&= diff[:patch].lines.to_a[5..-1].any? { |line| line[0] == '-' } + interesting &&= diff[:patch].lines.to_a[5..-1].any? { |line| line[0] == '+' } + + if interesting + log "Connecting to XMPP" + client = Jabber::Client.new(Jabber::JID.new(cfg.jid)) + client.connect + sleep 1 + client.auth(cfg.password) + sleep 1 + + log "Connected" + + m = Jabber::MUC::SimpleMUCClient.new(client) + m.join(cfg.channel + "/" + cfg.nick) + + log "Joined" + + title = "#{ctx.node.name} #{ctx.node.group} #{ctx.node.model.class.name.to_s.downcase}" + log "Posting diff as snippet to #{cfg.channel}" + + m.say(title + "\n\n" + diff[:patch].lines.to_a[4..-1].join) + + sleep 1 + + client.close + + log "Finished" + end end + rescue Timeout::Error + log "timed out" end end end -- cgit v1.2.1 From 140954f78e50bed1aaf3f8fd42f849e3892e55c0 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sun, 15 Apr 2018 13:24:05 +0200 Subject: restructure slackdiff.rb to comply with rubocop --- .rubocop_todo.yml | 11 ------ lib/oxidized/hook/slackdiff.rb | 77 ++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 51 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8121015..93a9271 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -269,7 +269,6 @@ Layout/MultilineBlockLayout: # SupportedStyles: symmetrical, new_line, same_line Layout/MultilineMethodCallBraceLayout: Exclude: - - 'lib/oxidized/hook/slackdiff.rb' - 'lib/oxidized/output/git.rb' # Offense count: 14 @@ -387,7 +386,6 @@ Layout/SpaceInsideBlockBraces: # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideHashLiteralBraces: Exclude: - - 'lib/oxidized/hook/slackdiff.rb' - 'lib/oxidized/output/git.rb' - 'lib/oxidized/output/gitcrypt.rb' - 'lib/oxidized/output/http.rb' @@ -503,7 +501,6 @@ Lint/ShadowingOuterLocalVariable: # Cop supports --auto-correct. Lint/StringConversionInInterpolation: Exclude: - - 'lib/oxidized/hook/slackdiff.rb' - 'lib/oxidized/hook/xmppdiff.rb' # Offense count: 10 @@ -701,12 +698,6 @@ Style/Alias: Style/AndOr: Enabled: false -# Offense count: 1 -# Configuration parameters: AllowedChars. -Style/AsciiComments: - Exclude: - - 'lib/oxidized/hook/slackdiff.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. @@ -823,7 +814,6 @@ Style/ExpandPathArguments: # SupportedStyles: format, sprintf, percent Style/FormatString: Exclude: - - 'lib/oxidized/hook/slackdiff.rb' - 'lib/oxidized/node.rb' - 'lib/oxidized/nodes.rb' @@ -840,7 +830,6 @@ Style/FormatStringToken: Style/GuardClause: Exclude: - 'lib/oxidized/cli.rb' - - 'lib/oxidized/hook/slackdiff.rb' - 'lib/oxidized/hook/xmppdiff.rb' - 'lib/oxidized/input/cli.rb' - 'lib/oxidized/jobs.rb' diff --git a/lib/oxidized/hook/slackdiff.rb b/lib/oxidized/hook/slackdiff.rb index 7cd4465..e271d5f 100644 --- a/lib/oxidized/hook/slackdiff.rb +++ b/lib/oxidized/hook/slackdiff.rb @@ -10,47 +10,44 @@ class SlackDiff < Oxidized::Hook end def run_hook(ctx) - if ctx.node - if ctx.event.to_s == "post_store" - log "Connecting to slack" - Slack.configure do |config| - config.token = cfg.token - config.proxy = cfg.proxy if cfg.has_key?('proxy') - end - client = Slack::Client.new - client.auth_test - 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 - unless diff == "no diffs" - title = "#{ctx.node.name.to_s} #{ctx.node.group.to_s} #{ctx.node.model.class.name.to_s.downcase}" - log "Posting diff as snippet to #{cfg.channel}" - client.files_upload(channels: cfg.channel, as_user: true, - content: diff[:patch].lines.to_a[4..-1].join, - filetype: "diff", - title: title, - filename: "change" - ) - end - 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.channel}" - client.chat_postMessage(channel: cfg.channel, text: msg, as_user: true) - end - log "Finished" + return unless ctx.node + return unless ctx.event.to_s == "post_store" + log "Connecting to slack" + Slack.configure do |config| + config.token = cfg.token + config.proxy = cfg.proxy if cfg.has_key?('proxy') + end + client = Slack::Client.new + client.auth_test + 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 + unless diff == "no diffs" + title = "#{ctx.node.name} #{ctx.node.group} #{ctx.node.model.class.name.to_s.downcase}" + log "Posting diff as snippet to #{cfg.channel}" + client.files_upload(channels: cfg.channel, as_user: true, + content: diff[:patch].lines.to_a[4..-1].join, + filetype: "diff", + title: title, + filename: "change") end end + # message custom formatted - optional + if cfg.has_key?('message') == true + log cfg.message + msg = format(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.channel}" + client.chat_postMessage(channel: cfg.channel, text: msg, as_user: true) + end + log "Finished" end end -- cgit v1.2.1 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 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.1 From 1b66348be97d4603566a262756d6ad5a2d21bd58 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Mon, 16 Apr 2018 21:03:35 +0200 Subject: restructure awssns.rb to comply with rubocop --- .rubocop_todo.yml | 2 -- lib/oxidized/hook/awssns.rb | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 81776bd..e71f1ba 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -216,7 +216,6 @@ Layout/FirstParameterIndentation: # SupportedStyles: special_inside_parentheses, consistent, align_braces Layout/IndentHash: Exclude: - - 'lib/oxidized/hook/awssns.rb' - 'lib/oxidized/hook/githubrepo.rb' - 'lib/oxidized/input/ssh.rb' - 'lib/oxidized/output/http.rb' @@ -692,7 +691,6 @@ Style/BlockDelimiters: # SupportedStyles: braces, no_braces, context_dependent Style/BracesAroundHashParameters: Exclude: - - 'lib/oxidized/hook/awssns.rb' - 'lib/oxidized/hook/githubrepo.rb' - 'lib/oxidized/input/telnet.rb' - 'lib/oxidized/model/procurve.rb' diff --git a/lib/oxidized/hook/awssns.rb b/lib/oxidized/hook/awssns.rb index dbc2d47..82c118e 100644 --- a/lib/oxidized/hook/awssns.rb +++ b/lib/oxidized/hook/awssns.rb @@ -19,9 +19,9 @@ class AwsSns < Oxidized::Hook :node => ctx.node.name.to_s ) end - topic.publish({ + topic.publish( message: message.to_json - }) + ) end end -- cgit v1.2.1 From b846b591289c721ac831fa2ec8fe4f248ab0bf17 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Mon, 16 Apr 2018 23:34:32 +0200 Subject: remove mention of ruby 1.9.3 from CentOS instructions in favor of 2.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ebe3d43..9e52792 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ gem install oxidized-script oxidized-web # if you don't install oxidized-web, ma ### CentOS, Oracle Linux, Red Hat Linux -On CentOS 6 / RHEL 6, install Ruby greater than 1.9.3 (for Ruby 2.1.2 installation instructions see [Installing Ruby 2.1.2 using RVM](#installing-ruby-212-using-rvm)), then install Oxidized dependencies +On CentOS 6 / RHEL 6, install Ruby 2.0 or greater (for Ruby 2.1.2 installation instructions see [Installing Ruby 2.1.2 using RVM](#installing-ruby-212-using-rvm)), then install Oxidized dependencies ```shell yum install cmake sqlite-devel openssl-devel libssh2-devel -- cgit v1.2.1 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 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.1 From 9ed50b5de4be4ae49c381fd539b9184631958d5b Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Thu, 19 Apr 2018 22:42:44 +0200 Subject: tidy up tests with rubocop --- .rubocop_todo.yml | 28 ---------------------------- spec/githubrepo_spec.rb | 31 +++++++++++++++---------------- spec/input/ssh_spec.rb | 15 +++++++-------- spec/node_spec.rb | 7 +++---- spec/nodes_spec.rb | 4 ++-- 5 files changed, 27 insertions(+), 58 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 81776bd..55642fc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -29,16 +29,6 @@ Layout/AccessModifierIndentation: Exclude: - 'lib/oxidized/output/gitcrypt.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/AlignHash: - Exclude: - - 'spec/input/ssh_spec.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -150,8 +140,6 @@ Layout/EmptyLinesAroundBlockBody: - 'lib/oxidized/model/audiocodes.rb' - 'lib/oxidized/model/ciscosma.rb' - 'lib/oxidized/model/tplink.rb' - - 'spec/input/ssh_spec.rb' - - 'spec/node_spec.rb' # Offense count: 158 # Cop supports --auto-correct. @@ -220,8 +208,6 @@ Layout/IndentHash: - 'lib/oxidized/hook/githubrepo.rb' - 'lib/oxidized/input/ssh.rb' - 'lib/oxidized/output/http.rb' - - 'spec/githubrepo_spec.rb' - - 'spec/node_spec.rb' # Offense count: 21 # Cop supports --auto-correct. @@ -381,8 +367,6 @@ Layout/SpaceInsideHashLiteralBraces: - 'lib/oxidized/output/git.rb' - 'lib/oxidized/output/gitcrypt.rb' - 'lib/oxidized/output/http.rb' - - 'spec/githubrepo_spec.rb' - - 'spec/input/ssh_spec.rb' # Offense count: 9 # Cop supports --auto-correct. @@ -697,9 +681,6 @@ Style/BracesAroundHashParameters: - 'lib/oxidized/input/telnet.rb' - 'lib/oxidized/model/procurve.rb' - 'lib/oxidized/output/http.rb' - - 'spec/githubrepo_spec.rb' - - 'spec/input/ssh_spec.rb' - - 'spec/node_spec.rb' # Offense count: 3 Style/CaseEquality: @@ -850,13 +831,6 @@ Style/LineEndConcatenation: Exclude: - 'lib/oxidized/hook.rb' -# Offense count: 9 -# Cop supports --auto-correct. -Style/MethodCallWithoutArgsParentheses: - Exclude: - - 'spec/githubrepo_spec.rb' - - 'spec/input/ssh_spec.rb' - # Offense count: 131 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -968,7 +942,6 @@ Style/PercentLiteralDelimiters: - 'lib/oxidized/config.rb' - 'lib/oxidized/input/ssh.rb' - 'oxidized.gemspec' - - 'spec/nodes_spec.rb' # Offense count: 22 # Cop supports --auto-correct. @@ -1134,7 +1107,6 @@ Style/TrailingUnderscoreVariable: Exclude: - 'lib/oxidized/node.rb' - 'lib/oxidized/output/git.rb' - - 'spec/node_spec.rb' # Offense count: 3 # Cop supports --auto-correct. diff --git a/spec/githubrepo_spec.rb b/spec/githubrepo_spec.rb index e676534..baa9a14 100644 --- a/spec/githubrepo_spec.rb +++ b/spec/githubrepo_spec.rb @@ -3,11 +3,11 @@ require 'rugged' require 'oxidized/hook/githubrepo' describe GithubRepo do - let(:credentials) { mock() } - let(:remote) { mock() } - let(:remotes) { mock() } - let(:repo_head) { mock() } - let(:repo) { mock() } + let(:credentials) { mock } + let(:remote) { mock } + let(:remotes) { mock } + let(:repo_head) { mock } + let(:repo) { mock } let(:gr) { GithubRepo.new } before do @@ -44,15 +44,15 @@ describe GithubRepo do gr.fetch_and_merge_remote(repo).must_equal nil end describe "when there is update considering conflicts" do - let(:merge_index) { mock() } - let(:their_branch) { mock() } + let(:merge_index) { mock } + let(:their_branch) { mock } before(:each) do - repo.expects(:fetch).with('origin', ['refs/heads/master'], credentials: credentials).returns({total_deltas: 1}) + repo.expects(:fetch).with('origin', ['refs/heads/master'], credentials: credentials).returns(total_deltas: 1) their_branch.expects(:target_id).returns(1) repo_head.expects(:target_id).returns(2) repo.expects(:merge_commits).with(2, 1).returns(merge_index) - repo.expects(:branches).returns({"origin/master" => their_branch}) + repo.expects(:branches).returns("origin/master" => their_branch) end it "should not try merging when there's conflict" do @@ -70,12 +70,11 @@ describe GithubRepo do repo_head.expects(:target).returns("our_target") merge_index.expects(:write_tree).with(repo).returns("tree") merge_index.expects(:conflicts?).returns(false) - Rugged::Commit.expects(:create).with(repo, { - parents: ["our_target", "their_target"], - tree: "tree", - message: "Merge remote-tracking branch 'origin/master'", - update_ref: "HEAD" - }).returns(1) + Rugged::Commit.expects(:create).with(repo, + parents: ["our_target", "their_target"], + tree: "tree", + message: "Merge remote-tracking branch 'origin/master'", + update_ref: "HEAD").returns(1) gr.fetch_and_merge_remote(repo).must_equal 1 end end @@ -101,7 +100,7 @@ describe GithubRepo do Oxidized.config.output.git.repo = '/foo.git' remote.expects(:url).returns('https://github.com/username/foo.git') remote.expects(:push).with(['refs/heads/master'], credentials: credentials).returns(true) - repo.expects(:remotes).returns({'origin' => remote}) + repo.expects(:remotes).returns('origin' => remote) Rugged::Repository.expects(:new).with('/foo.git').returns(repo) end diff --git a/spec/input/ssh_spec.rb b/spec/input/ssh_spec.rb index 7be9139..2d1f5ce 100644 --- a/spec/input/ssh_spec.rb +++ b/spec/input/ssh_spec.rb @@ -14,23 +14,22 @@ describe Oxidized::SSH do model: 'junos', username: 'alma', password: 'armud', - vars: {ssh_proxy: 'test.com'}) - + vars: { ssh_proxy: 'test.com' }) end describe "#connect" do it "should use proxy command when proxy host given" do ssh = Oxidized::SSH.new - model = mock() - model.expects(:cfg).returns({'ssh' => []}) + model = mock + model.expects(:cfg).returns('ssh' => []) @node.expects(:model).returns(model).at_least_once - proxy = mock() + proxy = mock Net::SSH::Proxy::Command.expects(:new).with("ssh test.com -W %h:%p").returns(proxy) - Net::SSH.expects(:start).with('93.184.216.34', 'alma', {:port => 22, :password => 'armud', :timeout => Oxidized.config.timeout, - :paranoid => Oxidized.config.input.ssh.secure, :auth_methods => ['none', 'publickey', 'password', 'keyboard-interactive'], - :number_of_password_prompts => 0, :proxy => proxy}) + Net::SSH.expects(:start).with('93.184.216.34', 'alma', :port => 22, :password => 'armud', :timeout => Oxidized.config.timeout, + :paranoid => Oxidized.config.input.ssh.secure, :auth_methods => ['none', 'publickey', 'password', 'keyboard-interactive'], + :number_of_password_prompts => 0, :proxy => proxy) ssh.instance_variable_set("@exec", true) ssh.connect(@node) diff --git a/spec/node_spec.rb b/spec/node_spec.rb index 829e05a..f769751 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -14,7 +14,6 @@ describe Oxidized::Node do username: 'alma', password: 'armud', prompt: 'test_prompt') - end describe '#new' do @@ -39,7 +38,7 @@ describe Oxidized::Node do it 'should fetch the configuration' do stub_oxidized_ssh - status, _ = @node.run + status, = @node.run status.must_equal :success end end @@ -52,9 +51,9 @@ describe Oxidized::Node do let(:group) { nil } let(:node) do - Oxidized::Node.new({ + Oxidized::Node.new( ip: '127.0.0.1', group: group, model: 'junos' - }) + ) end it 'when there are no groups' do diff --git a/spec/nodes_spec.rb b/spec/nodes_spec.rb index 6fa4b41..a801107 100644 --- a/spec/nodes_spec.rb +++ b/spec/nodes_spec.rb @@ -17,8 +17,8 @@ describe Oxidized::Nodes do Oxidized::Node.any_instance.stubs(:resolve_repo) Oxidized::Node.any_instance.stubs(:resolve_output) - @nodes_org = %w(ltt-pe1.hel kes2-rr1.tku tor-peer1.oul - hal-p2.tre sav-gr1-sw1.kuo psl-sec-pe1.hel).map { |e| Oxidized::Node.new(opts.merge(name: e)) } + @nodes_org = %w[ltt-pe1.hel kes2-rr1.tku tor-peer1.oul + hal-p2.tre sav-gr1-sw1.kuo psl-sec-pe1.hel].map { |e| Oxidized::Node.new(opts.merge(name: e)) } @node = @nodes_org.delete_at(0) @nodes = Oxidized::Nodes.new(nodes: @nodes_org.dup) end -- cgit v1.2.1 From a38057c0a6cae070748187b8c15f1ed26441a47e Mon Sep 17 00:00:00 2001 From: Yuri Zubov Date: Fri, 20 Apr 2018 12:17:29 +0300 Subject: remove .ruby-version & add many ruby-version in .travis.yml --- .gitignore | 2 ++ .ruby-version | 1 - .travis.yml | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) delete mode 100644 .ruby-version diff --git a/.gitignore b/.gitignore index f6a2251..3fd09d4 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ /tmp/ .idea/ Gemfile.lock +.ruby-version +.sass-cache/ # Used by dotenv library to load environment variables. # .env diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index ebf14b4..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.1.8 diff --git a/.travis.yml b/.travis.yml index 8f97b30..db2925a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,11 @@ language: ruby sudo: false cache: bundler +before_install: + - gem install bundler rvm: - - 2.1.6 + - 2.1 + - 2.2 + - 2.3 + - 2.4 + - 2.5 -- cgit v1.2.1 From aff10437b94e83e29ad16fbb3c17932a7a1488b3 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 20 Apr 2018 14:39:57 +0200 Subject: bump rubocop to 0.55 and regenerate .rubocop_todo.yml --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 79 +++++++++++++++++++++++++++++-------------------------- oxidized.gemspec | 2 +- 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ad1ca31..bc013cd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,6 +14,9 @@ LineLength: Style/PreferredHashMethods: EnforcedStyle: verbose +Style/Not: + Enabled: false + AllCops: Exclude: - 'vendor/**/*' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a56def7..b91409a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-04-11 13:02:45 +0200 using RuboCop version 0.54.0. +# on 2018-04-20 14:46:50 +0200 using RuboCop version 0.55.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -21,14 +21,6 @@ Gemspec/RequiredRubyVersion: Exclude: - 'oxidized.gemspec' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: outdent, indent -Layout/AccessModifierIndentation: - Exclude: - - 'lib/oxidized/output/gitcrypt.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -128,7 +120,7 @@ Layout/EmptyLines: - 'lib/oxidized/output/git.rb' - 'lib/oxidized/output/gitcrypt.rb' -# Offense count: 9 +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines @@ -141,7 +133,7 @@ Layout/EmptyLinesAroundBlockBody: - 'lib/oxidized/model/ciscosma.rb' - 'lib/oxidized/model/tplink.rb' -# Offense count: 158 +# Offense count: 159 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only @@ -198,7 +190,7 @@ Layout/FirstParameterIndentation: Exclude: - 'lib/oxidized/output/http.rb' -# Offense count: 11 +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces @@ -223,13 +215,13 @@ Layout/IndentationConsistency: - 'lib/oxidized/model/slxos.rb' - 'lib/oxidized/output/git.rb' -# Offense count: 116 +# Offense count: 47 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. Layout/IndentationWidth: Enabled: false -# Offense count: 109 +# Offense count: 108 # Cop supports --auto-correct. Layout/LeadingCommentSpace: Enabled: false @@ -240,7 +232,7 @@ Layout/MultilineBlockLayout: Exclude: - 'lib/oxidized/model/hatteras.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line @@ -348,15 +340,30 @@ Layout/SpaceInsideArrayLiteralBrackets: - 'lib/oxidized/input/telnet.rb' - 'oxidized.gemspec' -# Offense count: 31 +# Offense count: 29 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideBlockBraces: - Enabled: false + Exclude: + - 'lib/oxidized/cli.rb' + - 'lib/oxidized/hook.rb' + - 'lib/oxidized/model/aos.rb' + - 'lib/oxidized/model/aos7.rb' + - 'lib/oxidized/model/c4cmts.rb' + - 'lib/oxidized/model/coriantgroove.rb' + - 'lib/oxidized/model/dlink.rb' + - 'lib/oxidized/model/enterasys.rb' + - 'lib/oxidized/model/fabricos.rb' + - 'lib/oxidized/model/hpebladesystem.rb' + - 'lib/oxidized/model/mtrlrfs.rb' + - 'lib/oxidized/model/xos.rb' + - 'lib/oxidized/model/zhoneolt.rb' + - 'lib/oxidized/node.rb' + - 'lib/oxidized/nodes.rb' -# Offense count: 23 +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact @@ -369,6 +376,8 @@ Layout/SpaceInsideHashLiteralBraces: # Offense count: 9 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space Layout/SpaceInsideParens: Exclude: - 'extra/syslog.rb' @@ -402,8 +411,9 @@ Layout/TrailingBlankLines: - 'lib/oxidized/model/tplink.rb' - 'lib/oxidized/output/http.rb' -# Offense count: 165 +# Offense count: 179 # Cop supports --auto-correct. +# Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: Enabled: false @@ -413,7 +423,7 @@ Lint/AmbiguousBlockAssociation: - 'lib/oxidized/model/model.rb' - 'lib/oxidized/model/nos.rb' -# Offense count: 648 +# Offense count: 652 Lint/AmbiguousRegexpLiteral: Enabled: false @@ -510,14 +520,14 @@ Lint/Void: # Offense count: 60 Metrics/AbcSize: - Max: 86 + Max: 84 # Offense count: 15 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: - Max: 143 + Max: 142 -# Offense count: 4 +# Offense count: 2 # Configuration parameters: CountBlocks. Metrics/BlockNesting: Max: 4 @@ -585,7 +595,7 @@ Naming/PredicateName: # Offense count: 11 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: io, id, to +# AllowedNames: io, id, to, by, on, in, at Naming/UncommunicativeMethodParamName: Exclude: - 'extra/syslog.rb' @@ -657,7 +667,7 @@ Style/Alias: Style/AndOr: Enabled: false -# Offense count: 4 +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining @@ -669,7 +679,7 @@ Style/BlockDelimiters: - 'lib/oxidized/model/aricentiss.rb' - 'lib/oxidized/model/hatteras.rb' -# Offense count: 12 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: braces, no_braces, context_dependent @@ -709,7 +719,7 @@ Style/ClassVars: Exclude: - 'lib/oxidized.rb' -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. Style/ColonMethodCall: Exclude: @@ -730,7 +740,7 @@ Style/ConditionalAssignment: - 'lib/oxidized/hook/githubrepo.rb' - 'lib/oxidized/model/model.rb' -# Offense count: 142 +# Offense count: 143 Style/Documentation: Enabled: false @@ -761,7 +771,7 @@ Style/ExpandPathArguments: - 'bin/console' - 'oxidized.gemspec' -# Offense count: 7 +# Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent @@ -778,7 +788,7 @@ Style/FormatStringToken: - 'lib/oxidized/node.rb' - 'lib/oxidized/nodes.rb' -# Offense count: 15 +# Offense count: 13 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: @@ -881,11 +891,6 @@ Style/NilComparison: Exclude: - 'lib/oxidized/input/ssh.rb' -# Offense count: 31 -# Cop supports --auto-correct. -Style/Not: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedOctalStyle. @@ -932,7 +937,7 @@ Style/ParenthesesAroundCondition: - 'lib/oxidized/model/powerconnect.rb' - 'lib/oxidized/source/http.rb' -# Offense count: 10 +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: @@ -1098,7 +1103,7 @@ Style/TrailingCommaInHashLiteral: - 'lib/oxidized/node.rb' - 'lib/oxidized/node/stats.rb' -# Offense count: 3 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: AllowNamedUnderscoreVariables. Style/TrailingUnderscoreVariable: diff --git a/oxidized.gemspec b/oxidized.gemspec index 6019842..ba5c74b 100644 --- a/oxidized.gemspec +++ b/oxidized.gemspec @@ -34,6 +34,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'minitest', '~> 5.8' s.add_development_dependency 'mocha', '~> 1.1' s.add_development_dependency 'git', '~> 1' - s.add_development_dependency 'rubocop', '~> 0.54' + s.add_development_dependency 'rubocop', '~> 0.55' s.add_development_dependency 'rails_best_practices', '~> 1.19' end -- cgit v1.2.1 From c7a439becb4def5d52e306f9aa1a0029b6ef0a97 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 20 Apr 2018 15:25:00 +0200 Subject: Be pessimistic about rubocop --- oxidized.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oxidized.gemspec b/oxidized.gemspec index ba5c74b..dfcaf4c 100644 --- a/oxidized.gemspec +++ b/oxidized.gemspec @@ -34,6 +34,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'minitest', '~> 5.8' s.add_development_dependency 'mocha', '~> 1.1' s.add_development_dependency 'git', '~> 1' - s.add_development_dependency 'rubocop', '~> 0.55' + s.add_development_dependency 'rubocop', '~> 0.55.0' s.add_development_dependency 'rails_best_practices', '~> 1.19' end -- cgit v1.2.1 From 21e3d6490496573f25ef77fe8172766ac7d1a736 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 21 Apr 2018 13:27:05 +0200 Subject: the great makeover - standardize layout, alignment, indentation --- .rubocop_todo.yml | 400 +---------------------------------- bin/oxidized | 1 - extra/rest_client.rb | 9 +- extra/syslog.rb | 32 +-- lib/oxidized/cli.rb | 4 +- lib/oxidized/config.rb | 4 +- lib/oxidized/core.rb | 6 +- lib/oxidized/hook.rb | 129 ++++++----- lib/oxidized/hook/awssns.rb | 1 - lib/oxidized/hook/exec.rb | 5 +- lib/oxidized/hook/githubrepo.rb | 13 +- lib/oxidized/hook/slackdiff.rb | 6 +- lib/oxidized/hook/xmppdiff.rb | 18 +- lib/oxidized/input/cli.rb | 11 +- lib/oxidized/input/ftp.rb | 13 +- lib/oxidized/input/ssh.rb | 25 ++- lib/oxidized/input/telnet.rb | 48 ++--- lib/oxidized/jobs.rb | 7 +- lib/oxidized/manager.rb | 9 +- lib/oxidized/model/acos.rb | 31 ++- lib/oxidized/model/acsw.rb | 11 +- lib/oxidized/model/aen.rb | 3 +- lib/oxidized/model/aireos.rb | 8 +- lib/oxidized/model/alteonos.rb | 34 ++- lib/oxidized/model/alvarion.rb | 4 - lib/oxidized/model/aos.rb | 6 +- lib/oxidized/model/aos7.rb | 5 +- lib/oxidized/model/aosw.rb | 24 +-- lib/oxidized/model/apc_aos.rb | 3 - lib/oxidized/model/arbos.rb | 5 +- lib/oxidized/model/aricentiss.rb | 2 - lib/oxidized/model/asa.rb | 66 +++--- lib/oxidized/model/asyncos.rb | 39 ++-- lib/oxidized/model/audiocodes.rb | 12 +- lib/oxidized/model/awplus.rb | 79 ++++--- lib/oxidized/model/boss.rb | 7 +- lib/oxidized/model/br6910.rb | 88 ++++---- lib/oxidized/model/c4cmts.rb | 8 +- lib/oxidized/model/catos.rb | 2 - lib/oxidized/model/cisconga.rb | 4 +- lib/oxidized/model/ciscosma.rb | 37 ++-- lib/oxidized/model/ciscosmb.rb | 8 +- lib/oxidized/model/comware.rb | 12 +- lib/oxidized/model/coriant8600.rb | 8 +- lib/oxidized/model/coriantgroove.rb | 8 +- lib/oxidized/model/corianttmos.rb | 4 +- lib/oxidized/model/cumulus.rb | 58 +++-- lib/oxidized/model/datacom.rb | 2 - lib/oxidized/model/dcnos.rb | 2 - lib/oxidized/model/dlink.rb | 2 +- lib/oxidized/model/dnos.rb | 8 +- lib/oxidized/model/edgecos.rb | 6 +- lib/oxidized/model/edgeos.rb | 2 - lib/oxidized/model/edgeswitch.rb | 4 +- lib/oxidized/model/enterasys.rb | 4 +- lib/oxidized/model/eos.rb | 14 +- lib/oxidized/model/fabricos.rb | 8 +- lib/oxidized/model/firewareos.rb | 3 - lib/oxidized/model/fortios.rb | 28 ++- lib/oxidized/model/ftos.rb | 6 +- lib/oxidized/model/fujitsupy.rb | 6 +- lib/oxidized/model/gaiaos.rb | 16 +- lib/oxidized/model/gcombnps.rb | 19 +- lib/oxidized/model/hatteras.rb | 13 +- lib/oxidized/model/hirschmann.rb | 18 +- lib/oxidized/model/hpebladesystem.rb | 32 +-- lib/oxidized/model/hpemsa.rb | 3 - lib/oxidized/model/ios.rb | 108 +++++----- lib/oxidized/model/iosxr.rb | 4 +- lib/oxidized/model/ipos.rb | 4 +- lib/oxidized/model/ironware.rb | 27 ++- lib/oxidized/model/isam.rb | 9 +- lib/oxidized/model/junos.rb | 10 +- lib/oxidized/model/masteros.rb | 4 +- lib/oxidized/model/mlnxos.rb | 7 +- lib/oxidized/model/model.rb | 21 +- lib/oxidized/model/mtrlrfs.rb | 5 +- lib/oxidized/model/ndms.rb | 1 - lib/oxidized/model/netgear.rb | 2 - lib/oxidized/model/netscaler.rb | 2 - lib/oxidized/model/nos.rb | 4 +- lib/oxidized/model/nxos.rb | 5 +- lib/oxidized/model/oneos.rb | 14 +- lib/oxidized/model/opengear.rb | 6 +- lib/oxidized/model/opnsense.rb | 8 +- lib/oxidized/model/outputs.rb | 4 +- lib/oxidized/model/panos.rb | 3 +- lib/oxidized/model/pfsense.rb | 8 +- lib/oxidized/model/planet.rb | 20 +- lib/oxidized/model/powerconnect.rb | 9 +- lib/oxidized/model/procurve.rb | 4 +- lib/oxidized/model/quantaos.rb | 8 +- lib/oxidized/model/routeros.rb | 4 +- lib/oxidized/model/saos.rb | 1 - lib/oxidized/model/screenos.rb | 8 +- lib/oxidized/model/sgos.rb | 5 +- lib/oxidized/model/siklu.rb | 2 - lib/oxidized/model/slxos.rb | 26 ++- lib/oxidized/model/sros.rb | 1 - lib/oxidized/model/tmos.rb | 4 +- lib/oxidized/model/tplink.rb | 18 +- lib/oxidized/model/trango.rb | 13 +- lib/oxidized/model/ucs.rb | 1 - lib/oxidized/model/voltaire.rb | 9 +- lib/oxidized/model/voss.rb | 3 +- lib/oxidized/model/vrp.rb | 7 +- lib/oxidized/model/vyatta.rb | 4 +- lib/oxidized/model/weos.rb | 4 +- lib/oxidized/model/xos.rb | 6 +- lib/oxidized/model/zhoneolt.rb | 2 +- lib/oxidized/model/zynos.rb | 4 +- lib/oxidized/node.rb | 19 +- lib/oxidized/node/stats.rb | 3 +- lib/oxidized/nodes.rb | 13 +- lib/oxidized/output/file.rb | 83 ++++---- lib/oxidized/output/git.rb | 228 ++++++++++---------- lib/oxidized/output/gitcrypt.rb | 27 ++- lib/oxidized/output/http.rb | 50 ++--- lib/oxidized/output/output.rb | 3 +- lib/oxidized/source/csv.rb | 89 ++++---- lib/oxidized/source/http.rb | 97 +++++---- lib/oxidized/source/source.rb | 13 +- lib/oxidized/source/sql.rb | 103 +++++---- lib/oxidized/string.rb | 5 +- lib/oxidized/worker.rb | 2 +- oxidized.gemspec | 11 +- spec/cli_spec.rb | 8 +- spec/githubrepo_spec.rb | 2 +- 128 files changed, 1050 insertions(+), 1638 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b91409a..1b40a21 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-04-20 14:46:50 +0200 using RuboCop version 0.55.0. +# on 2018-04-21 13:24:05 +0200 using RuboCop version 0.55.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -21,402 +21,6 @@ Gemspec/RequiredRubyVersion: Exclude: - 'oxidized.gemspec' -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_parameter, with_fixed_indentation -Layout/AlignParameters: - Exclude: - - 'lib/oxidized/hook.rb' - - 'lib/oxidized/hook/exec.rb' - - 'lib/oxidized/output/git.rb' - - 'lib/oxidized/worker.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'lib/oxidized/model/awplus.rb' - - 'lib/oxidized/model/sgos.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -Layout/BlockEndNewline: - Exclude: - - 'lib/oxidized/model/awplus.rb' - - 'lib/oxidized/model/hatteras.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. -# SupportedStyles: case, end -Layout/CaseIndentation: - Exclude: - - 'lib/oxidized/output/http.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/ClosingParenthesisIndentation: - Exclude: - - 'lib/oxidized/output/git.rb' - -# Offense count: 13 -# Cop supports --auto-correct. -Layout/CommentIndentation: - Exclude: - - 'lib/oxidized/model/aosw.rb' - - 'lib/oxidized/model/audiocodes.rb' - - 'lib/oxidized/model/awplus.rb' - - 'lib/oxidized/model/edgeswitch.rb' - - 'lib/oxidized/model/fujitsupy.rb' - - 'lib/oxidized/model/gcombnps.rb' - - 'lib/oxidized/model/masteros.rb' - - 'lib/oxidized/model/planet.rb' - - 'lib/oxidized/output/http.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -Layout/ElseAlignment: - Exclude: - - 'lib/oxidized/input/telnet.rb' - - 'lib/oxidized/output/gitcrypt.rb' - - 'lib/oxidized/source/csv.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLineAfterMagicComment: - Exclude: - - 'oxidized.gemspec' - -# Offense count: 17 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Exclude: - - 'extra/syslog.rb' - - 'lib/oxidized/manager.rb' - - 'lib/oxidized/model/model.rb' - - 'lib/oxidized/nodes.rb' - - 'lib/oxidized/output/git.rb' - - 'lib/oxidized/output/gitcrypt.rb' - -# Offense count: 17 -# Cop supports --auto-correct. -Layout/EmptyLines: - Exclude: - - 'bin/oxidized' - - 'lib/oxidized/input/telnet.rb' - - 'lib/oxidized/model/acsw.rb' - - 'lib/oxidized/model/alvarion.rb' - - 'lib/oxidized/model/gaiaos.rb' - - 'lib/oxidized/model/gcombnps.rb' - - 'lib/oxidized/model/hatteras.rb' - - 'lib/oxidized/model/ironware.rb' - - 'lib/oxidized/model/planet.rb' - - 'lib/oxidized/model/voltaire.rb' - - 'lib/oxidized/nodes.rb' - - 'lib/oxidized/output/git.rb' - - 'lib/oxidized/output/gitcrypt.rb' - -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'lib/oxidized/hook/githubrepo.rb' - - 'lib/oxidized/model/alvarion.rb' - - 'lib/oxidized/model/asyncos.rb' - - 'lib/oxidized/model/audiocodes.rb' - - 'lib/oxidized/model/ciscosma.rb' - - 'lib/oxidized/model/tplink.rb' - -# Offense count: 159 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only -Layout/EmptyLinesAroundClassBody: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundExceptionHandlingKeywords: - Exclude: - - 'lib/oxidized/hook/exec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundMethodBody: - Exclude: - - 'lib/oxidized/output/http.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines -Layout/EmptyLinesAroundModuleBody: - Exclude: - - 'lib/oxidized/input/cli.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Layout/EndAlignment: - Exclude: - - 'lib/oxidized/output/gitcrypt.rb' - - 'lib/oxidized/source/csv.rb' - -# Offense count: 1 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: native, lf, crlf -Layout/EndOfLine: - Exclude: - - 'lib/oxidized/model/br6910.rb' - -# Offense count: 63 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstParameterIndentation: - Exclude: - - 'lib/oxidized/output/http.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/IndentHash: - Exclude: - - 'lib/oxidized/hook/githubrepo.rb' - - 'lib/oxidized/input/ssh.rb' - - 'lib/oxidized/output/http.rb' - -# Offense count: 21 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: normal, rails -Layout/IndentationConsistency: - Exclude: - - 'lib/oxidized/model/acsw.rb' - - 'lib/oxidized/model/awplus.rb' - - 'lib/oxidized/model/fortios.rb' - - 'lib/oxidized/model/hpebladesystem.rb' - - 'lib/oxidized/model/masteros.rb' - - 'lib/oxidized/model/sgos.rb' - - 'lib/oxidized/model/slxos.rb' - - 'lib/oxidized/output/git.rb' - -# Offense count: 47 -# Cop supports --auto-correct. -# Configuration parameters: Width, IgnoredPatterns. -Layout/IndentationWidth: - Enabled: false - -# Offense count: 108 -# Cop supports --auto-correct. -Layout/LeadingCommentSpace: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -Layout/MultilineBlockLayout: - Exclude: - - 'lib/oxidized/model/hatteras.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'lib/oxidized/output/git.rb' - -# Offense count: 14 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/MultilineOperationIndentation: - Exclude: - - 'lib/oxidized/hook.rb' - - 'lib/oxidized/model/awplus.rb' - - 'lib/oxidized/model/hatteras.rb' - - 'lib/oxidized/model/quantaos.rb' - - 'lib/oxidized/model/trango.rb' - -# Offense count: 33 -# Cop supports --auto-correct. -Layout/SpaceAfterComma: - Enabled: false - -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleInsidePipes. -# SupportedStylesInsidePipes: space, no_space -Layout/SpaceAroundBlockParameters: - Exclude: - - 'lib/oxidized/model/aos.rb' - - 'lib/oxidized/model/aos7.rb' - - 'lib/oxidized/model/c4cmts.rb' - - 'lib/oxidized/model/coriantgroove.rb' - - 'lib/oxidized/model/dlink.rb' - - 'lib/oxidized/model/enterasys.rb' - - 'lib/oxidized/model/hpebladesystem.rb' - - 'lib/oxidized/model/mtrlrfs.rb' - - 'lib/oxidized/model/xos.rb' - - 'lib/oxidized/model/zhoneolt.rb' - - 'lib/oxidized/node.rb' - -# Offense count: 32 -# Cop supports --auto-correct. -# Configuration parameters: . -# SupportedStyles: space, no_space -Layout/SpaceAroundEqualsInParameterDefault: - EnforcedStyle: no_space - -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceAroundKeyword: - Exclude: - - 'lib/oxidized/input/telnet.rb' - - 'lib/oxidized/model/xos.rb' - -# Offense count: 49 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceAroundOperators: - Enabled: false - -# Offense count: 15 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Exclude: - - 'lib/oxidized/cli.rb' - - 'lib/oxidized/model/aos.rb' - - 'lib/oxidized/model/aos7.rb' - - 'lib/oxidized/model/c4cmts.rb' - - 'lib/oxidized/model/coriantgroove.rb' - - 'lib/oxidized/model/dlink.rb' - - 'lib/oxidized/model/enterasys.rb' - - 'lib/oxidized/model/hpebladesystem.rb' - - 'lib/oxidized/model/mtrlrfs.rb' - - 'lib/oxidized/model/xos.rb' - - 'lib/oxidized/model/zhoneolt.rb' - - 'lib/oxidized/node.rb' - - 'lib/oxidized/output/output.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -Layout/SpaceBeforeComma: - Exclude: - - 'lib/oxidized/hook/exec.rb' - - 'lib/oxidized/model/fortios.rb' - -# Offense count: 25 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Enabled: false - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - 'lib/oxidized/input/ssh.rb' - - 'lib/oxidized/input/telnet.rb' - - 'oxidized.gemspec' - -# Offense count: 29 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'lib/oxidized/cli.rb' - - 'lib/oxidized/hook.rb' - - 'lib/oxidized/model/aos.rb' - - 'lib/oxidized/model/aos7.rb' - - 'lib/oxidized/model/c4cmts.rb' - - 'lib/oxidized/model/coriantgroove.rb' - - 'lib/oxidized/model/dlink.rb' - - 'lib/oxidized/model/enterasys.rb' - - 'lib/oxidized/model/fabricos.rb' - - 'lib/oxidized/model/hpebladesystem.rb' - - 'lib/oxidized/model/mtrlrfs.rb' - - 'lib/oxidized/model/xos.rb' - - 'lib/oxidized/model/zhoneolt.rb' - - 'lib/oxidized/node.rb' - - 'lib/oxidized/nodes.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'lib/oxidized/output/git.rb' - - 'lib/oxidized/output/gitcrypt.rb' - - 'lib/oxidized/output/http.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideParens: - Exclude: - - 'extra/syslog.rb' - - 'lib/oxidized/input/telnet.rb' - - 'lib/oxidized/model/asa.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -Layout/SpaceInsidePercentLiteralDelimiters: - Exclude: - - 'oxidized.gemspec' - -# Offense count: 6 -# Cop supports --auto-correct. -Layout/SpaceInsideRangeLiteral: - Exclude: - - 'lib/oxidized/input/telnet.rb' - -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingBlankLines: - Exclude: - - 'lib/oxidized/model/aen.rb' - - 'lib/oxidized/model/apc_aos.rb' - - 'lib/oxidized/model/firewareos.rb' - - 'lib/oxidized/model/gcombnps.rb' - - 'lib/oxidized/model/hpemsa.rb' - - 'lib/oxidized/model/mtrlrfs.rb' - - 'lib/oxidized/model/tplink.rb' - - 'lib/oxidized/output/http.rb' - -# Offense count: 179 -# Cop supports --auto-correct. -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Enabled: false - # Offense count: 4 Lint/AmbiguousBlockAssociation: Exclude: @@ -1145,7 +749,7 @@ Style/ZeroLengthPredicate: - 'lib/oxidized/model/ciscosmb.rb' - 'lib/oxidized/output/git.rb' -# Offense count: 275 +# Offense count: 269 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: diff --git a/bin/oxidized b/bin/oxidized index 7a0b03d..92730ee 100755 --- a/bin/oxidized +++ b/bin/oxidized @@ -1,6 +1,5 @@ #!/usr/bin/env ruby - # FIX ME, killing oxidized needs -9 trap("INT") { exit } # sinatra will otherwise steal this from us diff --git a/extra/rest_client.rb b/extra/rest_client.rb index 35d93ae..dba89c3 100644 --- a/extra/rest_client.rb +++ b/extra/rest_client.rb @@ -6,10 +6,10 @@ module Oxidized require 'asetus' class Config - Root = Root = ENV['OXIDIZED_HOME'] || File.join(ENV['HOME'], '.config', 'oxidized') + Root = Root = ENV['OXIDIZED_HOME'] || File.join(ENV['HOME'], '.config', 'oxidized') end - CFGS = Asetus.new :name=>'oxidized', :load=>false, :key_to_s=>true + CFGS = Asetus.new :name => 'oxidized', :load => false, :key_to_s => true CFGS.default.rest = '127.0.0.1:8888' begin @@ -28,13 +28,13 @@ module Oxidized PATH = URI(restcfg).path class << self - def next opt={}, host=HOST, port=PORT + def next opt = {}, host = HOST, port = PORT web = new host, port web.next opt end end - def initialize host=HOST, port=PORT + def initialize host = HOST, port = PORT @web = Net::HTTP.new host, port end @@ -42,6 +42,5 @@ module Oxidized data = JSON.dump opt @web.put PATH + '/node/next/' + opt[:name].to_s, data end - end end diff --git a/extra/syslog.rb b/extra/syslog.rb index e364cf9..f7d271f 100755 --- a/extra/syslog.rb +++ b/extra/syslog.rb @@ -27,13 +27,12 @@ require 'resolv' require_relative 'rest_client' module Oxidized - require 'asetus' class Config - Root = File.join ENV['HOME'], '.config', 'oxidized' + Root = File.join ENV['HOME'], '.config', 'oxidized' end - CFGS = Asetus.new :name=>'oxidized', :load=>false, :key_to_s=>true + CFGS = Asetus.new :name => 'oxidized', :load => false, :key_to_s => true CFGS.default.syslogd.port = 514 CFGS.default.syslogd.file = 'messages' CFGS.default.syslogd.resolve = true @@ -43,7 +42,7 @@ module Oxidized rescue => error raise InvalidConfig, "Error loading config: #{error.message}" ensure - CFG = CFGS.cfg # convenienence, instead of Config.cfg.password, CFG.password + CFG = CFGS.cfg # convenienence, instead of Config.cfg.password, CFG.password end class SyslogMonitor @@ -59,12 +58,13 @@ module Oxidized } class << self - def udp port=Oxidized::CFG.syslogd.port, listen=0 + def udp port = Oxidized::CFG.syslogd.port, listen = 0 io = UDPSocket.new io.bind listen, port new io, :udp end - def file syslog_file=Oxidized::CFG.syslogd.file + + def file syslog_file = Oxidized::CFG.syslogd.file io = open syslog_file, 'r' io.seek 0, IO::SEEK_END new io, :file @@ -73,7 +73,7 @@ module Oxidized private - def initialize io, mode=:udp + def initialize io, mode = :udp @mode = mode run io end @@ -84,24 +84,24 @@ module Oxidized def ios ip, log, i # TODO: we need to fetch 'ip/name' in mode == :file here - user = log[i+5] + user = log[i + 5] from = log[-1][1..-2] - rest( :user => user, :from => from, :model => 'ios', :ip => ip, - :name => getname(ip) ) + rest(:user => user, :from => from, :model => 'ios', :ip => ip, + :name => getname(ip)) end def jnpr ip, log, i # TODO: we need to fetch 'ip/name' in mode == :file here - user = log[i+2][1..-2] - msg = log[(i+6)..-1].join(' ')[10..-2] + user = log[i + 2][1..-2] + msg = log[(i + 6)..-1].join(' ')[10..-2] msg = nil if msg == 'none' - rest( :user => user, :msg => msg, :model => 'jnpr', :ip => ip, - :name => getname(ip) ) + rest(:user => user, :msg => msg, :model => 'jnpr', :ip => ip, + :name => getname(ip)) end def handle_log log, ip log = log.to_s.split ' ' - if i = log.find_index { |e| e.match( MSG[:ios] ) } + if i = log.find_index { |e| e.match(MSG[:ios]) } ios ip, log, i elsif i = log.index(MSG[:junos]) jnpr ip, log, i @@ -140,4 +140,4 @@ module Oxidized end Oxidized::SyslogMonitor.udp -#Oxidized::SyslogMonitor.file '/var/log/poop' +# Oxidized::SyslogMonitor.file '/var/log/poop' diff --git a/lib/oxidized/cli.rb b/lib/oxidized/cli.rb index 9a09d41..c29e269 100644 --- a/lib/oxidized/cli.rb +++ b/lib/oxidized/cli.rb @@ -40,7 +40,7 @@ module Oxidized end def parse_opts - opts = Slop.new(:help=>true) do + opts = Slop.new(:help => true) do on 'd', 'debug', 'turn on debugging' on 'daemonize', 'Daemonize/fork the process' on 'v', 'version', 'show version' do @@ -62,7 +62,7 @@ module Oxidized def write_pid if pidfile? begin - File.open(pidfile, ::File::CREAT | ::File::EXCL | ::File::WRONLY){|f| f.write("#{Process.pid}") } + File.open(pidfile, ::File::CREAT | ::File::EXCL | ::File::WRONLY) { |f| f.write("#{Process.pid}") } at_exit { File.delete(pidfile) if File.exists?(pidfile) } rescue Errno::EEXIST check_pid diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb index 47544fb..a825d39 100644 --- a/lib/oxidized/config.rb +++ b/lib/oxidized/config.rb @@ -13,7 +13,7 @@ module Oxidized HookDir = File.join Directory, %w(lib oxidized hook) Sleep = 1 - def self.load(cmd_opts={}) + def self.load(cmd_opts = {}) asetus = Asetus.new(name: 'oxidized', load: false, key_to_s: true) Oxidized.asetus = asetus @@ -37,7 +37,7 @@ module Oxidized asetus.default.input.default = 'ssh, telnet' asetus.default.input.debug = false # or String for session log file asetus.default.input.ssh.secure = false # complain about changed certs - asetus.default.input.ftp.passive= true # ftp passive mode + asetus.default.input.ftp.passive = true # ftp passive mode asetus.default.output.default = 'file' # file, git asetus.default.source.default = 'csv' # csv, sql diff --git a/lib/oxidized/core.rb b/lib/oxidized/core.rb index e007c9d..440d8e2 100644 --- a/lib/oxidized/core.rb +++ b/lib/oxidized/core.rb @@ -11,9 +11,9 @@ module Oxidized def initialize args Oxidized.mgr = Manager.new Oxidized.Hooks = HookManager.from_config(Oxidized.config) - nodes = Nodes.new + nodes = Nodes.new raise NoNodesFound, 'source returns no usable nodes' if nodes.size == 0 - @worker = Worker.new nodes + @worker = Worker.new nodes trap('HUP') { nodes.load } if Oxidized.config.rest? begin @@ -22,7 +22,7 @@ module Oxidized raise OxidizedError, 'oxidized-web not found: sudo gem install oxidized-web - \ or disable web support by setting "rest: false" in your configuration' end - @rest = API::Web.new nodes, Oxidized.config.rest + @rest = API::Web.new nodes, Oxidized.config.rest @rest.run end run diff --git a/lib/oxidized/hook.rb b/lib/oxidized/hook.rb index c27f6fd..915299b 100644 --- a/lib/oxidized/hook.rb +++ b/lib/oxidized/hook.rb @@ -1,89 +1,88 @@ module Oxidized -class HookManager - class << self - def from_config cfg - mgr = new - cfg.hooks.each do |name,h_cfg| - h_cfg.events.each do |event| - mgr.register event.to_sym, name, h_cfg.type, h_cfg + class HookManager + class << self + def from_config cfg + mgr = new + cfg.hooks.each do |name, h_cfg| + h_cfg.events.each do |event| + mgr.register event.to_sym, name, h_cfg.type, h_cfg + end end + mgr end - mgr end - end - - # HookContext is passed to each hook. It can contain anything related to the - # event in question. At least it contains the event name - class HookContext < OpenStruct; end - # RegisteredHook is a container for a Hook instance - class RegisteredHook < Struct.new(:name, :hook); end + # HookContext is passed to each hook. It can contain anything related to the + # event in question. At least it contains the event name + class HookContext < OpenStruct; end - Events = [ - :node_success, - :node_fail, - :post_store, - :nodes_done - ] - attr_reader :registered_hooks + # RegisteredHook is a container for a Hook instance + class RegisteredHook < Struct.new(:name, :hook); end - def initialize - @registered_hooks = Hash.new {|h,k| h[k] = []} - end + Events = [ + :node_success, + :node_fail, + :post_store, + :nodes_done + ] + attr_reader :registered_hooks - def register event, name, hook_type, cfg - unless Events.include? event - raise ArgumentError, - "unknown event #{event}, available: #{Events.join ','}" + def initialize + @registered_hooks = Hash.new { |h, k| h[k] = [] } end - Oxidized.mgr.add_hook hook_type - begin - hook = Oxidized.mgr.hook.fetch(hook_type).new - rescue KeyError - raise KeyError, "cannot find hook #{hook_type.inspect}" - end + def register event, name, hook_type, cfg + unless Events.include? event + raise ArgumentError, + "unknown event #{event}, available: #{Events.join ','}" + end - hook.cfg = cfg + Oxidized.mgr.add_hook hook_type + begin + hook = Oxidized.mgr.hook.fetch(hook_type).new + rescue KeyError + raise KeyError, "cannot find hook #{hook_type.inspect}" + end - @registered_hooks[event] << RegisteredHook.new(name, hook) - Oxidized.logger.debug "Hook #{name.inspect} registered #{hook.class} for event #{event.inspect}" - end + hook.cfg = cfg - def handle event, ctx_params={} - ctx = HookContext.new ctx_params - ctx.event = event + @registered_hooks[event] << RegisteredHook.new(name, hook) + Oxidized.logger.debug "Hook #{name.inspect} registered #{hook.class} for event #{event.inspect}" + end - @registered_hooks[event].each do |r_hook| - begin - r_hook.hook.run_hook ctx - rescue => e - Oxidized.logger.error "Hook #{r_hook.name} (#{r_hook.hook}) failed " + - "(#{e.inspect}) for event #{event.inspect}" + def handle event, ctx_params = {} + ctx = HookContext.new ctx_params + ctx.event = event + + @registered_hooks[event].each do |r_hook| + begin + r_hook.hook.run_hook ctx + rescue => e + Oxidized.logger.error "Hook #{r_hook.name} (#{r_hook.hook}) failed " + + "(#{e.inspect}) for event #{event.inspect}" + end end end end -end -# Hook abstract base class -class Hook - attr_reader :cfg + # Hook abstract base class + class Hook + attr_reader :cfg - def initialize - end + def initialize + end - def cfg=(cfg) - @cfg = cfg - validate_cfg! if self.respond_to? :validate_cfg! - end + def cfg=(cfg) + @cfg = cfg + validate_cfg! if self.respond_to? :validate_cfg! + end - def run_hook ctx - raise NotImplementedError - end + def run_hook ctx + raise NotImplementedError + end - def log(msg, level=:info) - Oxidized.logger.send(level, "#{self.class.name}: #{msg}") + def log(msg, level = :info) + Oxidized.logger.send(level, "#{self.class.name}: #{msg}") + end end - -end end diff --git a/lib/oxidized/hook/awssns.rb b/lib/oxidized/hook/awssns.rb index 82c118e..183cd2c 100644 --- a/lib/oxidized/hook/awssns.rb +++ b/lib/oxidized/hook/awssns.rb @@ -23,5 +23,4 @@ class AwsSns < Oxidized::Hook message: message.to_json ) end - end diff --git a/lib/oxidized/hook/exec.rb b/lib/oxidized/hook/exec.rb index 3f984c2..8a32412 100644 --- a/lib/oxidized/hook/exec.rb +++ b/lib/oxidized/hook/exec.rb @@ -23,10 +23,9 @@ class Exec < Oxidized::Hook @cmd = cfg.cmd raise "invalid cmd value" unless @cmd.is_a?(String) || @cmd.is_a?(Array) end - rescue RuntimeError => e raise ArgumentError, - "#{self.class.name}: configuration invalid: #{e.message}" + "#{self.class.name}: configuration invalid: #{e.message}" end def run_hook ctx @@ -45,7 +44,7 @@ class Exec < Oxidized::Hook def run_cmd! env pid, status = nil, nil Timeout.timeout(@timeout) do - pid = spawn env, @cmd , :unsetenv_others => true + pid = spawn env, @cmd, :unsetenv_others => true pid, status = wait2 pid unless status.exitstatus.zero? msg = "#{@cmd.inspect} failed with exit value #{status.exitstatus}" diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb index 4cae4e6..e077d5d 100644 --- a/lib/oxidized/hook/githubrepo.rb +++ b/lib/oxidized/hook/githubrepo.rb @@ -35,21 +35,20 @@ class GithubRepo < Oxidized::Hook end Rugged::Commit.create(repo, { - parents: [repo.head.target, their_branch.target], - tree: merge_index.write_tree(repo), - message: "Merge remote-tracking branch '#{their_branch.name}'", - update_ref: "HEAD" - }) + parents: [repo.head.target, their_branch.target], + tree: merge_index.write_tree(repo), + message: "Merge remote-tracking branch '#{their_branch.name}'", + update_ref: "HEAD" + }) end private def credentials Proc.new do |url, username_from_url, allowed_types| - if cfg.has_key?('username') git_user = cfg.username - else + else git_user = username_from_url ? username_from_url : 'git' end diff --git a/lib/oxidized/hook/slackdiff.rb b/lib/oxidized/hook/slackdiff.rb index e271d5f..2c5ec14 100644 --- a/lib/oxidized/hook/slackdiff.rb +++ b/lib/oxidized/hook/slackdiff.rb @@ -14,8 +14,8 @@ class SlackDiff < Oxidized::Hook return unless ctx.event.to_s == "post_store" log "Connecting to slack" Slack.configure do |config| - config.token = cfg.token - config.proxy = cfg.proxy if cfg.has_key?('proxy') + config.token = cfg.token + config.proxy = cfg.proxy if cfg.has_key?('proxy') end client = Slack::Client.new client.auth_test @@ -46,7 +46,7 @@ class SlackDiff < Oxidized::Hook msg = format(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.channel}" - client.chat_postMessage(channel: cfg.channel, text: msg, as_user: true) + client.chat_postMessage(channel: cfg.channel, text: msg, as_user: true) end log "Finished" end diff --git a/lib/oxidized/hook/xmppdiff.rb b/lib/oxidized/hook/xmppdiff.rb index 52cc0e0..6acb172 100644 --- a/lib/oxidized/hook/xmppdiff.rb +++ b/lib/oxidized/hook/xmppdiff.rb @@ -30,25 +30,25 @@ class XMPPDiff < Oxidized::Hook sleep 1 client.auth(cfg.password) sleep 1 - + log "Connected" - + m = Jabber::MUC::SimpleMUCClient.new(client) m.join(cfg.channel + "/" + cfg.nick) - + log "Joined" - + title = "#{ctx.node.name} #{ctx.node.group} #{ctx.node.model.class.name.to_s.downcase}" log "Posting diff as snippet to #{cfg.channel}" - + m.say(title + "\n\n" + diff[:patch].lines.to_a[4..-1].join) - + sleep 1 - + client.close - + log "Finished" - + end end rescue Timeout::Error diff --git a/lib/oxidized/input/cli.rb b/lib/oxidized/input/cli.rb index 660e173..d434e33 100644 --- a/lib/oxidized/input/cli.rb +++ b/lib/oxidized/input/cli.rb @@ -32,26 +32,25 @@ module Oxidized @pre_logout.each { |command, block| block ? block.call : (cmd command, nil) } end - def post_login _post_login=nil, &block + def post_login _post_login = nil, &block unless @exec @post_login << [_post_login, block] end end - def pre_logout _pre_logout=nil, &block + def pre_logout _pre_logout = nil, &block unless @exec - @pre_logout << [_pre_logout, block] + @pre_logout << [_pre_logout, block] end end - def username re=/^(Username|login)/ + def username re = /^(Username|login)/ @username or @username = re end - def password re=/^Password/ + def password re = /^Password/ @password or @password = re end - end end end diff --git a/lib/oxidized/input/ftp.rb b/lib/oxidized/input/ftp.rb index cdf3688..ebe50ef 100644 --- a/lib/oxidized/input/ftp.rb +++ b/lib/oxidized/input/ftp.rb @@ -6,22 +6,22 @@ module Oxidized class FTP < Input RescueFail = { :debug => [ - #Net::SSH::Disconnect, + # Net::SSH::Disconnect, ], :warn => [ - #RuntimeError, - #Net::SSH::AuthenticationFailed, + # RuntimeError, + # Net::SSH::AuthenticationFailed, ], } include Input::CLI def connect node - @node = node + @node = node @node.model.cfg['ftp'].each { |cb| instance_exec(&cb) } @log = File.open(Oxidized::Config::Log + "/#{@node.ip}-ftp", 'w') if Oxidized.config.input.debug? @ftp = Net::FTP.new(@node.ip) @ftp.passive = Oxidized.config.input.ftp.passive - @ftp.login @node.auth[:username], @node.auth[:password] + @ftp.login @node.auth[:username], @node.auth[:password] connected? end @@ -47,10 +47,9 @@ module Oxidized def disconnect @ftp.close - #rescue Errno::ECONNRESET, IOError + # rescue Errno::ECONNRESET, IOError ensure @log.close if Oxidized.config.input.debug? end - end end diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index 27e81e0..9cb6a4f 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -24,20 +24,20 @@ module Oxidized secure = Oxidized.config.input.ssh.secure @log = File.open(Oxidized::Config::Log + "/#{@node.ip}-ssh", 'w') if Oxidized.config.input.debug? port = vars(:ssh_port) || 22 - + ssh_opts = { - :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, - } + :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, + } if proxy_host = vars(:ssh_proxy) proxy_command = "ssh " proxy_command += "-o StrictHostKeyChecking=no " unless secure proxy_command += "#{proxy_host} -W %h:%p" - proxy = Net::SSH::Proxy::Command.new(proxy_command) + proxy = Net::SSH::Proxy::Command.new(proxy_command) ssh_opts[:proxy] = proxy end @@ -52,7 +52,7 @@ module Oxidized begin login rescue Timeout::Error - raise PromptUndetect, [ @output, 'not matching configured prompt', @node.prompt ].join(' ') + raise PromptUndetect, [@output, 'not matching configured prompt', @node.prompt].join(' ') end end connected? @@ -62,7 +62,7 @@ module Oxidized @ssh and not @ssh.closed? end - def cmd cmd, expect=node.prompt + def cmd cmd, expect = node.prompt Oxidized.logger.debug "lib/oxidized/input/ssh.rb #{cmd} @ #{node.name} with expect: #{expect.inspect}" if @exec @ssh.exec! cmd @@ -128,8 +128,8 @@ module Oxidized end end - def exec state=nil - state == nil ? @exec : (@exec=state) unless vars :ssh_no_exec + def exec state = nil + state == nil ? @exec : (@exec = state) unless vars :ssh_no_exec end def cmd_shell(cmd, expect_re) @@ -152,6 +152,5 @@ module Oxidized end end end - end end diff --git a/lib/oxidized/input/telnet.rb b/lib/oxidized/input/telnet.rb index a5561b9..4371e26 100644 --- a/lib/oxidized/input/telnet.rb +++ b/lib/oxidized/input/telnet.rb @@ -18,7 +18,7 @@ module Oxidized 'Model' => @node.model } opt['Output_log'] = Oxidized::Config::Log + "/#{@node.ip}-telnet" if Oxidized.config.input.debug? - @telnet = Net::Telnet.new opt + @telnet = Net::Telnet.new opt if @node.auth[:username] and @node.auth[:username].length > 0 expect username @telnet.puts @node.auth[:username] @@ -28,7 +28,7 @@ module Oxidized begin expect @node.prompt rescue Timeout::Error - raise PromptUndetect, [ 'unable to detect prompt:', @node.prompt ].join(' ') + raise PromptUndetect, ['unable to detect prompt:', @node.prompt].join(' ') end end @@ -36,7 +36,7 @@ module Oxidized @telnet and not @telnet.sock.closed? end - def cmd cmd, expect=@node.prompt + def cmd cmd, expect = @node.prompt Oxidized.logger.debug "Telnet: #{cmd} @#{@node.name}" args = { 'String' => cmd } args.merge!({ 'Match' => expect, 'Timeout' => @timeout }) if expect @@ -64,11 +64,9 @@ module Oxidized rescue Errno::ECONNRESET end end - end end - class Net::Telnet ## FIXME: we just need 'line = model.expects line' to handle pager ## how to do this, without redefining the whole damn thing @@ -86,7 +84,7 @@ class Net::Telnet elsif options.has_key?("Prompt") options["Prompt"] elsif options.has_key?("String") - Regexp.new( Regexp.quote(options["String"]) ) + Regexp.new(Regexp.quote(options["String"])) end time_out = options["Timeout"] if options.has_key?("Timeout") waittime = options["Waittime"] if options.has_key?("Waittime") @@ -102,7 +100,7 @@ class Net::Telnet line = '' buf = '' rest = '' - until(prompt === line and not IO::select([@sock], nil, nil, waittime)) + until prompt === line and not IO::select([@sock], nil, nil, waittime) unless IO::select([@sock], nil, nil, time_out) raise TimeoutError, "timed out while waiting for more data" end @@ -114,30 +112,30 @@ class Net::Telnet c = rest + c if Integer(c.rindex(/#{IAC}#{SE}/no) || 0) < Integer(c.rindex(/#{IAC}#{SB}/no) || 0) - buf = preprocess(c[0 ... c.rindex(/#{IAC}#{SB}/no)]) - rest = c[c.rindex(/#{IAC}#{SB}/no) .. -1] + buf = preprocess(c[0...c.rindex(/#{IAC}#{SB}/no)]) + rest = c[c.rindex(/#{IAC}#{SB}/no)..-1] elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no) || c.rindex(/\r\z/no) - buf = preprocess(c[0 ... pt]) - rest = c[pt .. -1] + buf = preprocess(c[0...pt]) + rest = c[pt..-1] else buf = preprocess(c) rest = '' end - else - # Not Telnetmode. - # - # We cannot use preprocess() on this data, because that - # method makes some Telnetmode-specific assumptions. - buf = rest + c - rest = '' - unless @options["Binmode"] - if pt = buf.rindex(/\r\z/no) - buf = buf[0 ... pt] - rest = buf[pt .. -1] - end - buf.gsub!(/#{EOL}/no, "\n") - end + else + # Not Telnetmode. + # + # We cannot use preprocess() on this data, because that + # method makes some Telnetmode-specific assumptions. + buf = rest + c + rest = '' + unless @options["Binmode"] + if pt = buf.rindex(/\r\z/no) + buf = buf[0...pt] + rest = buf[pt..-1] + end + buf.gsub!(/#{EOL}/no, "\n") + end end @log.print(buf) if @options.has_key?("Output_log") line += buf diff --git a/lib/oxidized/jobs.rb b/lib/oxidized/jobs.rb index c566778..fdc1cbf 100644 --- a/lib/oxidized/jobs.rb +++ b/lib/oxidized/jobs.rb @@ -6,7 +6,7 @@ module Oxidized def initialize max, interval, nodes @max = max - # Set interval to 1 if interval is 0 (=disabled) so we don't break + # Set interval to 1 if interval is 0 (=disabled) so we don't break # the 'ceil' function @interval = interval == 0 ? 1 : interval @nodes = nodes @@ -28,7 +28,7 @@ module Oxidized @durations.fill AVERAGE_DURATION, @durations.size...@nodes.size end @durations.push(last).shift - @duration = @durations.inject(:+).to_f / @nodes.size #rolling average + @duration = @durations.inject(:+).to_f / @nodes.size # rolling average new_count end @@ -45,9 +45,8 @@ module Oxidized # and c) there is more than MAX_INTER_JOB_GAP since last one was started # then we want one more thread (rationale is to fix hanging thread causing HOLB) if @want <= size and @want < @nodes.size - @want +=1 if (Time.now.utc - @last) > MAX_INTER_JOB_GAP + @want += 1 if (Time.now.utc - @last) > MAX_INTER_JOB_GAP end end - end end diff --git a/lib/oxidized/manager.rb b/lib/oxidized/manager.rb index d2ef4d2..c4523f3 100644 --- a/lib/oxidized/manager.rb +++ b/lib/oxidized/manager.rb @@ -7,11 +7,11 @@ module Oxidized class << self def load dir, file begin - require File.join dir, file+'.rb' + require File.join dir, file + '.rb' klass = nil [Oxidized, Object].each do |mod| klass = mod.constants.find { |const| const.to_s.downcase == file.downcase } - klass = mod.constants.find { |const| const.to_s.downcase == 'oxidized'+ file.downcase } unless klass + klass = mod.constants.find { |const| const.to_s.downcase == 'oxidized' + file.downcase } unless klass klass = mod.const_get klass if klass break if klass end @@ -31,16 +31,19 @@ module Oxidized @source = {} @hook = {} end + def add_input method method = Manager.load Config::InputDir, method return false if method.empty? @input.merge! method end + def add_output method method = Manager.load Config::OutputDir, method return false if method.empty? @output.merge! method end + def add_model _model name = _model _model = Manager.load File.join(Config::Root, 'model'), name @@ -48,12 +51,14 @@ module Oxidized return false if _model.empty? @model.merge! _model end + def add_source _source return nil if @source.has_key? _source _source = Manager.load Config::SourceDir, _source return false if _source.empty? @source.merge! _source end + def add_hook _hook return nil if @hook.has_key? _hook name = _hook diff --git a/lib/oxidized/model/acos.rb b/lib/oxidized/model/acos.rb index 47649a2..a2db89c 100644 --- a/lib/oxidized/model/acos.rb +++ b/lib/oxidized/model/acos.rb @@ -3,7 +3,7 @@ class ACOS < Oxidized::Model comment '! ' - ##ACOS prompt changes depending on the state of the device + # ACOS prompt changes depending on the state of the device prompt /^([-\w.\/:?\[\]\(\)]+[#>]\s?)$/ cmd :secret do |cfg| @@ -30,19 +30,19 @@ class ACOS < Oxidized::Model end cmd 'show partition-config all' do |cfg| - cfg.gsub! /(Current configuration).*/, '\\1 ' - cfg.gsub! /(Configuration last updated at).*/, '\\1 ' - cfg.gsub! /(Configuration last saved at).*/, '\\1 ' - cfg.gsub! /(Configuration last synchronized at).*/, '\\1 ' - cfg - end + cfg.gsub! /(Current configuration).*/, '\\1 ' + cfg.gsub! /(Configuration last updated at).*/, '\\1 ' + cfg.gsub! /(Configuration last saved at).*/, '\\1 ' + cfg.gsub! /(Configuration last synchronized at).*/, '\\1 ' + cfg + end cmd 'show running-config all-partitions' do |cfg| - cfg.gsub! /(Current configuration).*/, '\\1 ' - cfg.gsub! /(Configuration last updated at).*/, '\\1 ' - cfg.gsub! /(Configuration last saved at).*/, '\\1 ' - cfg.gsub! /(Configuration last synchronized at).*/, '\\1 ' - cfg + cfg.gsub! /(Current configuration).*/, '\\1 ' + cfg.gsub! /(Configuration last updated at).*/, '\\1 ' + cfg.gsub! /(Configuration last saved at).*/, '\\1 ' + cfg.gsub! /(Configuration last synchronized at).*/, '\\1 ' + cfg end cmd 'show aflex all-partitions' do |cfg| @@ -50,7 +50,7 @@ class ACOS < Oxidized::Model end cmd 'show aflex all-partitions' do |cfg| - @partitions_aflex = cfg.lines.each_with_object({}) do |l,h| + @partitions_aflex = cfg.lines.each_with_object({}) do |l, h| h[$1] = [] if l.match /partition: (.+)/ # only consider scripts that have passed syntax check h[h.keys.last] << $1 if l.match /^([\w-]+) +Check/ @@ -66,7 +66,7 @@ class ACOS < Oxidized::Model pre do unless @partitions_aflex.empty? out = [] - @partitions_aflex.each do |partition,arules| + @partitions_aflex.each do |partition, arules| out << "! partition: #{partition}" arules.each do |name| cmd("show aflex #{name} partition #{partition}") do |cfg| @@ -85,7 +85,7 @@ class ACOS < Oxidized::Model username /login:/ password /^Password:/ end - + cfg :telnet, :ssh do # preferred way to handle additional passwords post_login do @@ -98,5 +98,4 @@ class ACOS < Oxidized::Model post_login 'terminal width 0' pre_logout "exit\nexit\nY\r\n" end - end diff --git a/lib/oxidized/model/acsw.rb b/lib/oxidized/model/acsw.rb index 1aee2b6..c0857b3 100644 --- a/lib/oxidized/model/acsw.rb +++ b/lib/oxidized/model/acsw.rb @@ -1,5 +1,4 @@ class ACSW < Oxidized::Model - prompt /([\w.@()\/\\-]+[#>]\s?)/ comment '! ' @@ -25,16 +24,13 @@ class ACSW < Oxidized::Model cfg end - cmd 'show version' do |cfg| comment cfg end - - cmd 'show inventory' do |cfg| - comment cfg - end - + cmd 'show inventory' do |cfg| + comment cfg + end cmd 'show running-config' do |cfg| cfg = cfg.each_line.to_a[3..-1] @@ -63,5 +59,4 @@ class ACSW < Oxidized::Model post_login 'terminal length 0' pre_logout 'exit' end - end diff --git a/lib/oxidized/model/aen.rb b/lib/oxidized/model/aen.rb index 6d87433..474e6d5 100644 --- a/lib/oxidized/model/aen.rb +++ b/lib/oxidized/model/aen.rb @@ -16,5 +16,4 @@ class AEN < Oxidized::Model cfg :ssh do pre_logout 'exit' end - -end \ No newline at end of file +end diff --git a/lib/oxidized/model/aireos.rb b/lib/oxidized/model/aireos.rb index ba13120..a0378c7 100644 --- a/lib/oxidized/model/aireos.rb +++ b/lib/oxidized/model/aireos.rb @@ -1,17 +1,16 @@ class Aireos < Oxidized::Model - # AireOS (at least I think that is what it's called, hard to find data) # Used in Cisco WLC 5500 - comment '# ' ## this complains too, can't find real comment char + comment '# ' # this complains too, can't find real comment char prompt /^\([^\)]+\)\s>/ cmd :all do |cfg| cfg.each_line.to_a[1..-2].join end - ##show sysinfo? - ##show switchconfig? + # show sysinfo? + # show switchconfig? cmd 'show udi' do |cfg| cfg = comment clean cfg @@ -51,5 +50,4 @@ class Aireos < Oxidized::Model out = out.join "\n" out << "\n" end - end diff --git a/lib/oxidized/model/alteonos.rb b/lib/oxidized/model/alteonos.rb index 9eacf4e..dec4faf 100644 --- a/lib/oxidized/model/alteonos.rb +++ b/lib/oxidized/model/alteonos.rb @@ -1,5 +1,4 @@ class ALTEONOS < Oxidized::Model - prompt /^\(?.+\)?\s?[#>]/ comment '! ' @@ -11,19 +10,19 @@ class ALTEONOS < Oxidized::Model cfg end - ############################################################################################## - ## Added to remove # - ## # - ##/* Configuration dump taken 14:10:20 Fri Jul 28, 2017 (DST) # - ##/* Configuration last applied at 16:17:05 Fri Jul 14, 2017 # - ##/* Configuration last save at 16:17:43 Fri Jul 14, 2017 # - ##/* Version 29.0.3.12, vXXXXXXXX, Base MAC address XXXXXXXXXXX # - ##/* To restore SSL Offloading configuration and management HTTPS access, # - ##/* it is recommended to include the private keys in the dump. # - ## OR # - ##/* To restore SSL Offloading configuration and management HTTPS access,it is recommended # - ##/* to include the private keys in the dump. # - ## # + ############################################################################################## + # Added to remove # + # # + # /* Configuration dump taken 14:10:20 Fri Jul 28, 2017 (DST) # + # /* Configuration last applied at 16:17:05 Fri Jul 14, 2017 # + # /* Configuration last save at 16:17:43 Fri Jul 14, 2017 # + # /* Version 29.0.3.12, vXXXXXXXX, Base MAC address XXXXXXXXXXX # + # /* To restore SSL Offloading configuration and management HTTPS access, # + # /* it is recommended to include the private keys in the dump. # + # OR # + # /* To restore SSL Offloading configuration and management HTTPS access,it is recommended # + # /* to include the private keys in the dump. # + # # ############################################################################################## cmd 'cfg/dump' do |cfg| @@ -35,19 +34,19 @@ class ALTEONOS < Oxidized::Model cfg end - #Answer for Dispay private keys + # Answer for Dispay private keys expect /^Display private keys\?\s?\[y\/n\]\: $/ do |data, re| send "n\r" data.sub re, '' end - #Answer for sync to peer on exit + # Answer for sync to peer on exit expect /^Confirm Sync to Peer\s?\[y\/n\]\: $/ do |data, re| send "n\r" data.sub re, '' end - #Answer for Unsaved configuration + # Answer for Unsaved configuration expect /^(WARNING: There are unsaved configuration changes).*/ do |data, re| send "n\r" data.sub re, '' @@ -56,5 +55,4 @@ class ALTEONOS < Oxidized::Model cfg :ssh do pre_logout 'exit' end - end diff --git a/lib/oxidized/model/alvarion.rb b/lib/oxidized/model/alvarion.rb index 7a4dcc7..8831f49 100644 --- a/lib/oxidized/model/alvarion.rb +++ b/lib/oxidized/model/alvarion.rb @@ -1,5 +1,4 @@ class Alvarion < Oxidized::Model - # Used in Alvarion wisp equipment # Run this command as an instance of Model so we can access node @@ -7,9 +6,6 @@ class Alvarion < Oxidized::Model cmd "#{node.auth[:password]}.cfg" end - cfg :tftp do - end - end diff --git a/lib/oxidized/model/aos.rb b/lib/oxidized/model/aos.rb index ec73b92..fed78c8 100644 --- a/lib/oxidized/model/aos.rb +++ b/lib/oxidized/model/aos.rb @@ -1,8 +1,7 @@ class AOS < Oxidized::Model - # Alcatel-Lucent Operating System # used in OmniSwitch - + comment '! ' cmd :all do |cfg| @@ -10,7 +9,7 @@ class AOS < Oxidized::Model end cmd 'show system' do |cfg| - cfg = cfg.each_line.find{|line|line.match 'Description'} + cfg = cfg.each_line.find { |line| line.match 'Description' } comment cfg.to_s.strip end @@ -34,5 +33,4 @@ class AOS < Oxidized::Model cfg :telnet, :ssh do pre_logout 'exit' end - end diff --git a/lib/oxidized/model/aos7.rb b/lib/oxidized/model/aos7.rb index 8d11066..00bee54 100644 --- a/lib/oxidized/model/aos7.rb +++ b/lib/oxidized/model/aos7.rb @@ -1,8 +1,7 @@ class AOS7 < Oxidized::Model - # Alcatel-Lucent Operating System Version 7 (Linux based) # used in OmniSwitch 6900/10k - + comment '! ' cmd :all do |cfg, cmdstring| @@ -11,7 +10,7 @@ class AOS7 < Oxidized::Model end cmd 'show system' do |cfg| - cfg = cfg.each_line.find{|line|line.match 'Description'} + cfg = cfg.each_line.find { |line| line.match 'Description' } comment cfg.to_s.strip + "\n" end diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb index 3397305..7543353 100644 --- a/lib/oxidized/model/aosw.rb +++ b/lib/oxidized/model/aosw.rb @@ -1,14 +1,13 @@ class AOSW < Oxidized::Model - # AOSW Aruba Wireless, IAP, Instant Controller and Mobility Access Switches # Used in Alcatel OAW-4750 WLAN controller # Also Dell controllers - + # HPE Aruba Switches should use a different model as the software is based on the HP Procurve line. - + # Support for IAP & Instant Controller tested with 115, 205, 215 & 325 running 6.4.4.8-4.2.4.5_57965 # Support for Mobility Access Switches tested with S2500-48P & S2500-24P running 7.4.1.4_54199 and S2500-24P running 7.4.1.7_57823 - # All IAPs connected to a Instant Controller will have the same config output. Only the controller needs to be monitored. + # All IAPs connected to a Instant Controller will have the same config output. Only the controller needs to be monitored. comment '# ' prompt /^\(?.+\)?\s[#>]/ @@ -26,11 +25,11 @@ class AOSW < Oxidized::Model cfg.gsub!(/ sha (\S+)/, ' sha ') cfg.gsub!(/ des (\S+)/, ' des ') cfg.gsub!(/mobility-manager (\S+) user (\S+) (\S+)/, 'mobility-manager \1 user \2 ') - cfg.gsub!(/mgmt-user (\S+) (root|guest\-provisioning|network\-operations|read\-only|location\-api\-mgmt) (\S+)$/, 'mgmt-user \1 \2 ') #MAS & Wireless Controler - cfg.gsub!(/mgmt-user (\S+) (\S+)( (read\-only|guest\-mgmt))?$/, 'mgmt-user \1 \3') #IAP -#MAS format: mgmt-user -#IAP format (root user): mgmt-user -#IAP format: mgmt-user + cfg.gsub!(/mgmt-user (\S+) (root|guest\-provisioning|network\-operations|read\-only|location\-api\-mgmt) (\S+)$/, 'mgmt-user \1 \2 ') # MAS & Wireless Controler + cfg.gsub!(/mgmt-user (\S+) (\S+)( (read\-only|guest\-mgmt))?$/, 'mgmt-user \1 \3') # IAP + # MAS format: mgmt-user + # IAP format (root user): mgmt-user + # IAP format: mgmt-user cfg.gsub!(/key (\S+)$/, 'key ') cfg.gsub!(/wpa-passphrase (\S+)$/, 'wpa-passphrase ') cfg.gsub!(/bkup-passwords (\S+)$/, 'bkup-passwords ') @@ -45,17 +44,17 @@ class AOSW < Oxidized::Model end cmd 'show inventory' do |cfg| - cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices (IAP and MAS) + cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ # Don't show for unsupported devices (IAP and MAS) rstrip_cfg clean cfg end cmd 'show slots' do |cfg| - cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices (IAP and MAS) + cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ # Don't show for unsupported devices (IAP and MAS) rstrip_cfg comment cfg end cmd 'show license' do |cfg| - cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices (IAP and MAS) + cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ # Don't show for unsupported devices (IAP and MAS) rstrip_cfg comment cfg end @@ -112,5 +111,4 @@ class AOSW < Oxidized::Model out = comment out.join "\n" out << "\n" end - end diff --git a/lib/oxidized/model/apc_aos.rb b/lib/oxidized/model/apc_aos.rb index 530d436..5a4d232 100644 --- a/lib/oxidized/model/apc_aos.rb +++ b/lib/oxidized/model/apc_aos.rb @@ -1,11 +1,8 @@ class Apc_aos < Oxidized::Model - cmd 'config.ini' do |cfg| cfg.gsub! /^; Configuration file\, generated on.*/, '' end cfg :ftp do end - end - diff --git a/lib/oxidized/model/arbos.rb b/lib/oxidized/model/arbos.rb index 389f3f6..51b269d 100644 --- a/lib/oxidized/model/arbos.rb +++ b/lib/oxidized/model/arbos.rb @@ -1,9 +1,8 @@ -class ARBOS < Oxidized::Model - +class ARBOS < Oxidized::Model # Arbor OS model # prompt /^[\S\s]+\n([\w.@-]+[:\/#>]+)\s?$/ - comment '# ' + comment '# ' cmd 'system hardware' do |cfg| cfg.gsub! /^Boot\ time\:\s.+/, '' # Remove boot timer diff --git a/lib/oxidized/model/aricentiss.rb b/lib/oxidized/model/aricentiss.rb index 14f8502..77b78f4 100644 --- a/lib/oxidized/model/aricentiss.rb +++ b/lib/oxidized/model/aricentiss.rb @@ -4,7 +4,6 @@ # 0 SSE-G48-TG4 (P2-01) 1.0.16-9 class AricentISS < Oxidized::Model - prompt (/^(\e\[27m)?[ \r]*[\w-]+# ?$/) cfg :ssh do @@ -49,5 +48,4 @@ class AricentISS < Oxidized::Model l }.join.gsub(/ +$/, '') end - end diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb index bea0705..dfd94b1 100644 --- a/lib/oxidized/model/asa.rb +++ b/lib/oxidized/model/asa.rb @@ -1,5 +1,4 @@ class ASA < Oxidized::Model - # Cisco ASA model # # Only SSH supported for the sake of security @@ -54,48 +53,47 @@ class ASA < Oxidized::Model post_login 'terminal pager 0' pre_logout 'exit' end - + def single_context - # Single context mode - cmd 'more system:running-config' do |cfg| - cfg = cfg.each_line.to_a[3..-1].join - cfg.gsub! /^: [^\n]*\n/, '' - # backup any xml referenced in the configuration. - anyconnect_profiles = cfg.scan(Regexp.new('(\sdisk0:/.+\.xml)')).flatten - anyconnect_profiles.each do |profile| - cfg << (comment profile + "\n" ) - cmd ("more" + profile) do |xml| - cfg << (comment xml) - end + # Single context mode + cmd 'more system:running-config' do |cfg| + cfg = cfg.each_line.to_a[3..-1].join + cfg.gsub! /^: [^\n]*\n/, '' + # backup any xml referenced in the configuration. + anyconnect_profiles = cfg.scan(Regexp.new('(\sdisk0:/.+\.xml)')).flatten + anyconnect_profiles.each do |profile| + cfg << (comment profile + "\n") + cmd ("more" + profile) do |xml| + cfg << (comment xml) end - # if DAP is enabled, also backup dap.xml - if cfg.rindex(/dynamic-access-policy-record\s(?!DfltAccessPolicy)/) - cfg << (comment "disk0:/dap.xml\n") - cmd "more disk0:/dap.xml" do |xml| - cfg << (comment xml) - end + end + # if DAP is enabled, also backup dap.xml + if cfg.rindex(/dynamic-access-policy-record\s(?!DfltAccessPolicy)/) + cfg << (comment "disk0:/dap.xml\n") + cmd "more disk0:/dap.xml" do |xml| + cfg << (comment xml) end - cfg end + cfg + end end def multiple_context - # Multiple context mode - cmd 'changeto system' do |cfg| - cmd 'show running-config' do |systemcfg| - allcfg = "\n\n" + systemcfg + "\n\n" - contexts = systemcfg.scan(/^context (\S+)$/) - files = systemcfg.scan(/config-url (\S+)$/) - contexts.each_with_index do |cont, i| - allcfg = allcfg + "\n\n----------========== [ CONTEXT " + cont.join(" ") + " FILE " + files[i].join(" ") + " ] ==========----------\n\n" - cmd "more " + files[i].join(" ") do |cfgcontext| - allcfg = allcfg + "\n\n" + cfgcontext - end + # Multiple context mode + cmd 'changeto system' do |cfg| + cmd 'show running-config' do |systemcfg| + allcfg = "\n\n" + systemcfg + "\n\n" + contexts = systemcfg.scan(/^context (\S+)$/) + files = systemcfg.scan(/config-url (\S+)$/) + contexts.each_with_index do |cont, i| + allcfg = allcfg + "\n\n----------========== [ CONTEXT " + cont.join(" ") + " FILE " + files[i].join(" ") + " ] ==========----------\n\n" + cmd "more " + files[i].join(" ") do |cfgcontext| + allcfg = allcfg + "\n\n" + cfgcontext end - cfg = allcfg end - cfg + cfg = allcfg end + cfg + end end - end diff --git a/lib/oxidized/model/asyncos.rb b/lib/oxidized/model/asyncos.rb index ac19e34..2857ef8 100644 --- a/lib/oxidized/model/asyncos.rb +++ b/lib/oxidized/model/asyncos.rb @@ -1,28 +1,27 @@ class AsyncOS < Oxidized::Model - # ESA prompt "(mail.example.com)> " prompt /^\r*([(][\w. ]+[)][#>]\s+)$/ - comment '! ' - - # Select passphrase display option - expect /\[\S+\]>\s/ do |data, re| - send "3\n" + comment '! ' + + # Select passphrase display option + expect /\[\S+\]>\s/ do |data, re| + send "3\n" data.sub re, '' end - + # handle paging - expect /-Press Any Key For More-+.*$/ do |data, re| + expect /-Press Any Key For More-+.*$/ do |data, re| send " " data.sub re, '' end - + cmd 'version' do |cfg| comment cfg end cmd 'showconfig' do |cfg| - #Delete hour and date which change each run - #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' + # Delete hour and date which change each run + # cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' # Delete select passphrase display option cfg.gsub! /Choose the passphrase option:/, '' cfg.gsub! /1. Mask passphrases \(Files with masked passphrases cannot be loaded using/, '' @@ -30,20 +29,18 @@ class AsyncOS < Oxidized::Model cfg.gsub! /2. Encrypt passphrases/, '' cfg.gsub! /3. Plain passphrases/, '' cfg.gsub! /^3$/, '' - #Delete space - cfg.gsub! /\n\s{25,26}/, '' - #Delete after line - cfg.gsub! /([-\\\/,.\w><@]+)(\s{25,27})/,"\\1" - # Add a carriage return - cfg.gsub! /([-\\\/,.\w><@]+)(\s{6})([-\\\/,.\w><@]+)/,"\\1\n\\2\\3" + # Delete space + cfg.gsub! /\n\s{25,26}/, '' + # Delete after line + cfg.gsub! /([-\\\/,.\w><@]+)(\s{25,27})/, "\\1" + # Add a carriage return + cfg.gsub! /([-\\\/,.\w><@]+)(\s{6})([-\\\/,.\w><@]+)/, "\\1\n\\2\\3" # Delete prompt - cfg.gsub! /^\r*([(][\w. ]+[)][#>]\s+)$/, '' + cfg.gsub! /^\r*([(][\w. ]+[)][#>]\s+)$/, '' cfg - end - + cfg :ssh do pre_logout "exit" end - end diff --git a/lib/oxidized/model/audiocodes.rb b/lib/oxidized/model/audiocodes.rb index b7ee70e..2c77abb 100644 --- a/lib/oxidized/model/audiocodes.rb +++ b/lib/oxidized/model/audiocodes.rb @@ -1,20 +1,17 @@ class AudioCodes < Oxidized::Model - -# Pull config from AudioCodes Mediant devices from version > 7.0 + # Pull config from AudioCodes Mediant devices from version > 7.0 prompt /^\r?([\w.@() -]+[#>]\s?)$/ - comment '## ' + comment '## ' expect /\s*--MORE--$/ do |data, re| - send ' ' data.sub re, '' - end cmd 'show running-config' do |cfg| - cfg + cfg end cfg :ssh do @@ -22,11 +19,10 @@ class AudioCodes < Oxidized::Model password /^.+password:\s$/ pre_logout 'exit' end - + cfg :telnet do username /^Username:\s$/ password /^Password:\s$/ pre_logout 'exit' end - end diff --git a/lib/oxidized/model/awplus.rb b/lib/oxidized/model/awplus.rb index 1d8fbcd..7c88d60 100644 --- a/lib/oxidized/model/awplus.rb +++ b/lib/oxidized/model/awplus.rb @@ -1,27 +1,26 @@ class AWPlus < Oxidized::Model + # Allied Telesis Alliedware Plus Model# + # https://www.alliedtelesis.com/products/software/AlliedWare-Plus - #Allied Telesis Alliedware Plus Model# - #https://www.alliedtelesis.com/products/software/AlliedWare-Plus - prompt /^(\r?[\w.@:\/-]+[#>]\s?)$/ - comment '! ' + comment '! ' - #Avoids needing "term length 0" to display full config file. - expect /--More--/ do |data, re| - send ' ' - data.sub re, '' - end + # Avoids needing "term length 0" to display full config file. + expect /--More--/ do |data, re| + send ' ' + data.sub re, '' + end - #Removes gibberish pager output e.g. VT100 escape codes + # Removes gibberish pager output e.g. VT100 escape codes cmd :all do |cfg| cfg.gsub! /\e\[K/, '' # example how to handle pager - cleareol EL0 cfg.gsub! /\e\[7m\e\[m/, '' # example how to handle pager - Reverse SGR7 - cfg.gsub! /\r/, '' # Filters rogue ^M - see issue #415 + cfg.gsub! /\r/, '' # Filters rogue ^M - see issue #415 cfg.each_line.to_a[1..-2].join end - #Remove passwords from config file. - #Add vars "remove_secret: true" to global oxidized config file to enable. + # Remove passwords from config file. + # Add vars "remove_secret: true" to global oxidized config file to enable. cmd :secret do |cfg| cfg.gsub! /^(snmp-server community).*/, '\\1 ' @@ -34,52 +33,52 @@ class AWPlus < Oxidized::Model cfg end - #Adds "Show system" output to start of config. + # Adds "Show system" output to start of config. cmd 'Show System' do |cfg| - comment cfg.insert(0,"--------------------------------------------------------------------------------! \n") - #Unhash below to write a comment in the config file. - cfg.insert(0,"Starting: Show system cmd \n") + comment cfg.insert(0, "--------------------------------------------------------------------------------! \n") + # Unhash below to write a comment in the config file. + cfg.insert(0, "Starting: Show system cmd \n") cfg << "\n \nEnding: show system cmd" comment cfg << "\n--------------------------------------------------------------------------------! \n \n" - #Removes the following lines from "show system" in output file. This ensures oxidized diffs are meaningful. - comment cfg.each_line.reject { |line| - line.match /^$\n/ or #Remove blank lines in "sh sys" - line.match /System Status\s*.*/ or - line.match /RAM\s*:.*/ or - line.match /Uptime\s*:.*/ or - line.match /Flash\s*:.*/ or - line.match /Current software\s*:.*/ or - line.match /Software version\s*:.*/ or - line.match /Build date\s*:.*/ }.join + # Removes the following lines from "show system" in output file. This ensures oxidized diffs are meaningful. + comment cfg.each_line.reject { |line| + line.match /^$\n/ or # Remove blank lines in "sh sys" + line.match /System Status\s*.*/ or + line.match /RAM\s*:.*/ or + line.match /Uptime\s*:.*/ or + line.match /Flash\s*:.*/ or + line.match /Current software\s*:.*/ or + line.match /Software version\s*:.*/ or + line.match /Build date\s*:.*/ + } .join end - - #Actually get the devices running config# + + # Actually get the devices running config# cmd 'show running-config' do |cfg| cfg end - - #Config required for telnet to detect username prompt + + # Config required for telnet to detect username prompt cfg :telnet do username /login:\s/ - end + end - #Main login config - cfg :telnet, :ssh do + # Main login config + cfg :telnet, :ssh do post_login do if vars :enable send "enable\n" expect /^Password:\s/ cmd vars(:enable) + "\r\n" else - cmd 'enable' # Required for Priv-Exec users without enable PW to be put into "enable mode". + cmd 'enable' # Required for Priv-Exec users without enable PW to be put into "enable mode". end -# cmd 'terminal length 0' #set so the entire config is output without intervention. + # cmd 'terminal length 0' #set so the entire config is output without intervention. end pre_logout do -# cmd 'terminal no length' #Sets term length back to default on exit. - send "exit\r\n" + # cmd 'terminal no length' #Sets term length back to default on exit. + send "exit\r\n" end - end - + end end diff --git a/lib/oxidized/model/boss.rb b/lib/oxidized/model/boss.rb index 02201a1..cf762ee 100644 --- a/lib/oxidized/model/boss.rb +++ b/lib/oxidized/model/boss.rb @@ -16,7 +16,7 @@ class Boss < Oxidized::Model data.sub re, '' end - # Handle the Failed retries since last login + # Handle the Failed retries since last login # no known way to disable other than to implement radius authentication expect /Press ENTER to continue/ do |data, re| send "\n" @@ -29,7 +29,7 @@ class Boss < Oxidized::Model send "c" data.sub re, '' end - + # needed for proper formatting cmd('') { |cfg| comment "#{cfg}\n" } @@ -43,7 +43,7 @@ class Boss < Oxidized::Model cfg.gsub! /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} .*/, '' comment "#{cfg}\n" end - + # if a stack then collect the stacking information cmd 'show stack-info' do |cfg| if @stack @@ -72,5 +72,4 @@ class Boss < Oxidized::Model post_login 'terminal length 0' post_login 'terminal width 132' end - end diff --git a/lib/oxidized/model/br6910.rb b/lib/oxidized/model/br6910.rb index df93793..1e79da3 100644 --- a/lib/oxidized/model/br6910.rb +++ b/lib/oxidized/model/br6910.rb @@ -1,45 +1,43 @@ - -class BR6910 < Oxidized::Model - - prompt /^([\w.@()-]+[#>]\s?)$/ - comment '! ' - - # not possible to disable paging prior to show running-config - expect /^((.*)Others to exit ---(.*))$/ do |data, re| - send 'a' - data.sub re, '' - end - - cmd :all do |cfg| - # sometimes br6910s inserts arbitrary whitespace after commands are - # issued on the CLI, from run to run. this normalises the output. - cfg.each_line.to_a[1..-2].drop_while { |e| e.match /^\s+$/ }.join - end - - cmd 'show version' do |cfg| - comment cfg - end - - # show flash is not possible on a brocade 6910, do dir instead - # to see flash contents (includes config file names) - cmd 'dir' do |cfg| - comment cfg - end - - cmd 'show running-config' do |cfg| - arr = cfg.each_line.to_a - arr[2..-1].join unless arr.length < 2 - end - - cfg :telnet do - username /^Username:/ - password /^Password:/ - end - - # post login and post logout - cfg :telnet, :ssh do - post_login '' - pre_logout 'exit' - end - -end + +class BR6910 < Oxidized::Model + prompt /^([\w.@()-]+[#>]\s?)$/ + comment '! ' + + # not possible to disable paging prior to show running-config + expect /^((.*)Others to exit ---(.*))$/ do |data, re| + send 'a' + data.sub re, '' + end + + cmd :all do |cfg| + # sometimes br6910s inserts arbitrary whitespace after commands are + # issued on the CLI, from run to run. this normalises the output. + cfg.each_line.to_a[1..-2].drop_while { |e| e.match /^\s+$/ }.join + end + + cmd 'show version' do |cfg| + comment cfg + end + + # show flash is not possible on a brocade 6910, do dir instead + # to see flash contents (includes config file names) + cmd 'dir' do |cfg| + comment cfg + end + + cmd 'show running-config' do |cfg| + arr = cfg.each_line.to_a + arr[2..-1].join unless arr.length < 2 + end + + cfg :telnet do + username /^Username:/ + password /^Password:/ + end + + # post login and post logout + cfg :telnet, :ssh do + post_login '' + pre_logout 'exit' + end +end diff --git a/lib/oxidized/model/c4cmts.rb b/lib/oxidized/model/c4cmts.rb index 150029c..8ea27c6 100644 --- a/lib/oxidized/model/c4cmts.rb +++ b/lib/oxidized/model/c4cmts.rb @@ -1,15 +1,14 @@ class C4CMTS < Oxidized::Model - # Arris C4 CMTS prompt /^([\w.@:\/-]+[#>]\s?)$/ comment '! ' cmd :all do |cfg| - cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n" + cfg.each_line.to_a[1..-2].map { |line| line.delete("\r").rstrip }.join("\n") + "\n" end - cmd :secret do |cfg| + cmd :secret do |cfg| cfg.gsub! /(.+)\s+encrypted-password\s+\w+\s+(.*)/, '\\1