[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, upstream, updated. 3a39dd8353b6308cf49522990104cc63e55d7cda

Paul Nasrat pnasrat at googlemail.com
Fri Jan 29 17:22:37 UTC 2010


The following commit has been merged in the upstream branch:
commit fe41fb80dda8c96814b7a57875331b731dd04395
Author: Paul Nasrat <pnasrat at googlemail.com>
Date:   Tue Aug 11 17:45:40 2009 +0100

    Fix #2470 - duplicate entries in interfaces fact
    
    Solaris orders inet and inet6 seperately. This tests for and fixes this by
    uniqueing the list. Will probably need work when we get to ipv6 support.

diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index fb32d70..9fb7034 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -51,7 +51,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(/:$/, '') }
+        output.scan(/^\w+[.:]?\d+[.:]?\d*[.:]?\w*/).collect { |i| i.sub(/:$/, '') }.uniq
     end
 
     def self.get_all_interface_output
diff --git a/spec/unit/data/solaris_ifconfig_all_with_multiple_interfaces b/spec/unit/data/solaris_ifconfig_all_with_multiple_interfaces
new file mode 100644
index 0000000..f04ad5d
--- /dev/null
+++ b/spec/unit/data/solaris_ifconfig_all_with_multiple_interfaces
@@ -0,0 +1,8 @@
+lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
+	inet 127.0.0.1 netmask ff000000 
+e1000g0: flags=201004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4,CoS> mtu 1500 index 2
+	inet 192.168.162.130 netmask ffffff00 broadcast 192.168.162.255
+lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
+	inet6 ::1/128 
+e1000g0: flags=202004841<UP,RUNNING,MULTICAST,DHCP,IPv6,CoS> mtu 1500 index 2
+	inet6 fe80::20c:29ff:fe09:627e/10 
diff --git a/spec/unit/util/ip.rb b/spec/unit/util/ip.rb
index 512c07b..60ec09e 100644
--- a/spec/unit/util/ip.rb
+++ b/spec/unit/util/ip.rb
@@ -34,6 +34,13 @@ describe Facter::Util::IP do
         Facter::Util::IP.get_interfaces().should == ["lo0", "en0"]
     end
 
+    it "should return a list two interfaces on Solaris with two interfaces multiply reporting" do
+        sample_output_file = File.dirname(__FILE__) + '/../data/solaris_ifconfig_all_with_multiple_interfaces'
+        solaris_ifconfig = File.new(sample_output_file).read()
+        Facter::Util::IP.stubs(:get_all_interface_output).returns(solaris_ifconfig)
+        Facter::Util::IP.get_interfaces().should == ["lo0", "e1000g0"]
+    end
+
     it "should return a value for a specific interface" do
         Facter::Util::IP.should respond_to(:get_interface_value)
     end

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list