diff options
author | Paul Nasrat <pnasrat@googlemail.com> | 2009-01-24 12:52:07 +0000 |
---|---|---|
committer | Paul Nasrat <pnasrat@googlemail.com> | 2009-01-24 12:52:07 +0000 |
commit | 02c2912fb94edd37d6d7001e28714c11d5939f6d (patch) | |
tree | ef0ad5b487f1a1840f20ad4205d453bb0b43aa45 /lib/facter/interfaces.rb | |
parent | db4facecf6bd8a8e4629165aafa813652bf2d53d (diff) | |
download | facter-02c2912fb94edd37d6d7001e28714c11d5939f6d.tar.gz facter-02c2912fb94edd37d6d7001e28714c11d5939f6d.tar.xz facter-02c2912fb94edd37d6d7001e28714c11d5939f6d.zip |
Refactor - rename ipmess to interfaces
Diffstat (limited to 'lib/facter/interfaces.rb')
-rw-r--r-- | lib/facter/interfaces.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/facter/interfaces.rb b/lib/facter/interfaces.rb new file mode 100644 index 0000000..bf0cc6e --- /dev/null +++ b/lib/facter/interfaces.rb @@ -0,0 +1,33 @@ +# interfaces.rb +# Try to get additional Facts about the machine's network interfaces +# +# Original concept Copyright (C) 2007 psychedelys <psychedelys@gmail.com> +# Update and *BSD support (C) 2007 James Turnbull <james@lovedthanlost.net> +# + +require 'facter/util/ip' + +# Note that most of this only works on a fixed list of platforms; notably, Darwin +# is missing. + +Facter.add(:interfaces) do + confine :kernel => Facter::Util::IP.supported_platforms + setcode do + Facter::Util::IP.get_interfaces.collect { |iface| Facter::Util::IP.alphafy(iface) }.join(",") + end +end + +Facter::Util::IP.get_interfaces.each do |interface| + mi = Facter::Util::IP.alphafy(interface) + + # Make a fact for each detail of each interface. Yay. + # There's no point in confining these facts, since we wouldn't be able to create + # them if we weren't running on a supported platform. + %w{ipaddress macaddress netmask}.each do |label| + Facter.add(label + "_" + mi) do + setcode do + Facter::Util::IP.get_interface_value(interface, label) + end + end + end +end |