components/facter/patches/facter-02-virtual-zones-facts.patch
changeset 1409 9db4ba32e740
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/facter/patches/facter-02-virtual-zones-facts.patch	Mon Jul 29 16:02:38 2013 -0600
@@ -0,0 +1,69 @@
+Add output for kernel zones and fix prtdiag output so that it doesn't report
+an error in a kernel zone.
+--- facter-1.6.16/lib/facter/virtual.rb.orig	2013-06-10 15:19:45.461022623 -0600
++++ facter-1.6.16/lib/facter/virtual.rb	2013-06-10 15:22:54.164653119 -0600
+@@ -119,9 +119,9 @@
+             result = "hyperv" if pd =~ /Product Name: Virtual Machine/
+           end
+         elsif Facter.value(:kernel) == 'SunOS'
+-          res = Facter::Util::Resolution.new('prtdiag')
++          res = Facter::Util::Resolution.new('/usr/sbin/prtdiag 2>/dev/null')
+           res.timeout = 6
+-          res.setcode('prtdiag')
++          res.setcode('/usr/sbin/prtdiag 2>/dev/null')
+           output = res.value
+           if not output.nil?
+             output.each_line do |pd|
+@@ -210,3 +210,52 @@
+     end
+   end
+ end
++
++#
++# Fact: kernel_zone
++#
++# Purpose: A facter fact to report kernel zones status on a system.
++#
++# Resolution: Provides the following kernel zone information.
++# supported: kernel zones are supported
++# unsupported: kernel zones are not supported
++# current: the current environment is a kernel zone
++# parent: the current environment is a child of a kernel zone
++#
++Facter.add("kernel_zone") do
++  confine :operatingsystem => :Solaris
++  setcode do
++      virtinfo = %x{/sbin/virtinfo list -H -o class kernel-zone 2>/dev/null}
++      case virtinfo.chomp!
++      when "supported"
++      when "current"
++      when "parent"
++          virtinfo
++      else
++          "unsupported"
++      end
++  end
++end
++
++#
++# Fact: non_global_zone
++#
++# Purpose: A facter fact to report non-global zone status on a system.
++#
++# Resolution: Provides the following kernel zone information.
++# current: the current environment is a non-global zone
++# Otherwise returns supported because non-global zones are supported
++# in Solaris in both global and kernel zones.
++#
++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}
++      case virtinfo.chomp!
++      when "current"
++          virtinfo
++      else
++          "supported"
++     end
++  end
++end