summaryrefslogtreecommitdiff
path: root/lib/oxidized/nodes.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-12-03 15:22:19 +0200
committerSaku Ytti <saku@ytti.fi>2014-12-03 15:22:19 +0200
commit53daa6fab0b87c6ef6dc3efda9f0eff0f6af5e3e (patch)
treec2f3e679f5770941d2dbc8036266a8617a3340c7 /lib/oxidized/nodes.rb
parent32733012e2bcda5373406aec8156dcb9c00a58ce (diff)
parent6132f0f825d281c2d5c7d918239eeec80b3e87be (diff)
Merge branch 'master' into cfg_as_object
Diffstat (limited to 'lib/oxidized/nodes.rb')
-rw-r--r--lib/oxidized/nodes.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 6f30af4..032118d 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -9,16 +9,11 @@ module Oxidized
def load node_want=nil
with_lock do
new = []
- node_want_ip = (IPAddr.new(node_want) rescue false) 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 specific node(s), not all of them
- if node_want
- next unless node_want_ip == node[:ip] or node_want.match(node[:name])
- end
-
+ next unless node_want? node_want, node
begin
_node = Node.new node
new.push _node
@@ -33,6 +28,20 @@ module Oxidized
end
end
+ def node_want? node_want, node
+ return true unless node_want
+ node_want_ip = (IPAddr.new(node_want) rescue false)
+ name_is_ip = (IPAddr.new(node[:name]) rescue false)
+ if name_is_ip and node_want_ip == node[:name]
+ true
+ elsif node[:ip] and node_want_ip == node[:ip]
+ true
+ elsif node_want.match node[:name]
+ true unless name_is_ip
+ end
+ end
+
+
def list
with_lock do
map { |e| e.serialize }