Avoid warnings when virt-what produces no output

The previous patch caused spurious warnings from facter when the
virt-what command produced no output, as it would if run by root on a
physical host:

$ sudo facter virtual
Could not retrieve virtual: private method `gsub' called for nil:NilClass
physical

Josh Cooper from Puppet Labs caught and fixed this.
epel9
Todd Zullinger 12 years ago
parent be66d28fa4
commit 4b98da968b

@ -1,4 +1,4 @@
From c823dd47277bc88b95062dda726800860c75f1c3 Mon Sep 17 00:00:00 2001 From 39382efcf16e3f3b30ce8284ae3aefcf09b1b2d6 Mon Sep 17 00:00:00 2001
From: Todd Zullinger <tmz@pobox.com> From: Todd Zullinger <tmz@pobox.com>
Date: Fri, 29 Mar 2013 19:31:59 -0400 Date: Fri, 29 Mar 2013 19:31:59 -0400
Subject: [PATCH] (#19989) Filter virt-what warnings from virtual fact Subject: [PATCH] (#19989) Filter virt-what warnings from virtual fact
@ -17,6 +17,11 @@ A virt-what fix was committed upstream¹.
Thanks to Adrien Thebo for help on making this testable. 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 ¹ http://git.annexia.org/?p=virt-what.git;a=commitdiff;h=2f47e06
Conflicts: Conflicts:
@ -27,7 +32,7 @@ Conflicts:
2 files changed, 15 insertions(+), 1 deletion(-) 2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb
index 41472b8..b5fa09d 100644 index 41472b8..534f31a 100644
--- a/lib/facter/util/virtual.rb --- a/lib/facter/util/virtual.rb
+++ b/lib/facter/util/virtual.rb +++ b/lib/facter/util/virtual.rb
@@ -3,8 +3,16 @@ module Facter::Util::Virtual @@ -3,8 +3,16 @@ module Facter::Util::Virtual
@ -44,7 +49,7 @@ index 41472b8..b5fa09d 100644
- Facter::Util::Resolution.exec command - Facter::Util::Resolution.exec command
+ redirected_cmd = "#{command} 2>/dev/null" + redirected_cmd = "#{command} 2>/dev/null"
+ output = Facter::Util::Resolution.exec redirected_cmd + output = Facter::Util::Resolution.exec redirected_cmd
+ output.gsub(/^virt-what: .*$/, '') + output.gsub(/^virt-what: .*$/, '') if output
end end
## ##

@ -16,7 +16,7 @@
Name: facter Name: facter
Version: 1.6.18 Version: 1.6.18
Release: 2%{?dist} Release: 3%{?dist}
Summary: Command and ruby library for gathering system information Summary: Command and ruby library for gathering system information
Group: System Environment/Base Group: System Environment/Base
@ -112,6 +112,9 @@ rspec spec
%changelog %changelog
* Wed Apr 03 2013 Todd Zullinger <tmz@pobox.com> - 1.6.18-3
- Avoid warnings when virt-what produces no output
* Tue Apr 02 2013 Todd Zullinger <tmz@pobox.com> - 1.6.18-2 * Tue Apr 02 2013 Todd Zullinger <tmz@pobox.com> - 1.6.18-2
- Apply upstream patch to filter virt-what warnings from virtual fact - Apply upstream patch to filter virt-what warnings from virtual fact

Loading…
Cancel
Save