summaryrefslogtreecommitdiff
path: root/lib/oxidized/nodes.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-04-13 10:45:36 +0300
committerSaku Ytti <saku@ytti.fi>2014-04-13 10:45:36 +0300
commitb603c20370c7548739f90f2b92ffa066d59446ab (patch)
treea14f062b34df21caa6a29edea265109acf7e639c /lib/oxidized/nodes.rb
parent8cf98a934f42bea096538ae41afa6055a35c0479 (diff)
smarter match for IP address in nodes
- add 'connnected?' method to ssh/telnet to query if or not we're connected - subclass OxidizedError from StandardError, all future OxidizedErrors should be subclasssed from this.
Diffstat (limited to 'lib/oxidized/nodes.rb')
-rw-r--r--lib/oxidized/nodes.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 8d49443..42c18cb 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -1,5 +1,6 @@
module Oxidized
- require 'oxidized/node'
+ require 'oxidized/node'
+ require 'ipaddr'
class Oxidized::NotSupported < StandardError; end
class Oxidized::NodeNotFound < StandardError; end
class Nodes < Array
@@ -8,14 +9,18 @@ module Oxidized
def load node_want=nil
with_lock do
new = []
+ node_want_ip = (IPaddr.new(node_want) rescue nil) if node_want
@source = CFG.source[:default]
Oxidized.mgr.add_source @source
Oxidized.mgr.source[@source].new.load.each do |node|
- # we want to load one specific node(s), not all of them
+ # we want to load specific node(s), not all of them
if node_want
- next unless node[:name].to_s.match(node_want) or
- node[:ip].to_s.match(node_want)
+ if node_want_ip
+ next unless node_want_ip == node[:ip]
+ else
+ next unless node[:name].match node_want
+ end
end
begin