summaryrefslogtreecommitdiffstats
path: root/lib/facter/util
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2010-06-11 09:24:24 +1000
committerJames Turnbull <james@lovedthanlost.net>2010-06-15 01:29:05 +1000
commit8106bc3f000d0e18969c4ec142ef84fbc780b30a (patch)
treee00415d7e9cc7cda337af80090e850b28e67b375 /lib/facter/util
parent83b3ea6abbd1d382a6738fa731f9f7409867e135 (diff)
downloadfacter-8106bc3f000d0e18969c4ec142ef84fbc780b30a.tar.gz
facter-8106bc3f000d0e18969c4ec142ef84fbc780b30a.tar.xz
facter-8106bc3f000d0e18969c4ec142ef84fbc780b30a.zip
Adding HP-UX support to Facter's IP facts
Includes Rspec tests
Diffstat (limited to 'lib/facter/util')
-rw-r--r--lib/facter/util/ip.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index 25acf3a..366303c 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -16,9 +16,14 @@ module Facter::Util::IP
:netmask => /netmask\s+0x(\w{8})/
},
:sunos => {
- :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
+ :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{8})/
+ },
+ :"hp-ux" => {
+ :ipaddress => /\s+inet (\S+)\s.*/,
+ :macaddress => /(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/,
+ :netmask => /.*\s+netmask (\S+)\s.*/
}
}
@@ -28,7 +33,7 @@ module Facter::Util::IP
end
def self.convert_from_hex?(kernel)
- kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin]
+ kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin, :"hp-ux"]
kernels_to_convert.include?(kernel)
end
@@ -60,6 +65,8 @@ module Facter::Util::IP
output = %x{/sbin/ifconfig -a}
when 'SunOS'
output = %x{/usr/sbin/ifconfig -a}
+ when 'HP-UX'
+ output = %x{/bin/netstat -i}
end
output
end
@@ -71,6 +78,12 @@ module Facter::Util::IP
output = %x{/sbin/ifconfig #{interface}}
when 'SunOS'
output = %x{/usr/sbin/ifconfig #{interface}}
+ when 'HP-UX'
+ mac = ""
+ ifc = %x{/usr/sbin/ifconfig #{interface}}
+ %x{/usr/sbin/lanscan}.scan(/(\dx\S+).*UP\s+(\w+\d+)/).each {|i| mac = i[0] if i.include?(interface) }
+ mac = mac.sub(/0x(\S+)/,'\1').scan(/../).join(":")
+ output = ifc + "\n" + mac
end
output
end
@@ -101,7 +114,6 @@ module Facter::Util::IP
device
end
-
def self.get_interface_value(interface, label)
tmp1 = []