From f5e283c74fc5699731715a9ce7958c9e6145cb10 Mon Sep 17 00:00:00 2001 From: curiositycasualty Date: Mon, 30 Mar 2015 11:36:47 -0700 Subject: populate ipaddress correctly within zones --- lib/ohai/plugins/solaris2/network.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ohai/plugins/solaris2/network.rb b/lib/ohai/plugins/solaris2/network.rb index 7e4e445b..b2db8df6 100644 --- a/lib/ohai/plugins/solaris2/network.rb +++ b/lib/ohai/plugins/solaris2/network.rb @@ -150,10 +150,17 @@ Ohai.plugin(:Network) do so = shell_out("route -n get default") so.stdout.lines do |line| - matches = /interface: (\S+)/.match(line) + matches = /interface: (?\S+)/.match(line) if matches + # Within a zone, `route -n get default` will produce the zonehost's + # interface name ("net0"), not the zone's specific iteration of it ("net0:3"). + # This pairs the two and allows node['ipaddress'] to be populated correctly + # by the default network.rb plugin. + actual_default_interface = network[:interfaces].select do |v, vi| + v.include? matches[:def_route_interface] + end Ohai::Log.debug("found gateway device: #{$1}") - network[:default_interface] = matches[1] + network[:default_interface] = actual_default_interface.keys.first end matches = /gateway: (\S+)/.match(line) if matches -- cgit v1.2.1