diff options
author | Samer Abdel-Hafez <sam@arahant.net> | 2013-10-25 15:00:13 -0700 |
---|---|---|
committer | Samer Abdel-Hafez <sam@arahant.net> | 2013-10-25 15:00:13 -0700 |
commit | 056ecb1a94d24085497d1baa304645390052e50b (patch) | |
tree | 96764af0bcc7980c66779f7ef42e832df88982d5 /lib/oxidized | |
parent | feba4c2b9e0faeb40cad32f16d7b024a2d4327ae (diff) | |
parent | 4455a5b91accda5da7c1b8128cb045c7eb7bb5da (diff) |
Merge pull request #1 from ytti/master
update local branch
Diffstat (limited to 'lib/oxidized')
-rw-r--r-- | lib/oxidized/input/ssh.rb | 2 | ||||
-rw-r--r-- | lib/oxidized/input/telnet.rb | 2 | ||||
-rw-r--r-- | lib/oxidized/model/ios.rb | 14 | ||||
-rw-r--r-- | lib/oxidized/nodes.rb | 28 |
4 files changed, 30 insertions, 16 deletions
diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index c0594db..dc90354 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -39,7 +39,7 @@ module Oxidized disconnect_cli @ssh.loop @ssh.close if not @ssh.closed? - rescue Net::SSH::Disconnect + rescue Errno::ECONNRESET, Net::SSH::Disconnect end end diff --git a/lib/oxidized/input/telnet.rb b/lib/oxidized/input/telnet.rb index c4c8bab..26755ca 100644 --- a/lib/oxidized/input/telnet.rb +++ b/lib/oxidized/input/telnet.rb @@ -17,7 +17,7 @@ module Oxidized expect password @telnet.puts @node.auth[:password] expect @node.prompt - rescue Timeout::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTUNREACH + rescue Timeout::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EPIPE, Errno::EHOSTUNREACH return false end end diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb index 3fcc7ae..a216126 100644 --- a/lib/oxidized/model/ios.rb +++ b/lib/oxidized/model/ios.rb @@ -23,7 +23,11 @@ class IOS < Oxidized::Model cmd 'show running-config' do |cfg| cfg = cfg.each_line.to_a[3..-1].join + cfg.gsub! /^Current configuration : [^\n]*\n/, '' cfg.sub! /^(ntp clock-period).*/, '! \1' + cfg.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]*\n*( + (?:\ [^\n]*\n*)* + tunnel\ mpls\ traffic-eng\ auto-bw)/mx, '\1' cfg end @@ -40,10 +44,12 @@ class IOS < Oxidized::Model post_login 'terminal length 0' post_login 'terminal width 0' # preferred way to handle additional passwords - #post_login do - # send "enable\n" - # send CFG.vars[:enable] + "\n" - #end + if CFG.vars[:enable] and CFG.vars[:enable] != '' + post_login do + send "enable\n" + send CFG.vars[:enable] + "\n" + end + end pre_logout 'exit' end diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index d878d89..affeea8 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -1,6 +1,7 @@ module Oxidized require 'oxidized/node' class Oxidized::NotSupported < StandardError; end + class Oxidized::NodeNotFound < StandardError; end class Nodes < Array attr_accessor :source alias :put :unshift @@ -20,21 +21,18 @@ module Oxidized def list map { |e| e.name } end - def find_index node - index { |e| e.name == node } - end def show node - i = find_index node - self[i].serialize if i + i = find_node_index node + self[i].serialize end def fetch node, group - raise Oxidized::NotSupported unless Oxidized.mgr.output.respond_to? :fetch - i = find_index node - self[i].output.new.fetch node, group + i = find_node_index node + output = self[i].output.new + raise Oxidized::NotSupported unless output.respond_to? :fetch + output.fetch node, group end def del node - i = find_index node - delete_at i if i + delete_at find_node_index end # @param node [String] name of the node moved into the head of array def next node, opt={} @@ -52,5 +50,15 @@ module Oxidized def get (self << shift).last end + + private + + def find_index node + index { |e| e.name == node } + end + + def find_node_index node + find_index node or raise Oxidized::NodeNotFound + end end end |