We already had code to do this that wasn't tested or being called. Adding a per interface network fact
Signed-off-by: Paul Nasrat <[email protected]> --- lib/facter/interfaces.rb | 2 +- spec/unit/util/ip.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletions(-) diff --git a/lib/facter/interfaces.rb b/lib/facter/interfaces.rb index 1239215..ce76717 100644 --- a/lib/facter/interfaces.rb +++ b/lib/facter/interfaces.rb @@ -22,7 +22,7 @@ Facter::Util::IP.get_interfaces.each do |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| + %w{ipaddress macaddress netmask network}.each do |label| Facter.add(label + "_" + Facter::Util::IP.alphafy(interface)) do setcode do Facter::Util::IP.get_interface_value(interface, label) diff --git a/spec/unit/util/ip.rb b/spec/unit/util/ip.rb index 60ec09e..f501d9a 100644 --- a/spec/unit/util/ip.rb +++ b/spec/unit/util/ip.rb @@ -69,6 +69,17 @@ describe Facter::Util::IP do Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0" end + + it "should return network information for Solaris" do + sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" + solaris_ifconfig_interface = File.new(sample_output_file).read() + + Facter::Util::IP.stubs(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) + Facter.stubs(:value).with(:kernel).returns("SunOS") + + Facter::Util::IP.get_network_value("e1000g0").should == "172.16.15.0" + end + it "should return interface information for FreeBSD supported via an alias" do sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig" -- 1.6.1.3 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---
