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

Luke Kanies luke at madstop.com
Fri Jan 29 17:22:20 UTC 2010


The following commit has been merged in the upstream branch:
commit d89ea7a88a93b6ce3132d9dd394b4187eb460cb2
Author: Luke Kanies <luke at madstop.com>
Date:   Mon Apr 20 11:40:42 2009 -0500

    Fixing ifconfig warnings generated on OS X
    
    The interface collection regex was leaving trailing
    ':' characters on the interface names, which meant
    individual interfaces weren't quite right.
    
    Signed-off-by: Luke Kanies <luke at madstop.com>

diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index e06e506..374d9f3 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -45,17 +45,13 @@ module Facter::Util::IP
     end
 
     def self.get_interfaces
-        int = nil
+        return [] unless output = Facter::Util::IP.get_all_interface_output()
 
-        output =  Facter::Util::IP.get_all_interface_output()
-
-        # We get lots of warnings on platforms that don't get an output
-        # made.
-        if output
-            int = output.scan(/^\w+[.:]?\d+[.:]?\d*[.:]?\w*/)
-        else
-            []
-        end
+        # Our regex appears to be stupid, in that it leaves colons sitting
+        # 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(/:$/, '') }
     end
 
     def self.get_all_interface_output
diff --git a/spec/unit/util/ip.rb b/spec/unit/util/ip.rb
index 4f6e2c0..a1d2458 100644
--- a/spec/unit/util/ip.rb
+++ b/spec/unit/util/ip.rb
@@ -37,7 +37,7 @@ describe Facter::Util::IP do
         Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == []
     end
 
-    it "should return interface information for directly supported platforms" do
+    it "should return netmask information for Solaris" do
         sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
         solaris_ifconfig_interface = File.new(sample_output_file).read()
 
@@ -47,7 +47,7 @@ describe Facter::Util::IP do
         Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0"
     end
 
-    it "should return interface information for platforms supported via an alias" do
+    it "should return interface information for FreeBSD supported via an alias" do
         sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig"
         ifconfig_interface = File.new(sample_output_file).read()
 
@@ -57,7 +57,7 @@ describe Facter::Util::IP do
         Facter::Util::IP.get_interface_value("fxp0", "macaddress").should == "00:0e:0c:68:67:7c"
     end
 
-    it "should return interface information for OS X" do
+    it "should return macaddress information for OS X" do
         sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig"
         ifconfig_interface = File.new(sample_output_file).read()
 
@@ -67,6 +67,16 @@ describe Facter::Util::IP do
         Facter::Util::IP.get_interface_value("en1", "macaddress").should == "00:1b:63:ae:02:66"
     end
 
+    it "should return all interfaces correctly on OS X" do
+        sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig"
+        ifconfig_interface = File.new(sample_output_file).read()
+
+        Facter::Util::IP.expects(:get_all_interface_output).returns(ifconfig_interface)
+        Facter.stubs(:value).with(:kernel).returns("Darwin")
+
+        Facter::Util::IP.get_interfaces().should == ["lo0", "gif0", "stf0", "en0", "fw0", "en1", "vmnet8", "vmnet1"]
+    end
+
     it "should return a human readable netmask on Solaris" do
         sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
         solaris_ifconfig_interface = File.new(sample_output_file).read()

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list