summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2009-01-27 10:23:26 +1100
committerJames Turnbull <james@lovedthanlost.net>2009-01-27 10:23:26 +1100
commitda52e30971ebb6935c64777e4a91cb2cbb066db9 (patch)
tree4fdc856618534fa2e83c329907e91a70f940cea2 /lib
parentc2de35f1329dbaf6c843ff0a4967955ce989f2f0 (diff)
downloadfacter-da52e30971ebb6935c64777e4a91cb2cbb066db9.tar.gz
facter-da52e30971ebb6935c64777e4a91cb2cbb066db9.tar.xz
facter-da52e30971ebb6935c64777e4a91cb2cbb066db9.zip
Fixed #1870 - Format all subnet masks as human-readable
Diffstat (limited to 'lib')
-rw-r--r--lib/facter/util/ip.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index 35dadb6..a7f0a85 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -13,7 +13,7 @@ module Facter::Util::IP
:aliases => [:openbsd, :netbsd, :freebsd, :darwin],
:ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
:macaddress => /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/,
- :netmask => /netmask\s+(\w{10})/
+ :netmask => /netmask\s+0x(\w{8})/
},
:sunos => {
:addr => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
@@ -27,6 +27,11 @@ module Facter::Util::IP
interface.gsub(/[:.]/, '_')
end
+ def self.convert_from_hex?(kernel)
+ kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin]
+ kernels_to_convert.include?(kernel)
+ end
+
def self.supported_platforms
REGEX_MAP.inject([]) do |result, tmp|
key, map = tmp
@@ -122,7 +127,7 @@ module Facter::Util::IP
output_int.each do |s|
if s =~ regex
value = $1
- if label == 'netmask' && Facter.value(:kernel) == "SunOS"
+ if label == 'netmask' && convert_from_hex?(kernel)
value = value.scan(/../).collect do |byte| byte.to_i(16) end.join('.')
end
tmp1.push(value)