diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/oxidized/input/ssh.rb | 5 | ||||
-rw-r--r-- | lib/oxidized/model/xos.rb | 5 | ||||
-rw-r--r-- | lib/oxidized/model/zynoscli.rb | 36 | ||||
-rw-r--r-- | lib/oxidized/nodes.rb | 3 | ||||
-rw-r--r-- | lib/oxidized/source/http.rb | 8 | ||||
-rw-r--r-- | lib/oxidized/source/sql.rb | 7 | ||||
-rw-r--r-- | lib/oxidized/worker.rb | 6 |
7 files changed, 63 insertions, 7 deletions
diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index dc1eb27..6e86d13 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -29,11 +29,14 @@ module Oxidized port: port.to_i, paranoid: secure, keepalive: true, - auth_methods: %w(none publickey password keyboard-interactive), password: @node.auth[:password], :timeout => Oxidized.config.timeout, number_of_password_prompts: 0, } + auth_methods = vars(:auth_methods) || %w(none publickey password) + ssh_opts[:auth_methods] = auth_methods + Oxidized.logger.info "AUTH METHODS::#{auth_methods}" + if proxy_host = vars(:ssh_proxy) proxy_command = "ssh " proxy_command += "-o StrictHostKeyChecking=no " unless secure diff --git a/lib/oxidized/model/xos.rb b/lib/oxidized/model/xos.rb index e862596..5ce8017 100644 --- a/lib/oxidized/model/xos.rb +++ b/lib/oxidized/model/xos.rb @@ -26,7 +26,10 @@ class XOS < Oxidized::Model comment cfg.each_line.reject { |line| line.match /Time:/ or line.match /boot/i }.join end - cmd 'show configuration' + cmd 'show configuration' do |cfg| + cfg = cfg.each_line.reject { |line| line.match /^#(\s[\w]+\s)(Configuration generated)/ }.join + cfg + end cmd 'show policy detail' do |cfg| comment cfg diff --git a/lib/oxidized/model/zynoscli.rb b/lib/oxidized/model/zynoscli.rb new file mode 100644 index 0000000..ae64b04 --- /dev/null +++ b/lib/oxidized/model/zynoscli.rb @@ -0,0 +1,36 @@ +class ZyNOSCLI < Oxidized::Model + # Used in Zyxel DSLAMs, such as SAM1316 + + # Typical prompt "XGS4600#" + prompt /^([\w.@()-]+[#>]\s\e7)$/ + comment ';; ' + + cmd :all do |cfg| + cfg.gsub! /^.*\e7/, '' + end + cmd 'show stacking' + + cmd 'show version' + + cmd 'show running-config' + + cfg :telnet do + username /^User name:/i + password /^Password:/i + end + + cfg :telnet, :ssh do + if vars :enable + post_login do + send "enable\n" + # Interpret enable: true as meaning we won't be prompted for a password + unless vars(:enable).is_a? TrueClass + expect /[pP]assword:\s?$/ + send vars(:enable) + "\n" + end + expect /^.+[#]$/ + end + end + pre_logout 'exit' + end +end diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index 84766f0..a159b48 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -12,7 +12,8 @@ module Oxidized @source = Oxidized.config.source.default Oxidized.mgr.add_source @source Oxidized.logger.info "lib/oxidized/nodes.rb: Loading nodes" - Oxidized.mgr.source[@source].new.load.each do |node| + nodes = Oxidized.mgr.source[@source].new.load node_want + nodes.each do |node| # we want to load specific node(s), not all of them next unless node_want? node_want, node begin diff --git a/lib/oxidized/source/http.rb b/lib/oxidized/source/http.rb index 4480cbb..55dcd4c 100644 --- a/lib/oxidized/source/http.rb +++ b/lib/oxidized/source/http.rb @@ -15,7 +15,7 @@ module Oxidized require "uri" require "json" - def load + def load node_want = nil nodes = [] uri = URI.parse(@cfg.url) http = Net::HTTP.new(uri.host, uri.port) @@ -28,7 +28,11 @@ module Oxidized headers[header] = value end - request = Net::HTTP::Get.new(uri.request_uri, headers) + req_uri = uri.request_uri + if node_want + req_uri = "#{req_uri}/#{node_want}" + end + request = Net::HTTP::Get.new(req_uri, headers) if (@cfg.user? && @cfg.pass?) request.basic_auth(@cfg.user, @cfg.pass) end diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb index 5737c93..c5fe650 100644 --- a/lib/oxidized/source/sql.rb +++ b/lib/oxidized/source/sql.rb @@ -18,11 +18,16 @@ module Oxidized end end - def load + def load node_want = nil nodes = [] db = connect query = db[@cfg.table.to_sym] query = query.with_sql(@cfg.query) if @cfg.query? + + if node_want + query = query.where(@cfg.map.name.to_sym => node_want) + end + query.each do |node| # map node parameters keys = {} diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index 7eaa888..692b060 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -80,7 +80,11 @@ module Oxidized private def is_cycle_finished? - @jobs_done > 0 && @jobs_done % @nodes.count == 0 + if @jobs_done > @nodes.count + true + else + @jobs_done > 0 && @jobs_done % @nodes.count == 0 + end end def run_done_hook |