Signed-off-by: Marc Fournier <[email protected]>
---
 lib/facter/hardwareisa.rb               |    2 +-
 lib/facter/id.rb                        |    2 +-
 lib/facter/lsb.rb                       |    2 +-
 lib/facter/lsbmajdistrelease.rb         |    2 +-
 lib/facter/macaddress.rb                |    2 +-
 lib/facter/memory.rb                    |    2 +-
 lib/facter/netmask.rb                   |    2 +-
 lib/facter/processor.rb                 |    6 ++--
 lib/facter/uniqueid.rb                  |    2 +-
 lib/facter/util/ip.rb                   |   10 ++++----
 lib/facter/util/manufacturer.rb         |    4 +-
 lib/facter/util/netmask.rb              |    2 +-
 lib/facter/util/virtual.rb              |    6 ++++-
 lib/facter/virtual.rb                   |    6 ++--
 spec/unit/data/debian_kfreebsd_ifconfig |   40 +++++++++++++++++++++++++++++++
 spec/unit/util/ip.rb                    |   30 ++++++++++++++++++++++-
 spec/unit/util/virtual.rb               |    6 +++-
 17 files changed, 100 insertions(+), 26 deletions(-)
 create mode 100644 spec/unit/data/debian_kfreebsd_ifconfig

diff --git a/lib/facter/hardwareisa.rb b/lib/facter/hardwareisa.rb
index 45a16bc..23f7d08 100644
--- a/lib/facter/hardwareisa.rb
+++ b/lib/facter/hardwareisa.rb
@@ -1,4 +1,4 @@
 Facter.add(:hardwareisa) do
     setcode 'uname -p', '/bin/sh'
-    confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE 
SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD OEL OVS}
+    confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE 
SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD OEL OVS GNU/kFreeBSD}
 end
diff --git a/lib/facter/id.rb b/lib/facter/id.rb
index 0a4067d..c2ab3b7 100644
--- a/lib/facter/id.rb
+++ b/lib/facter/id.rb
@@ -1,5 +1,5 @@
 Facter.add(:id) do
-    confine :operatingsystem => %w{Linux Fedora RedHat CentOS SuSE SLES Debian 
Ubuntu Gentoo AIX OEL OVS}
+    confine :operatingsystem => %w{Linux Fedora RedHat CentOS SuSE SLES Debian 
Ubuntu Gentoo AIX OEL OVS GNU/kFreeBSD}
     setcode "whoami"
 end
 
diff --git a/lib/facter/lsb.rb b/lib/facter/lsb.rb
index f54d75f..4b98466 100644
--- a/lib/facter/lsb.rb
+++ b/lib/facter/lsb.rb
@@ -20,7 +20,7 @@
    "LSBDistCodeName"    => %r{^Codename:\t(.*)$}
 }.each do |fact, pattern|
     Facter.add(fact) do
-        confine :kernel => :linux
+        confine :kernel => [ :linux, :"gnu/kfreebsd" ]
         setcode do
             unless defined?(@@lsbdata) and defined?(@@lsbtime) and 
(Time.now.to_i - @@lsbtime.to_i < 5)
                 type = nil
diff --git a/lib/facter/lsbmajdistrelease.rb b/lib/facter/lsbmajdistrelease.rb
index e091593..997e7ef 100644
--- a/lib/facter/lsbmajdistrelease.rb
+++ b/lib/facter/lsbmajdistrelease.rb
@@ -3,7 +3,7 @@
 require 'facter'
 
 Facter.add("lsbmajdistrelease") do
-    confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE 
SLES Debian Ubuntu Gentoo OEL OVS}
+    confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE 
SLES Debian Ubuntu Gentoo OEL OVS GNU/kFreeBSD}
     setcode do
         if /(\d*)\./i =~ Facter.value(:lsbdistrelease)
             result=$1
diff --git a/lib/facter/macaddress.rb b/lib/facter/macaddress.rb
index 889feea..8e37f58 100644
--- a/lib/facter/macaddress.rb
+++ b/lib/facter/macaddress.rb
@@ -1,5 +1,5 @@
 Facter.add(:macaddress) do
-    confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE 
SLES Debian Gentoo Ubuntu OEL OVS}
+    confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE 
SLES Debian Gentoo Ubuntu OEL OVS GNU/kFreeBSD}
     setcode do
         ether = []
         output = %x{/sbin/ifconfig -a}
diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb
index 06640e6..a6e6143 100644
--- a/lib/facter/memory.rb
+++ b/lib/facter/memory.rb
@@ -13,7 +13,7 @@ require 'facter/util/memory'
     :SwapFree   => "SwapFree"
 }.each do |fact, name|
     Facter.add(fact) do
-        confine :kernel => :linux
+        confine :kernel => [ :linux, :"gnu/kfreebsd" ]
         setcode do
             Facter::Memory.meminfo_number(name)
         end
diff --git a/lib/facter/netmask.rb b/lib/facter/netmask.rb
index bad3648..d6d125e 100644
--- a/lib/facter/netmask.rb
+++ b/lib/facter/netmask.rb
@@ -9,7 +9,7 @@
 require 'facter/util/netmask'
 
 Facter.add("netmask") do
-    confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin ]
+    confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, 
:"gnu/kfreebsd" ]
     setcode do
         Facter::NetMask.get_netmask
     end
diff --git a/lib/facter/processor.rb b/lib/facter/processor.rb
index 53998ff..ac75867 100644
--- a/lib/facter/processor.rb
+++ b/lib/facter/processor.rb
@@ -7,7 +7,7 @@
 
 require 'thread'
 
-if Facter.value(:kernel) == "Linux"
+if ["Linux", "GNU/kFreeBSD"].include? Facter.value(:kernel)
     processor_num = -1
     processor_list = []
     Thread::exclusive do
@@ -22,7 +22,7 @@ if Facter.value(:kernel) == "Linux"
     end
 
     Facter.add("ProcessorCount") do
-        confine :kernel => :linux
+        confine :kernel => [ :linux, :"gnu/kfreebsd" ]
         setcode do
             processor_list.length.to_s
         end
@@ -30,7 +30,7 @@ if Facter.value(:kernel) == "Linux"
 
     processor_list.each_with_index do |desc, i|
         Facter.add("Processor#{i}") do
-            confine :kernel => :linux
+            confine :kernel => [ :linux, :"gnu/kfreebsd" ]
             setcode do
                 desc
             end
diff --git a/lib/facter/uniqueid.rb b/lib/facter/uniqueid.rb
index 93f8a61..aaeaa12 100644
--- a/lib/facter/uniqueid.rb
+++ b/lib/facter/uniqueid.rb
@@ -1,4 +1,4 @@
 Facter.add(:uniqueid) do
     setcode 'hostid', '/bin/sh'
-    confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE 
SLES Debian Ubuntu Gentoo AIX OEL OVS}
+    confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE 
SLES Debian Ubuntu Gentoo AIX OEL OVS GNU/kFreeBSD}
 end
diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index 366303c..62d50a4 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -10,9 +10,9 @@ module Facter::Util::IP
             :netmask    => /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
         },
         :bsd   => {
-            :aliases    => [:openbsd, :netbsd, :freebsd, :darwin],
+            :aliases    => [:openbsd, :netbsd, :freebsd, :darwin, 
:"gnu/kfreebsd"],
             :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)/,
+            :macaddress => 
/(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/,
             :netmask    => /netmask\s+0x(\w{8})/
         },
         :sunos => {
@@ -33,7 +33,7 @@ module Facter::Util::IP
     end
 
     def self.convert_from_hex?(kernel)
-        kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin, 
:"hp-ux"]
+        kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin, 
:"hp-ux", :"gnu/kfreebsd"]
         kernels_to_convert.include?(kernel)
     end
 
@@ -61,7 +61,7 @@ module Facter::Util::IP
 
     def self.get_all_interface_output
         case Facter.value(:kernel)
-        when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin'
+        when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD'
             output = %x{/sbin/ifconfig -a}
         when 'SunOS'
             output = %x{/usr/sbin/ifconfig -a}
@@ -74,7 +74,7 @@ module Facter::Util::IP
     def self.get_single_interface_output(interface)
         output = ""
         case Facter.value(:kernel)
-        when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin'
+        when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD'
             output = %x{/sbin/ifconfig #{interface}}
         when 'SunOS'
             output = %x{/usr/sbin/ifconfig #{interface}}
diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb
index 112380b..c89da60 100644
--- a/lib/facter/util/manufacturer.rb
+++ b/lib/facter/util/manufacturer.rb
@@ -5,7 +5,7 @@ module Facter::Manufacturer
 
     def self.get_dmi_table()
         case Facter.value(:kernel)
-        when 'Linux'
+        when 'Linux', 'GNU/kFreeBSD'
             return nil unless FileTest.exists?("/usr/sbin/dmidecode")
 
             output=%x{/usr/sbin/dmidecode 2>/dev/null}
@@ -38,7 +38,7 @@ module Facter::Manufacturer
                         if line =~ /#{key}/ and line =~ /\n\s+#{value} (.+)\n/
                             result = $1.strip
                             Facter.add(facterkey) do
-                                confine :kernel => [ :linux, :freebsd, 
:netbsd, :sunos ]
+                                confine :kernel => [ :linux, :freebsd, 
:netbsd, :sunos, :"gnu/kfreebsd" ]
                                 setcode do
                                     result
                                 end
diff --git a/lib/facter/util/netmask.rb b/lib/facter/util/netmask.rb
index 160cdbd..5dcc576 100644
--- a/lib/facter/util/netmask.rb
+++ b/lib/facter/util/netmask.rb
@@ -17,7 +17,7 @@ module Facter::NetMask
                 :regex => %r{\s+ inet \s #{Facter.ipaddress} \s netmask \s 
(\w{8})}x,
                 :munge => Proc.new { |mask| mask.scan(/../).collect do |byte| 
byte.to_i(16) end.join('.') }
             }
-        when 'FreeBSD','NetBSD','OpenBSD', 'Darwin'
+        when 'FreeBSD','NetBSD','OpenBSD', 'Darwin', 'GNU/kFreeBSD'
             ops = {
                 :ifconfig => '/sbin/ifconfig -a',
                 :regex => %r{\s+ inet \s #{Facter.ipaddress} \s netmask \s 
0x(\w{8})}x,
diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb
index 5f70d42..d500874 100644
--- a/lib/facter/util/virtual.rb
+++ b/lib/facter/util/virtual.rb
@@ -59,7 +59,11 @@ module Facter::Util::Virtual
     end
 
     def self.jail?
-        Facter::Util::Resolution.exec("/sbin/sysctl -n security.jail.jailed") 
== "1"
+        path = case Facter.value(:kernel)
+            when "FreeBSD": "/sbin"
+            when "GNU/kFreeBSD": "/bin"
+        end
+        Facter::Util::Resolution.exec("#{path}/sysctl -n 
security.jail.jailed") == "1"
     end
 
 end
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index c14a715..c299783 100644
--- a/lib/facter/virtual.rb
+++ b/lib/facter/virtual.rb
@@ -1,7 +1,7 @@
 require 'facter/util/virtual'
 
 Facter.add("virtual") do
-    confine :kernel => %w{Linux FreeBSD OpenBSD SunOS}
+    confine :kernel => %w{Linux FreeBSD OpenBSD SunOS GNU/kFreeBSD}
 
     result = "physical"
 
@@ -38,7 +38,7 @@ Facter.add("virtual") do
             result = Facter::Util::Virtual.kvm_type()
         end
 
-        if Facter.value(:kernel)=="FreeBSD"
+        if ["FreeBSD", "GNU/kFreeBSD"].include? Facter.value(:kernel)
             result = "jail" if Facter::Util::Virtual.jail?
         end
 
@@ -76,7 +76,7 @@ Facter.add("virtual") do
 end
   
 Facter.add("is_virtual") do
-    confine :kernel => %w{Linux FreeBSD OpenBSD SunOS}
+    confine :kernel => %w{Linux FreeBSD OpenBSD SunOS GNU/kFreeBSD}
 
     setcode do
         case Facter.value(:virtual)
diff --git a/spec/unit/data/debian_kfreebsd_ifconfig 
b/spec/unit/data/debian_kfreebsd_ifconfig
new file mode 100644
index 0000000..44a3b62
--- /dev/null
+++ b/spec/unit/data/debian_kfreebsd_ifconfig
@@ -0,0 +1,40 @@
+em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
+       
options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
+       ether 0:11:a:59:67:90
+       inet6 fe80::211:aff:fe59:6790%em0 prefixlen 64 scopeid 0x1 
+       nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
+       media: Ethernet autoselect (1000baseT <full-duplex>)
+       status: active
+em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
+       
options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
+       ether 0:11:a:59:67:91
+       inet6 fe80::211:aff:fe59:6791%em1 prefixlen 64 scopeid 0x2 
+       inet 192.168.10.10 netmask 0xffffff00 broadcast 192.168.10.255
+       nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
+       media: Ethernet autoselect (100baseTX <full-duplex>)
+       status: active
+bge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
+       
options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
+       ether 0:14:c2:3f:ea:e4
+       media: Ethernet autoselect (none)
+       status: no carrier
+bge1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
+       
options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
+       ether 0:14:c2:3f:ea:e3
+       media: Ethernet autoselect (none)
+       status: no carrier
+lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
+       options=3<RXCSUM,TXCSUM>
+       inet6 ::1 prefixlen 128 
+       inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5 
+       inet 127.0.0.1 netmask 0xff000000 
+       nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
+vlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
+       options=3<RXCSUM,TXCSUM>
+       ether 0:11:a:59:67:90
+       inet6 fe80::211:aff:fe59:6790%vlan0 prefixlen 64 scopeid 0x6 
+       inet 192.168.192.2 netmask 0xffffff00 broadcast 192.168.192.255
+       nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
+       media: Ethernet autoselect (1000baseT <full-duplex>)
+       status: active
+       vlan: 192 parent interface: em0
diff --git a/spec/unit/util/ip.rb b/spec/unit/util/ip.rb
index a9aae76..e9ebae6 100755
--- 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, :darwin, :"hp-ux"].each do 
|platform|
+    [:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux", 
:"gnu/kfreebsd"].each do |platform|
         it "should be supported on #{platform}" do
             Facter::Util::IP.supported_platforms.should be_include(platform)
         end
@@ -48,6 +48,13 @@ describe Facter::Util::IP do
         Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"]
     end 
 
+    it "should return a list of six interfaces on a GNU/kFreeBSD with six 
interfaces" do
+        sample_output_file = File.dirname(__FILE__) + 
'/../data/debian_kfreebsd_ifconfig'
+        kfreebsd_ifconfig = File.new(sample_output_file).read()
+        
Facter::Util::IP.stubs(:get_all_interface_output).returns(kfreebsd_ifconfig)
+        Facter::Util::IP.get_interfaces().should == ["em0", "em1", "bge0", 
"bge1", "lo0", "vlan0"]
+    end
+
     it "should return a value for a specific interface" do
         Facter::Util::IP.should respond_to(:get_interface_value)
     end
@@ -107,6 +114,16 @@ describe Facter::Util::IP do
         Facter::Util::IP.get_interface_value("lan0", "macaddress").should == 
"00:13:21:BD:9C:B7"
     end 
 
+    it "should return macaddress with leading zeros stripped off for 
GNU/kFreeBSD" do
+        sample_output_file = File.dirname(__FILE__) + 
"/../data/debian_kfreebsd_ifconfig"
+        kfreebsd_ifconfig = File.new(sample_output_file).read()
+
+        
Facter::Util::IP.expects(:get_single_interface_output).with("em0").returns(kfreebsd_ifconfig)
+        Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD")
+
+        Facter::Util::IP.get_interface_value("em0", "macaddress").should == 
"0:11:a:59:67:90"
+    end
+
     it "should return netmask information for HP-UX" do
         sample_output_file = File.dirname(__FILE__) + 
"/../data/hpux_ifconfig_single_interface"
         hpux_ifconfig_interface = File.new(sample_output_file).read()
@@ -188,6 +205,17 @@ describe Facter::Util::IP do
         Facter::Util::IP.get_interface_value("en1", "netmask").should == 
"255.255.255.0"
     end
     
+    it "should return a human readable netmask on GNU/kFreeBSD" do
+        sample_output_file = File.dirname(__FILE__) + 
"/../data/debian_kfreebsd_ifconfig"
+
+        kfreebsd_ifconfig = File.new(sample_output_file).read()
+
+        
Facter::Util::IP.expects(:get_single_interface_output).with("em1").returns(kfreebsd_ifconfig)
+        Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD")
+
+        Facter::Util::IP.get_interface_value("em1", "netmask").should == 
"255.255.255.0"
+    end
+
     it "should not get bonding master on interface aliases" do
         Facter.stubs(:value).with(:kernel).returns("Linux")
         
diff --git a/spec/unit/util/virtual.rb b/spec/unit/util/virtual.rb
index 1e31a2f..082c420 100644
--- a/spec/unit/util/virtual.rb
+++ b/spec/unit/util/virtual.rb
@@ -107,12 +107,14 @@ describe Facter::Util::Virtual do
     end
 
     it "should identify FreeBSD jail when in jail" do
+        Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
         Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n 
security.jail.jailed").returns("1")
         Facter::Util::Virtual.should be_jail
     end
 
-    it "should not identify FreeBSD jail when not in jail" do
-        Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n 
security.jail.jailed").returns("0")
+    it "should not identify GNU/kFreeBSD jail when not in jail" do
+        Facter.fact(:kernel).stubs(:value).returns("GNU/kFreeBSD")
+        Facter::Util::Resolution.stubs(:exec).with("/bin/sysctl -n 
security.jail.jailed").returns("0")
         Facter::Util::Virtual.should_not be_jail
     end
 
-- 
1.7.1

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