[Pkg-puppet-devel] [facter] 35/352: (#22322) Suppress swap stderr on AIX and Solaris
Stig Sandbeck Mathisen
ssm at debian.org
Sun Apr 6 22:21:29 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 f457f598e3785834c81ee5730a0eb7e85566b33e
Author: Adrien Thebo <git at somethingsinistral.net>
Date: Tue Oct 1 15:33:40 2013 -0700
(#22322) Suppress swap stderr on AIX and Solaris
When `swap -l` is run on Solaris and no swap devices are present,
the command emits "No swap devices configured". This commit squelches
the stderr output to reduce the noice produced when running Facter.
This supersedes GH-530.
---
lib/facter/util/memory.rb | 4 ++--
spec/unit/memory_spec.rb | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/facter/util/memory.rb b/lib/facter/util/memory.rb
index 7c63dd0..9a2401e 100644
--- a/lib/facter/util/memory.rb
+++ b/lib/facter/util/memory.rb
@@ -134,7 +134,7 @@ module Facter::Memory
def self.swap_info(kernel = Facter.value(:kernel))
case kernel
when /AIX/i
- (Facter.value(:id) == "root") ? Facter::Util::Resolution.exec('swap -l') : nil
+ (Facter.value(:id) == "root") ? Facter::Util::Resolution.exec('swap -l 2>/dev/null') : nil
when /OpenBSD/i
Facter::Util::Resolution.exec('swapctl -s')
when /FreeBSD/i
@@ -142,7 +142,7 @@ module Facter::Memory
when /Darwin/i
Facter::Util::Resolution.exec('sysctl vm.swapusage')
when /SunOS/i
- Facter::Util::Resolution.exec('/usr/sbin/swap -l')
+ Facter::Util::Resolution.exec('/usr/sbin/swap -l 2>/dev/null')
end
end
diff --git a/spec/unit/memory_spec.rb b/spec/unit/memory_spec.rb
index 2de005e..d249d5b 100755
--- a/spec/unit/memory_spec.rb
+++ b/spec/unit/memory_spec.rb
@@ -154,7 +154,7 @@ device maj,min total free
/dev/hd6 10, 2 512MB 508MB
SWAP
- Facter::Util::Resolution.stubs(:exec).with('swap -l').returns(swapusage)
+ Facter::Util::Resolution.stubs(:exec).with('swap -l 2>/dev/null').returns(swapusage)
Facter.collection.internal_loader.load(:memory)
end
@@ -264,7 +264,7 @@ VMSTAT
swapfile dev swaplo blocks free
/dev/swap 4294967295,4294967295 16 2097136 2097136
SWAP
- Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l').returns sample_swap_line
+ Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
Facter.collection.internal_loader.load(:memory)
end
@@ -293,7 +293,7 @@ swapfile dev swaplo blocks free
/dev/swap 4294967295,4294967295 16 2097136 2097136
/dev/swap2 4294967295,4294967295 16 2097136 2097136
SWAP
- Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l').returns sample_swap_line
+ Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
Facter.collection.internal_loader.load(:memory)
end
@@ -316,7 +316,7 @@ SWAP
describe "when no swap exists" do
before(:each) do
- Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l').returns ""
+ Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns ""
Facter.collection.internal_loader.load(:memory)
end
--
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