[Pkg-puppet-devel] [facter] 162/180: (FACT-664) Fix swap facts for SmartOS container

Stig Sandbeck Mathisen ssm at debian.org
Mon Jun 30 15:06:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 46eac60e69e4f3112b338e5409f6182947c450cd
Author: Steven Williamson <steve at freeagent.com>
Date:   Fri Apr 18 11:53:15 2014 +0100

    (FACT-664) Fix swap facts for SmartOS container
    
    Inside a SmartOS container swap facts report 0 for size and free even
    though a swap volume is allocated. This removes the leading '/' to match
    the smartos swap format.
---
 lib/facter/util/memory.rb                            |  2 +-
 spec/fixtures/unit/memory/smartos_zone_swap_l-single |  2 ++
 spec/unit/memory_spec.rb                             | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/facter/util/memory.rb b/lib/facter/util/memory.rb
index 9b64349..8b2b2ad 100644
--- a/lib/facter/util/memory.rb
+++ b/lib/facter/util/memory.rb
@@ -205,7 +205,7 @@ module Facter::Memory
         0
       end
     when /SunOS/i
-      if line =~ /^\/\S+\s.*\s+(\d+)\s+(\d+)$/
+      if line =~ /^\S+\s.*\s+(\d+)\s+(\d+)$/
         (is_size) ? $1.to_i : $2.to_i
       else
         0
diff --git a/spec/fixtures/unit/memory/smartos_zone_swap_l-single b/spec/fixtures/unit/memory/smartos_zone_swap_l-single
new file mode 100644
index 0000000..6e8c9fe
--- /dev/null
+++ b/spec/fixtures/unit/memory/smartos_zone_swap_l-single
@@ -0,0 +1,2 @@
+swapfile             dev    swaplo   blocks     free
+swap                  -          8 100663296 68968568
diff --git a/spec/unit/memory_spec.rb b/spec/unit/memory_spec.rb
index 575f616..4e22f9a 100755
--- a/spec/unit/memory_spec.rb
+++ b/spec/unit/memory_spec.rb
@@ -214,6 +214,7 @@ describe "Memory facts" do
     end
   end
 
+
   describe "on Solaris" do
     before(:each) do
       Facter.clear
@@ -249,6 +250,7 @@ describe "Memory facts" do
       it "should return the current swap size in MB" do
         Facter.fact(:swapsize_mb).value.should == "1023.99"
       end
+
     end
 
     describe "when multiple swaps exist" do
@@ -297,6 +299,22 @@ describe "Memory facts" do
         Facter.fact(:swapsize_mb).value.should == "0.00"
       end
     end
+
+    describe "when in a SmartOS zone" do
+      before(:each) do
+        Facter::Core::Execution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns my_fixture_read('smartos_zone_swap_l-single')
+        Facter.collection.internal_loader.load(:memory)
+      end
+
+      it "should return the current swap size in MB" do
+        Facter.fact(:swapsize_mb).value.should == "49152.00"
+      end
+
+      it "should return the current swap free in MB" do
+        Facter.fact(:swapfree_mb).value.should == "33676.06"
+      end
+    end
+
   end
 
     describe "on DragonFly BSD" do

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list