diff options
-rw-r--r-- | Gemfile.lock | 18 | ||||
-rw-r--r-- | README.md | 37 | ||||
-rwxr-xr-x | extra/oxidized-report-git-commits | 61 | ||||
-rw-r--r-- | lib/oxidized/model/asa.rb | 71 | ||||
-rw-r--r-- | lib/oxidized/model/dlink.rb | 1 | ||||
-rw-r--r-- | lib/oxidized/model/ironware.rb | 3 | ||||
-rw-r--r-- | lib/oxidized/model/planet.rb | 3 | ||||
-rw-r--r-- | lib/oxidized/model/procurve.rb | 13 |
8 files changed, 139 insertions, 68 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 2c887c1..229a55c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,10 @@ PATH remote: . specs: - oxidized (0.18.0) + oxidized (0.20.0) asetus (~> 0.1) net-ssh (~> 3.0.2) - net-telnet + net-telnet (~> 0) rugged (~> 0.21, >= 0.21.4) slop (~> 3.5) @@ -12,20 +12,20 @@ GEM remote: https://rubygems.org/ specs: asetus (0.3.0) - coderay (1.1.0) + coderay (1.1.1) + git (1.3.0) metaclass (0.0.4) method_source (0.8.2) - minitest (5.9.0) - mocha (1.1.0) + minitest (5.10.1) + mocha (1.2.1) metaclass (~> 0.0.1) net-ssh (3.0.2) net-telnet (0.1.1) - pry (0.10.3) + pry (0.11.0.pre2) coderay (~> 1.1.0) method_source (~> 0.8.1) - slop (~> 3.4) rake (10.5.0) - rugged (0.23.3) + rugged (0.25.1.1) slop (3.6.0) PLATFORMS @@ -41,4 +41,4 @@ DEPENDENCIES rake (~> 10.0) BUNDLED WITH - 1.11.2 + 1.14.6 @@ -1,5 +1,9 @@ # 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!** + +[WANTED: MAINTAINER](#help-needed) + Oxidized is a network device configuration backup tool. It's a RANCID replacement! * automatically adds/removes threads to meet configured retrieval interval @@ -1075,6 +1079,39 @@ The following objects exist in Oxidized. * 'junos', 'ios', 'ironware' and 'powerconnect' implemented +# 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 +helped further the software, however contributions are not the same as ongoing +owner- and maintainership. It appears that many companies use the software to +manage their network infrastructure, this is great news! But without additional +help to maintain the software and put out releases, the future of oxidized +might be less bright. The current pace of development and the much needed +refactoring simply are not sustainable if they are to be driven by a single +person. + +## Maintainer duties and expectations + +* 4 hours per week to perform triage on issues, review pull requests and help answer any questions from users. +* Above average knowledge of the Ruby programming language. +* Professional experience with both oxidized and some other config backup tool (like rancid). +* Ability to keep a cool head, and enjoy interaction with end users! :) +* A desire and passion to help drive `oxidized` towards its `1.x.x` stage of life + * help refactor the code + * rework the core infrastructure +* Permission from your employer to contribute to open source projects + +## YES, I WANT TO HELP + +Awesome! Simply send an email to Saku Ytti <saku@ytti.fi>. + +## Further reading + +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 Copyright 2013-2015 Saku Ytti <saku@ytti.fi> diff --git a/extra/oxidized-report-git-commits b/extra/oxidized-report-git-commits index 2fd4870..db36ecf 100755 --- a/extra/oxidized-report-git-commits +++ b/extra/oxidized-report-git-commits @@ -17,64 +17,45 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# 20170615 - Andre Sencioles <asenci@gmail.com> +# Removed requirement for Git working directory +# Check job status +# +# # usage: add the following hook to the oxidized config file: # # hooks: # email_output: # type: exec # events: [post_store, node_fail] -# cmd: '/home/oxidized/extra/oxidized-report-git-commits ~/gitdir/ | mail -s "Oxidized updates for ${OX_NODE_NAME}" update-recipient@example.com' +# cmd: '/home/oxidized/extra/oxidized-report-git-commits | mail -s "Oxidized updates for ${OX_NODE_NAME}" update-recipient@example.com' # async: true # timeout: 120 # # -# The script takes a single argument, namely a git working directory name, -# e.g. "~/gitdir/". This is only used as a staging directory and should -# not be set to be the same as the git repo directory. -# -PATH=${PATH}:/usr/local/bin:/usr/local/sbin -export PATH +echo "Node name: ${OX_NODE_NAME}" +echo "Group name: ${OX_NODE_GROUP}" +echo "Job status: ${OX_JOB_STATUS}" +echo "Job time: ${OX_JOB_TIME}" -gitdir=$1 +if [ "${OX_EVENT}" = "node_fail" ]; then + echo 'Job failed' + exit 64 +fi -if [ X${OX_REPO_COMMITREF} = "X" ]; then - echo \$OX_REPO_COMMITREF not set +if [ -z "${OX_REPO_COMMITREF}" ]; then + echo '$OX_REPO_COMMITREF not set' exit 64 fi -if [ X${OX_REPO_NAME} = "X" ]; then - echo \$OX_REPO_NAME not set +if [ -z "${OX_REPO_NAME}" ]; then + echo '$OX_REPO_NAME not set' exit 64 fi -if [ ! -d ${gitdir}/.git ]; then - git clone -q ${OX_REPO_NAME} ${gitdir} - - ret=$? - if [ X"${ret}" != X0 ] && [ X"${ret}" != X1 ]; then - echo git clone failed: aborting. - exit 128 - fi -fi - -cd ${gitdir} - -git pull -q > /dev/null 2>&1 -ret=$? -if [ X"${ret}" != X0 ] && [ X"${ret}" != X1 ]; then - echo git pull failed: aborting. - exit 128 -fi - -# Git is probably working at this stage, so safe to emit more info - -echo "Node name: ${OX_NODE_NAME}" -echo "Group Name: ${OX_NODE_GROUP}" -echo "Job Time: ${OX_JOB_TIME}" -echo "Git Commit ID: ${OX_REPO_COMMITREF}" -echo "Git Repo: ${OX_REPO_NAME}" -echo "Local working dir: ${gitdir}" +echo "Git repo: ${OX_REPO_NAME}" +echo "Git commit ID: ${OX_REPO_COMMITREF}" echo "" -git diff --no-color ${OX_REPO_COMMITREF}~1..${OX_REPO_COMMITREF} +git --bare --git-dir="${OX_REPO_NAME}" diff --no-color "${OX_REPO_COMMITREF}~1..${OX_REPO_COMMITREF}" diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb index 038dd6b..9df4206 100644 --- a/lib/oxidized/model/asa.rb +++ b/lib/oxidized/model/asa.rb @@ -20,6 +20,11 @@ class ASA < Oxidized::Model cfg end + # check for multiple contexts + cmd 'show mode' do |cfg| + @is_multiple_context = cfg.include? 'multiple' + end + 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.*)/ } @@ -31,25 +36,12 @@ class ASA < Oxidized::Model comment cfg end - 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 + post do + if @is_multiple_context + multiple_context + else + single_context 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 - cfg end cfg :ssh do @@ -62,5 +54,48 @@ 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 + 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 + 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 + end + cfg = allcfg + end + cfg + end + end end diff --git a/lib/oxidized/model/dlink.rb b/lib/oxidized/model/dlink.rb index 5756bad..0d08793 100644 --- a/lib/oxidized/model/dlink.rb +++ b/lib/oxidized/model/dlink.rb @@ -15,6 +15,7 @@ class Dlink < Oxidized::Model end cmd 'show switch' do |cfg| + cfg.gsub! /^System\ Uptime\s.+/, '' # Omit constantly changing uptime info comment cfg end diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb index 9715c65..3ab8da1 100644 --- a/lib/oxidized/model/ironware.rb +++ b/lib/oxidized/model/ironware.rb @@ -34,6 +34,8 @@ class IronWare < Oxidized::Model cfg.gsub! /(^((.*)Current temp(.*))$)/, '' #remove unwanted lines current temperature cfg.gsub! /Speed = [A-Z-]{2,6} \(\d{2,3}\%\)/, '' #remove unwanted lines Speed Fans cfg.gsub! /current speed is [A-Z]{2,6} \(\d{2,3}\%\)/, '' + cfg.gsub! /Fan \d* - STATUS: OK \D*\d*./, '' # Fix for ADX Fan speed reporting + cfg.gsub! /\d* deg C/, '' # Fix for ADX temperature reporting cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, '' cfg.gsub! /\d{2}\.\d deg-C/, 'XX.X deg-C' if cfg.include? "TEMPERATURE" @@ -50,6 +52,7 @@ class IronWare < Oxidized::Model end cmd 'show flash' do |cfg| + cfg.gsub! /(\d+) bytes/, '' # Fix for ADX flash size comment cfg end diff --git a/lib/oxidized/model/planet.rb b/lib/oxidized/model/planet.rb index 05a369a..9ce9cf9 100644 --- a/lib/oxidized/model/planet.rb +++ b/lib/oxidized/model/planet.rb @@ -39,9 +39,10 @@ class Planet < Oxidized::Model cfg = cfg.each_line.to_a[0...-2] - # Strip system time and system uptime from planet gs switches + # Strip system (up)time and temperature cfg = cfg.reject { |line| line.match /System Time\s*:.*/ } cfg = cfg.reject { |line| line.match /System Uptime\s*:.*/ } + cfg = cfg.reject { |line| line.match /Temperature\s*:.*/ } comment cfg.join end diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 7dcf1fd..180b703 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -30,6 +30,7 @@ class Procurve < Oxidized::Model cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>' cfg.gsub! /^(snmp-server host).*/, '\\1 <configuration removed>' cfg.gsub! /^(radius-server host).*/, '\\1 <configuration removed>' + cfg.gsub! /^(radius-server key).*/, '\\1 <configuration removed>' cfg end @@ -37,6 +38,18 @@ class Procurve < Oxidized::Model comment cfg end + cmd 'show modules' do |cfg| + comment cfg + end + + cmd 'show interfaces transceiver' do |cfg| + comment cfg + end + + cmd 'show flash' do |cfg| + comment cfg + end + # not supported on all models cmd 'show system-information' do |cfg| cfg = cfg.split("\n")[0..-8].join("\n") |