[facter] Avoid warnings when virt-what produces no output

Todd Zullinger tmz at fedoraproject.org
Wed Apr 3 21:38:45 UTC 2013


commit 4b98da968bae319d2a82da378fd51f932486420f
Author: Todd Zullinger <tmz at pobox.com>
Date:   Wed Apr 3 17:20:40 2013 -0400

    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.

 ...lter-virt-what-warnings-from-virtual-fact.patch |   11 ++++++++---
 facter.spec                                        |    5 ++++-
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/0001-19989-Filter-virt-what-warnings-from-virtual-fact.patch b/0001-19989-Filter-virt-what-warnings-from-virtual-fact.patch
index d4d32d7..8ef9e2e 100644
--- a/0001-19989-Filter-virt-what-warnings-from-virtual-fact.patch
+++ b/0001-19989-Filter-virt-what-warnings-from-virtual-fact.patch
@@ -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 at pobox.com>
 Date: Fri, 29 Mar 2013 19:31:59 -0400
 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.
 
+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:
@@ -27,7 +32,7 @@ Conflicts:
  2 files changed, 15 insertions(+), 1 deletion(-)
 
 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
 +++ b/lib/facter/util/virtual.rb
 @@ -3,8 +3,16 @@ module Facter::Util::Virtual
@@ -44,7 +49,7 @@ index 41472b8..b5fa09d 100644
 -    Facter::Util::Resolution.exec command
 +    redirected_cmd = "#{command} 2>/dev/null"
 +    output = Facter::Util::Resolution.exec redirected_cmd
-+    output.gsub(/^virt-what: .*$/, '')
++    output.gsub(/^virt-what: .*$/, '') if output
    end
  
    ##
diff --git a/facter.spec b/facter.spec
index 0aff157..cf212ea 100644
--- a/facter.spec
+++ b/facter.spec
@@ -16,7 +16,7 @@
 
 Name:           facter
 Version:        1.6.18
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Command and ruby library for gathering system information
 
 Group:          System Environment/Base
@@ -112,6 +112,9 @@ rspec spec
 
 
 %changelog
+* Wed Apr 03 2013 Todd Zullinger <tmz at pobox.com> - 1.6.18-3
+- Avoid warnings when virt-what produces no output
+
 * Tue Apr 02 2013 Todd Zullinger <tmz at pobox.com> - 1.6.18-2
 - Apply upstream patch to filter virt-what warnings from virtual fact
 


More information about the scm-commits mailing list