19268753 Facter incorrectly reports is_virtual=false in LDOM or kernel zone guests
authorPatrick Einheber <patrick.einheber@oracle.com>
Fri, 03 Jun 2016 13:09:41 -0700
changeset 6136 428f5dba7242
parent 6135 d3413bce6809
child 6137 f81b30a97f44
19268753 Facter incorrectly reports is_virtual=false in LDOM or kernel zone guests
components/ruby/facter/patches/facter-04-FACT-660.patch
components/ruby/facter/patches/facter-07-19268753-kz.patch
--- a/components/ruby/facter/patches/facter-04-FACT-660.patch	Fri Jun 03 11:11:06 2016 -0700
+++ b/components/ruby/facter/patches/facter-04-FACT-660.patch	Fri Jun 03 13:09:41 2016 -0700
@@ -32,7 +32,7 @@
 +Facter.add("non_global_zone") do
 +  confine :operatingsystem => :Solaris
 +  setcode do
-+      virtinfo = %x{/sbin/virtinfo list -H -o class non-global-zone 2>/dev/null}
++      virtinfo = %x{/sbin/virtinfo list | /usr/bin/nawk '/^non-global-zone/ {print $2}' 2>/dev/null}
 +      case virtinfo.chomp!
 +      when "supported", "current"
 +          virtinfo
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ruby/facter/patches/facter-07-19268753-kz.patch	Fri Jun 03 13:09:41 2016 -0700
@@ -0,0 +1,39 @@
+Use virtinfo to determine if running in a kernel-zone when checking for zone
+No upstream facter 2.x is dead and new bugs are not being accepted.
+--- facter-2.4.6/lib/facter/util/solaris_zones.rb.orig	2016-06-01 10:44:41.516631538 -0700
++++ facter-2.4.6/lib/facter/util/solaris_zones.rb	2016-06-01 10:46:24.859533768 -0700
+@@ -186,3 +186,16 @@
+       end
+   end
+ end
++
++Facter.add("is_kernel_zone") do
++  confine :operatingsystem => :Solaris
++  setcode do
++  virtinfo = %x{/sbin/virtinfo -c current list -H -o class kernel-zone 2>&1}
++    case virtinfo.chomp!
++    when "current"
++      true
++    else
++      false
++    end
++  end
++end
+
+--- facter-2.4.6/lib/facter/util/virtual.rb.orig	2016-06-01 10:46:41.238895210 -0700
++++ facter-2.4.6/lib/facter/util/virtual.rb	2016-06-01 10:47:17.692020885 -0700
+@@ -1,5 +1,6 @@
+ require 'facter/util/posix'
+ require 'facter/util/file_read'
++require 'facter/util/solaris_zones'
+ require 'pathname'
+ 
+ module Facter::Util::Virtual
+@@ -73,6 +74,7 @@
+   end
+ 
+   def self.zone?
++    return true if Facter.value(:is_kernel_zone)
+     return true if FileTest.directory?("/.SUNWnative")
+     z = Facter::Core::Execution.exec("/sbin/zonename")
+     return false unless z