From b3bec7b240640b1b6ca900bb3aab3659914783c0 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Fri, 4 Jul 2014 10:02:20 +0300 Subject: match node[:name] to ip When running Oxidized via oxidized-script you want just one node, and you specify that as Nodes.new(:node=>x) however as router.db usually lacks 'ip' field, and only has 'name' field'. If you have router.db with IP in 'name' field, and you do Nodes.new(:node='192.0.2.1') it won't return anything, as '192.0.2.1' is matched against node[:ip] which does not exist. This change makes IP match against IP and Name. --- lib/oxidized/nodes.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index 2ea1891..d6cc867 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -9,18 +9,14 @@ module Oxidized def load node_want=nil with_lock do new = [] - node_want_ip = (IPAddr.new(node_want) rescue nil) if node_want + 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 - if node_want_ip - next unless node_want_ip == node[:ip] - else - next unless node[:name].match node_want - end + next unless node_want_ip == node[:ip] or node_want.match(node[:name]) end begin -- cgit v1.2.1