From f061f2752539da60ae894ba42ed567df7155314b Mon Sep 17 00:00:00 2001 From: Harm van Tilborg Date: Tue, 27 Oct 2015 09:52:10 +0100 Subject: Typo in Brocade NOS model --- lib/oxidized/model/nos.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/model/nos.rb b/lib/oxidized/model/nos.rb index c2f4319..18ca6a2 100644 --- a/lib/oxidized/model/nos.rb +++ b/lib/oxidized/model/nos.rb @@ -26,7 +26,7 @@ class NOS < Oxidized::Model end cfg 'show system' do |cfg| - commen cfg.each_line.reject { |line| line.match /Time/ or line.match /speed/ } + comment cfg.each_line.reject { |line| line.match /Time/ or line.match /speed/ } end cmd 'show running-config' -- cgit v1.2.1 From a9996e8115bafd9837672c26dc9b76cbf3696840 Mon Sep 17 00:00:00 2001 From: Marno van der Molen Date: Tue, 3 Nov 2015 08:08:22 +0100 Subject: Adds optional debug output when loading hosts (resolving DNS) --- lib/oxidized/node.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/oxidized') diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index d50317f..c847416 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -9,6 +9,9 @@ module Oxidized attr_accessor :running, :user, :msg, :from, :stats, :retry alias :running? :running def initialize opt + if CFG.debug == true or opt[:debug] == true + puts 'resolving DNS for %s...' % opt[:name] + end @name = opt[:name] @ip = IPAddr.new(opt[:ip]).to_s rescue nil @ip ||= Resolv.new.getaddress @name -- cgit v1.2.1 From f04ada741166c7c2cd5f9eee29a89127fab1f328 Mon Sep 17 00:00:00 2001 From: Marno van der Molen Date: Tue, 3 Nov 2015 08:30:44 +0100 Subject: Log crashes on node name instead of ip to ease troubleshooting --- lib/oxidized/node.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index c847416..974b2d1 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -70,7 +70,7 @@ module Oxidized Log.send(level, '%s raised %s%s with msg "%s"' % [self.ip, err.class, resc, err.message]) return false rescue => err - file = Oxidized::Config::Crash + '.' + self.ip.to_s + file = Oxidized::Config::Crash + '.' + opt[:name] open file, 'w' do |fh| fh.puts Time.now.utc fh.puts err.message + ' [' + err.class.to_s + ']' -- cgit v1.2.1 From dc5f7285c87dc45763a24636a95c4081552356de Mon Sep 17 00:00:00 2001 From: Marno van der Molen Date: Tue, 3 Nov 2015 09:46:41 +0100 Subject: Revert crash logging on fqdn - seems to crash oxidized... --- lib/oxidized/node.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index 974b2d1..c847416 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -70,7 +70,7 @@ module Oxidized Log.send(level, '%s raised %s%s with msg "%s"' % [self.ip, err.class, resc, err.message]) return false rescue => err - file = Oxidized::Config::Crash + '.' + opt[:name] + file = Oxidized::Config::Crash + '.' + self.ip.to_s open file, 'w' do |fh| fh.puts Time.now.utc fh.puts err.message + ' [' + err.class.to_s + ']' -- cgit v1.2.1 From cb9f02548bbef0bdeb28a595031b700972bc7d1c Mon Sep 17 00:00:00 2001 From: Jeff Groom Date: Mon, 23 Nov 2015 18:12:14 +1300 Subject: added support for Ciena SOAS 6.x device type --- lib/oxidized/model/saos.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/oxidized/model/saos.rb (limited to 'lib/oxidized') diff --git a/lib/oxidized/model/saos.rb b/lib/oxidized/model/saos.rb new file mode 100644 index 0000000..cada35b --- /dev/null +++ b/lib/oxidized/model/saos.rb @@ -0,0 +1,24 @@ +class SAOS < Oxidized::Model + + # Ciena SAOS switch + # used for 6.x devices + + comment '! ' + + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].join + end + + cmd 'configuration show' do |cfg| + cfg + end + + cfg :telnet do + username /login:/ + password /assword:/ + end + cfg :telnet do + post_login 'system shell session set more off' + pre_logout 'exit' + end +end \ No newline at end of file -- cgit v1.2.1 From 96d2efa8ed31e1ea22674c3195c589eb15d584dc Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Wed, 25 Nov 2015 11:16:48 +0200 Subject: add placeholder 'version' method for file output --- lib/oxidized/output/file.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/oxidized') diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb index 38c9917..3326a32 100644 --- a/lib/oxidized/output/file.rb +++ b/lib/oxidized/output/file.rb @@ -39,5 +39,9 @@ class OxidizedFile < Output end end + def version node, group + 'not implemented for file output' + end + end end -- cgit v1.2.1 From 4e23b4341cec6a1c4e7526bd3acafbe66c624fc5 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Tue, 1 Dec 2015 11:21:47 +0200 Subject: meh further hack not to barf on version for files --- lib/oxidized/output/file.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb index 3326a32..d1a8c17 100644 --- a/lib/oxidized/output/file.rb +++ b/lib/oxidized/output/file.rb @@ -40,7 +40,12 @@ class OxidizedFile < Output end def version node, group - 'not implemented for file output' + # not supported + [] + end + + def get_version node, group, oid + 'not supported' end end -- cgit v1.2.1 From 9d2ca3d1cb51cdddef45f584aa6c98e8e600f3b6 Mon Sep 17 00:00:00 2001 From: MrRJ45 Date: Thu, 17 Dec 2015 16:06:43 +0000 Subject: Identify Stackable Switches Change how we identify stackable switches using the word "Unit" to identify this. This is more reliable than identifying the Model number. --- lib/oxidized/model/powerconnect.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb index ec15402..cd04766 100644 --- a/lib/oxidized/model/powerconnect.rb +++ b/lib/oxidized/model/powerconnect.rb @@ -14,6 +14,9 @@ class PowerConnect < Oxidized::Model end cmd 'show version' do |cfg| + if (@stackable.nil?) + @stackable = true if cfg.match /(U|u)nit\s/ + end cfg = cfg.split("\n").select { |line| not line[/Up\sTime/] } comment cfg.join("\n") + "\n" end @@ -47,15 +50,17 @@ class PowerConnect < Oxidized::Model def clean cfg out = [] - skip_block = false + skip_blocks = 0 cfg.each_line do |line| - if line.match /Up\sTime|Temperature|Power Supplies/i - # For 34xx, 35xx, 54xx, 55xx, 62xx and 8024F we should skip this block (terminated by a blank line) - skip_block = true if @model =~ /^(34|35)(24|48)$|^(54|55)(24|48)$|^(62)(24|48)$|^8024$/ + # If this is a stackable switch we should skip this block of information + if (line.match /Up\sTime|Temperature|Power Suppl(ies|y)|Fans/i and @stackable == true) + skip_blocks = 1 + # Some switches have another empty line. This is identified by this line having a colon + skip_blocks = 2 if line.match /:/ end # If we have lines to skip do this until we reach and empty line - if skip_block - skip_block = false if /\S/ !~ line + if skip_blocks > 0 + skip_blocks -= 1 if /\S/ !~ line next end out << line.strip -- cgit v1.2.1 From 8e6d2d15dfcbfd01547ac33ba78f7e88ba3ef292 Mon Sep 17 00:00:00 2001 From: asynet Date: Mon, 21 Dec 2015 21:39:29 +0000 Subject: Update fortios.rb Changing the regex makes possible to backup devices with FortiOS 4.x and long names --- lib/oxidized/model/fortios.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb index 2c796cb..a9d219c 100644 --- a/lib/oxidized/model/fortios.rb +++ b/lib/oxidized/model/fortios.rb @@ -2,7 +2,7 @@ class FortiOS < Oxidized::Model comment '# ' - prompt /^([-\w\.]+(\s[\(\w\-\.\)]+)?\s?[#>]\s?)$/ + prompt /^([-\w\.]+(\s[\(\w\-\.\)]+)?\~?\s?[#>]\s?)$/ cmd :all do |cfg, cmdstring| new_cfg = comment "COMMAND: #{cmdstring}\n" -- cgit v1.2.1 From 201c02551d96a070f8d55936aba350f772649465 Mon Sep 17 00:00:00 2001 From: Nick Hilliard Date: Sun, 27 Dec 2015 18:19:36 +0000 Subject: expose git repo name and commit oid in hook mechanism and environment variables --- lib/oxidized/hook/exec.rb | 2 ++ lib/oxidized/node.rb | 3 ++- lib/oxidized/output/file.rb | 3 +++ lib/oxidized/output/git.rb | 7 +++++-- lib/oxidized/worker.rb | 6 ++++-- 5 files changed, 16 insertions(+), 5 deletions(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/hook/exec.rb b/lib/oxidized/hook/exec.rb index af2aeb1..58d6fd5 100644 --- a/lib/oxidized/hook/exec.rb +++ b/lib/oxidized/hook/exec.rb @@ -71,6 +71,8 @@ class Exec < Oxidized::Hook "OX_NODE_MSG" => ctx.node.msg.to_s, "OX_NODE_GROUP" => ctx.node.group.to_s, "OX_EVENT" => ctx.event.to_s, + "OX_REPO_COMMITREF" => ctx.commitref.to_s, + "OX_REPO_NAME" => ctx.node.repo.to_s, ) end if ctx.job diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index c847416..df5b830 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -5,7 +5,7 @@ module Oxidized class MethodNotFound < OxidizedError; end class ModelNotFound < OxidizedError; end class Node - attr_reader :name, :ip, :model, :input, :output, :group, :auth, :prompt, :vars, :last + attr_reader :name, :ip, :model, :input, :output, :group, :auth, :prompt, :vars, :last, :repo attr_accessor :running, :user, :msg, :from, :stats, :retry alias :running? :running def initialize opt @@ -24,6 +24,7 @@ module Oxidized @vars = opt[:vars] @stats = Stats.new @retry = 0 + @repo = CFG.output.git.repo # model instance needs to access node instance @model.node = self diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb index d1a8c17..eb915c3 100644 --- a/lib/oxidized/output/file.rb +++ b/lib/oxidized/output/file.rb @@ -2,6 +2,8 @@ module Oxidized class OxidizedFile < Output require 'fileutils' + attr_reader :commitref + def initialize @cfg = CFG.output.file end @@ -22,6 +24,7 @@ class OxidizedFile < Output FileUtils.mkdir_p file file = File.join file, node open(file, 'w') { |fh| fh.write outputs.to_cfg } + @commitref = file end def fetch node, group diff --git a/lib/oxidized/output/git.rb b/lib/oxidized/output/git.rb index 3757cfc..fff3941 100644 --- a/lib/oxidized/output/git.rb +++ b/lib/oxidized/output/git.rb @@ -7,6 +7,8 @@ class Git < Output raise OxidizedError, 'rugged not found: sudo gem install rugged' end + attr_reader :commitref + def initialize @cfg = CFG.output.git end @@ -27,6 +29,7 @@ class Git < Output @user = (opt[:user] or @cfg.user) @email = (opt[:email] or @cfg.email) @opt = opt + @commitref = nil repo = @cfg.repo outputs.types.each do |type| @@ -63,7 +66,7 @@ class Git < Output end end - #give a hash of all oid revision for the givin node, and the date of the commit + #give a hash of all oid revision for the given node, and the date of the commit def version node, group begin repo = @cfg.repo @@ -176,7 +179,7 @@ class Git < Output if tree_old != tree_new repo.config['user.name'] = user repo.config['user.email'] = email - Rugged::Commit.create(repo, + @commitref = Rugged::Commit.create(repo, :tree => index.write_tree(repo), :message => msg, :parents => repo.empty? ? [] : [repo.head.target].compact, diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index eea747e..c886a5b 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -39,11 +39,13 @@ module Oxidized msg = "update #{node.name}" msg += " from #{node.from}" if node.from msg += " with message '#{node.msg}'" if node.msg - if node.output.new.store node.name, job.config, + output = node.output.new + if output.store node.name, job.config, :msg => msg, :user => node.user, :group => node.group Log.info "Configuration updated for #{node.group}/#{node.name}" Oxidized.Hooks.handle :post_store, :node => node, - :job => job + :job => job, + :commitref => output.commitref end node.reset else -- cgit v1.2.1 From 6e72e399626c0abb4cff7cea3d96505d4971e646 Mon Sep 17 00:00:00 2001 From: Tyler Christiansen Date: Tue, 29 Dec 2015 23:14:30 -0800 Subject: Fix groups vars. Fixes ytti/oxidized#242. Fixes ytti/oxidized-web#38. Added a check to verify the key exists for a group before returning. Might fic a group issue in ytti/oxidized#171. --- lib/oxidized/config/vars.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/config/vars.rb b/lib/oxidized/config/vars.rb index b39e7fe..b0471f2 100644 --- a/lib/oxidized/config/vars.rb +++ b/lib/oxidized/config/vars.rb @@ -2,9 +2,14 @@ module Oxidized::Config::Vars # convenience method for accessing node, group or global level user variables # nil values will be ignored def vars name - r = @node.vars[name] unless @node.vars.nil? - r ||= Oxidized::CFG.groups[@node.group].vars[name.to_s] if Oxidized::CFG.groups.has_key?(@node.group) + r = @node.vars[name] unless @node.vars.nil? + if Oxidized::CFG.groups.has_key?(@node.group) + if Oxidized::CFG.groups[@node.group].vars.has_key?(name.to_s) + r ||= Oxidized::CFG.groups[@node.group].vars[name.to_s] + end + end r ||= Oxidized::CFG.vars[name.to_s] if Oxidized::CFG.vars.has_key?(name.to_s) r end end + -- cgit v1.2.1 From 1ee130b83a28f822cdc3379c24d4965ceee86034 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Mon, 4 Jan 2016 10:24:46 -0500 Subject: merge version --- lib/oxidized/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/version.rb b/lib/oxidized/version.rb index c2a0c0e..38772b7 100644 --- a/lib/oxidized/version.rb +++ b/lib/oxidized/version.rb @@ -1,3 +1,3 @@ module Oxidized - VERSION = '0.8.1' + VERSION = '0.9.0' end -- cgit v1.2.1