parent
97e8b31049
commit
3ecf208a26
@ -1,73 +0,0 @@
|
||||
From 39382efcf16e3f3b30ce8284ae3aefcf09b1b2d6 Mon Sep 17 00:00:00 2001
|
||||
From: Todd Zullinger <tmz@pobox.com>
|
||||
Date: Fri, 29 Mar 2013 19:31:59 -0400
|
||||
Subject: [PATCH] (#19989) Filter virt-what warnings from virtual fact
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Presently, the virt-what command puts errors on stdout, prefixed with
|
||||
virt-what:. This ends up in the virtual fact, which is undesirable.
|
||||
|
||||
When a fixed virt-what is released and available for supported systems,
|
||||
the 'output.gsub /^virt-what: .*$/' can be removed from
|
||||
Facter::Util::Virtual::virt_what().
|
||||
|
||||
A virt-what fix was committed upstream¹.
|
||||
|
||||
Thanks to Adrien Thebo for help on making this testable.
|
||||
|
||||
This also rolls in a follow-up fix to suppress warnings when virt-what
|
||||
produces no output:
|
||||
|
||||
4a59d36 ((Maint) Don't parse nil Facter::Util::Resolution output)
|
||||
|
||||
¹ http://git.annexia.org/?p=virt-what.git;a=commitdiff;h=2f47e06
|
||||
|
||||
Conflicts:
|
||||
spec/unit/util/virtual_spec.rb
|
||||
---
|
||||
lib/facter/util/virtual.rb | 10 +++++++++-
|
||||
spec/unit/util/virtual_spec.rb | 6 ++++++
|
||||
2 files changed, 15 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb
|
||||
index 41472b8..534f31a 100644
|
||||
--- a/lib/facter/util/virtual.rb
|
||||
+++ b/lib/facter/util/virtual.rb
|
||||
@@ -3,8 +3,16 @@ module Facter::Util::Virtual
|
||||
# virt_what is a delegating helper method intended to make it easier to stub
|
||||
# the system call without affecting other calls to
|
||||
# Facter::Util::Resolution.exec
|
||||
+ #
|
||||
+ # Per https://bugzilla.redhat.com/show_bug.cgi?id=719611 when run as a
|
||||
+ # non-root user the virt-what command may emit an error message on stdout,
|
||||
+ # and later versions of virt-what may emit this message on stderr. This
|
||||
+ # method ensures stderr is redirected and that error messages are stripped
|
||||
+ # from stdout.
|
||||
def self.virt_what(command = "virt-what")
|
||||
- Facter::Util::Resolution.exec command
|
||||
+ redirected_cmd = "#{command} 2>/dev/null"
|
||||
+ output = Facter::Util::Resolution.exec redirected_cmd
|
||||
+ output.gsub(/^virt-what: .*$/, '') if output
|
||||
end
|
||||
|
||||
##
|
||||
diff --git a/spec/unit/util/virtual_spec.rb b/spec/unit/util/virtual_spec.rb
|
||||
index da74d70..c50084b 100755
|
||||
--- a/spec/unit/util/virtual_spec.rb
|
||||
+++ b/spec/unit/util/virtual_spec.rb
|
||||
@@ -181,4 +181,10 @@ describe Facter::Util::Virtual do
|
||||
Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server rx660')
|
||||
Facter::Util::Virtual.should_not be_hpvm
|
||||
end
|
||||
+
|
||||
+ it "should strip out warnings on stdout from virt-what" do
|
||||
+ virt_what_warning = "virt-what: this script must be run as root"
|
||||
+ Facter::Util::Resolution.expects(:exec).with('virt-what 2>/dev/null').returns virt_what_warning
|
||||
+ Facter::Util::Virtual.virt_what.should_not match /^virt-what: /
|
||||
+ end
|
||||
end
|
||||
--
|
||||
1.7.11.7
|
||||
|
@ -1,21 +0,0 @@
|
||||
diff -uNr facter-1.6.18/lib/facter/ipaddress.rb facter-1.6.18/lib/facter/ipaddress.rb
|
||||
--- lib/facter/ipaddress.rb 2013-03-13 14:17:44.000000000 -0400
|
||||
+++ lib/facter/ipaddress.rb 2013-06-21 20:44:33.997664732 -0400
|
||||
@@ -28,10 +28,14 @@
|
||||
confine :kernel => :linux
|
||||
setcode do
|
||||
ip = nil
|
||||
- if output = Facter::Util::IP.exec_ifconfig(["2>/dev/null"])
|
||||
+ output = Facter::Util::IP.exec_ifconfig(["2>/dev/null"])
|
||||
+ if output
|
||||
regexp = /inet (?:addr:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
|
||||
- if match = regexp.match(output)
|
||||
- match[1] unless /^127/.match(match[1])
|
||||
+ output.split("\n").each do |line|
|
||||
+ match = regexp.match(line)
|
||||
+ if match
|
||||
+ break match[1] unless /^127/.match(match[1])
|
||||
+ end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,12 +0,0 @@
|
||||
diff -up facter-1.7.4/lib/facter/virtual.rb.dmidecode-drop-stderr facter-1.7.4/lib/facter/virtual.rb
|
||||
--- facter-1.7.4/lib/facter/virtual.rb.dmidecode-drop-stderr 2013-12-17 15:23:22.000000000 -0500
|
||||
+++ facter-1.7.4/lib/facter/virtual.rb 2014-01-28 18:28:27.604949053 -0500
|
||||
@@ -133,7 +133,7 @@ Facter.add("virtual") do
|
||||
end
|
||||
|
||||
# Parse dmidecode
|
||||
- output = Facter::Util::Resolution.exec('dmidecode')
|
||||
+ output = Facter::Util::Resolution.exec('dmidecode 2>/dev/null')
|
||||
if output
|
||||
lines = output.split("\n")
|
||||
next "parallels" if lines.any? {|l| l =~ /Parallels/ }
|
Loading…
Reference in new issue