Signed-off-by: Paul Nasrat <[email protected]>
---
 lib/facter/util/ip.rb                   |    6 +++---
 spec/unit/data/Mac_OS_X_10.5.5_ifconfig |   26 ++++++++++++++++++++++++++
 spec/unit/util/ip.rb                    |   12 +++++++++++-
 3 files changed, 40 insertions(+), 4 deletions(-)
 create mode 100644 spec/unit/data/Mac_OS_X_10.5.5_ifconfig

diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index 598b084..35dadb6 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -10,7 +10,7 @@ module Facter::Util::IP
             :netmask => /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
         },
         :bsd => {
-            :aliases => [:openbsd, :netbsd, :freebsd],
+            :aliases => [:openbsd, :netbsd, :freebsd, :darwin],
             :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{10})/
@@ -55,7 +55,7 @@ module Facter::Util::IP
 
     def self.get_all_interface_output
         case Facter.value(:kernel)
-        when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD'
+        when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin'
             output = %x{/sbin/ifconfig -a}
         when 'SunOS'
             output = %x{/usr/sbin/ifconfig -a}
@@ -66,7 +66,7 @@ module Facter::Util::IP
     def self.get_single_interface_output(interface)
         output = ""
         case Facter.value(:kernel)
-        when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD'
+        when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin'
             output = %x{/sbin/ifconfig #{interface}}
         when 'SunOS'
             output = %x{/usr/sbin/ifconfig #{interface}}
diff --git a/spec/unit/data/Mac_OS_X_10.5.5_ifconfig 
b/spec/unit/data/Mac_OS_X_10.5.5_ifconfig
new file mode 100644
index 0000000..33f6609
--- /dev/null
+++ b/spec/unit/data/Mac_OS_X_10.5.5_ifconfig
@@ -0,0 +1,26 @@
+lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
+       inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
+       inet 127.0.0.1 netmask 0xff000000 
+       inet6 ::1 prefixlen 128 
+gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
+stf0: flags=0<> mtu 1280
+en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
+       ether 00:1b:63:ae:02:66 
+       media: autoselect status: inactive
+       supported media: autoselect 10baseT/UTP <half-duplex> 10baseT/UTP 
<full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 10baseT/UTP 
<full-duplex,flow-control> 100baseTX <half-duplex> 100baseTX <full-duplex> 
100baseTX <full-duplex,hw-loopback> 100baseTX <full-duplex,flow-control> 
1000baseT <full-duplex> 1000baseT <full-duplex,hw-loopback> 1000baseT 
<full-duplex,flow-control> none
+fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
+       lladdr 00:1e:52:ff:fe:31:1a:80 
+       media: autoselect <full-duplex> status: inactive
+       supported media: autoselect <full-duplex>
+en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
+       inet6 fe80::21e:52ff:fe70:d7b6%en1 prefixlen 64 scopeid 0x6 
+       inet 192.168.0.4 netmask 0xffffff00 broadcast 192.168.0.255
+       ether 00:1e:52:70:d7:b6 
+       media: autoselect status: active
+       supported media: autoselect
+vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
+       inet 172.16.15.1 netmask 0xffffff00 broadcast 172.16.15.255
+       ether 00:50:56:c0:00:08 
+vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
+       inet 192.168.89.1 netmask 0xffffff00 broadcast 192.168.89.255
+       ether 00:50:56:c0:00:01 
diff --git a/spec/unit/util/ip.rb b/spec/unit/util/ip.rb
index 73cf37c..af7e109 100644
--- a/spec/unit/util/ip.rb
+++ b/spec/unit/util/ip.rb
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require 'facter/util/ip'
 
 describe Facter::Util::IP do
-    [:freebsd, :linux, :netbsd, :openbsd, :sunos].each do |platform|
+    [:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin].each do |platform|
         it "should be supported on #{platform}" do
             Facter::Util::IP.supported_platforms.should be_include(platform)
         end
@@ -57,6 +57,16 @@ 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
+        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_single_interface_output).with("en1").returns(ifconfig_interface)
+        Facter.stubs(:value).with(:kernel).returns("Darwin")
+
+        Facter::Util::IP.get_interface_value("en1", "macaddress").should == 
"00:1b:63:ae:02:66"
+    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()
-- 
1.6.0.2


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to