summaryrefslogtreecommitdiffstats
path: root/lib/facter/util/ip.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/facter/util/ip.rb')
-rw-r--r--lib/facter/util/ip.rb18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index 23eeb9c..e4370dc 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -59,7 +59,7 @@ module Facter::Util::IP
# at the end of interfaces. So, we have to trim those trailing
# characters. I tried making the regex better but supporting all
# platforms with a single regex is probably a bit too much.
- output.scan(/^[-\w]+[.:]?\d+[.:]?\d*[.:]?\w*/).collect { |i| i.sub(/:$/, '') }.uniq
+ output.scan(/^\S+/).collect { |i| i.sub(/:$/, '') }.uniq
end
def self.get_all_interface_output
@@ -69,7 +69,7 @@ module Facter::Util::IP
when 'SunOS'
output = %x{/usr/sbin/ifconfig -a}
when 'HP-UX'
- output = %x{/bin/netstat -i}
+ output = %x{/bin/netstat -in | sed -e 1d}
end
output
end
@@ -141,15 +141,13 @@ module Facter::Util::IP
else
output_int = get_single_interface_output(interface)
- if interface != /^lo[0:]?\d?/
- output_int.each_line do |s|
- if s =~ regex
- value = $1
+ output_int.each_line do |s|
+ if s =~ regex
+ value = $1
if label == 'netmask' && convert_from_hex?(kernel)
value = value.scan(/../).collect do |byte| byte.to_i(16) end.join('.')
end
- tmp1.push(value)
- end
+ tmp1.push(value)
end
end
@@ -158,13 +156,13 @@ module Facter::Util::IP
end
end
end
-
+
def self.get_network_value(interface)
require 'ipaddr'
ipaddress = get_interface_value(interface, "ipaddress")
netmask = get_interface_value(interface, "netmask")
-
+
if ipaddress && netmask
ip = IPAddr.new(ipaddress, Socket::AF_INET)
subnet = IPAddr.new(netmask, Socket::AF_INET)