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

James Turnbull james at lovedthanlost.net
Wed Aug 18 05:55:48 UTC 2010


The following commit has been merged in the upstream branch:
commit 9a00eaeb3a26fa32f9fda2bf3ff733f5214864ba
Author: James Turnbull <james at lovedthanlost.net>
Date:   Sat Apr 24 16:15:22 2010 +1000

    Fixed #2313 - Somewhat essential hardware facts not available on OpenBSD, patch included
    
    Thanks to Joe McDonagh for the patch.

diff --git a/lib/facter/architecture.rb b/lib/facter/architecture.rb
index abd54da..e4aaeba 100644
--- a/lib/facter/architecture.rb
+++ b/lib/facter/architecture.rb
@@ -23,3 +23,11 @@ Facter.add(:architecture) do
         end
     end
 end
+
+Facter.add(:architecture) do
+    confine :kernel => :openbsd
+    setcode do
+        architecture = Facter.value(:hardwaremodel)
+    end
+end
+
diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb
index 6880731..f0f0d45 100644
--- a/lib/facter/memory.rb
+++ b/lib/facter/memory.rb
@@ -44,3 +44,44 @@ if Facter.value(:kernel) == "AIX"
         end
     end
 end
+
+if Facter.value(:kernel) == "OpenBSD"
+    swap = Facter::Util::Resolution.exec('swapctl -l | sed 1d')
+    swapfree, swaptotal = 0, 0
+    swap.each do |dev|
+        if dev =~ /^\S+\s+(\S+)\s+\S+\s+(\S+)\s+.*$/
+            swaptotal += $1.to_i
+            swapfree  += $2.to_i
+        end
+    end
+
+    Facter.add("SwapSize") do
+        confine :kernel => :openbsd
+        setcode do
+            Facter::Memory.scale_number(swaptotal.to_f,"kB")
+        end
+    end
+
+    Facter.add("SwapFree") do
+        confine :kernel => :openbsd
+        setcode do
+            Facter::Memory.scale_number(swapfree.to_f,"kB")
+        end
+    end
+
+    Facter.add("MemoryFree") do
+        confine :kernel => :openbsd
+        memfree = Facter::Util::Resolution.exec("vmstat | tail -n 1 | awk '{ print $5 }'")
+        setcode do
+            Facter::Memory.scale_number(memfree.to_f,"kB")
+        end
+    end
+
+    Facter.add("MemoryTotal") do
+        confine :kernel => :openbsd
+        memtotal = Facter::Util::Resolution.exec("sysctl hw.physmem | cut -d'=' -f2")
+        setcode do
+            Facter::Memory.scale_number(memtotal.to_f,"")
+        end
+    end
+end
diff --git a/lib/facter/processor.rb b/lib/facter/processor.rb
index 154cced..53998ff 100644
--- a/lib/facter/processor.rb
+++ b/lib/facter/processor.rb
@@ -72,3 +72,19 @@ if Facter.value(:kernel) == "AIX"
         end
     end
 end
+
+if Facter.value(:kernel) == "OpenBSD"
+    Facter.add("Processor") do
+        confine :kernel => :openbsd
+        setcode do
+            Facter::Util::Resolution.exec("uname -p")
+        end
+    end
+    
+    Facter.add("ProcessorCount") do
+        confine :kernel => :openbsd 
+        setcode do
+            Facter::Util::Resolution.exec("sysctl hw.ncpu | cut -d'=' -f2")
+        end
+    end
+end

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list