summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2010-11-30 11:13:08 -0800
committerMatt Robinson <matt@puppetlabs.com>2010-11-30 11:13:08 -0800
commit3ebb5a550a6ce474dbc8edffbf15f90d60d3b711 (patch)
treec770be95c2851937278013ed0784432fb35289fd /lib
parent2cbbc2c1063cc46b1fb77e69e41a872d2e5bfae1 (diff)
parent1985528c9e70095116f84d4f4849c149602fffec (diff)
downloadfacter-3ebb5a550a6ce474dbc8edffbf15f90d60d3b711.tar.gz
facter-3ebb5a550a6ce474dbc8edffbf15f90d60d3b711.tar.xz
facter-3ebb5a550a6ce474dbc8edffbf15f90d60d3b711.zip
Merge branch 'ticket/next/4754' into next
* ticket/next/4754: (#4754) Change is_virtual logic to not enumerate virtual types (#4754) Add support for Darwin and Parallels VM to "virtual" fact
Diffstat (limited to 'lib')
-rw-r--r--lib/facter/virtual.rb36
1 files changed, 29 insertions, 7 deletions
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index a8afb60..8412a0a 100644
--- a/lib/facter/virtual.rb
+++ b/lib/facter/virtual.rb
@@ -1,6 +1,24 @@
require 'facter/util/virtual'
Facter.add("virtual") do
+ confine :kernel => "Darwin"
+
+ setcode do
+ require 'facter/util/macosx'
+ result = "physical"
+ output = Facter::Util::Macosx.profiler_data("SPDisplaysDataType")
+ if output.is_a?(Hash)
+ result = "parallels" if output["spdisplays_vendor-id"] =~ /0x1ab8/
+ result = "parallels" if output["spdisplays_vendor"] =~ /[Pp]arallels/
+ result = "vmware" if output["spdisplays_vendor-id"] =~ /0x15ad/
+ result = "vmware" if output["spdisplays_vendor"] =~ /VM[wW]are/
+ end
+ result
+ end
+end
+
+
+Facter.add("virtual") do
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX}
result = "physical"
@@ -53,18 +71,23 @@ Facter.add("virtual") do
# --- look for the vmware video card to determine if it is virtual => vmware.
# --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter
result = "vmware" if p =~ /VM[wW]are/
+ # --- look for pci vendor id used by Parallels video card
+ # --- 01:00.0 VGA compatible controller: Unknown device 1ab8:4005
+ result = "parallels" if p =~ /1ab8:|[Pp]arallels/
end
else
output = Facter::Util::Resolution.exec('dmidecode')
if not output.nil?
output.each_line do |pd|
- result = "vmware" if pd =~ /VMware|Parallels/
+ result = "parallels" if pd =~ /Parallels/
+ result = "vmware" if pd =~ /VMware/
end
else
output = Facter::Util::Resolution.exec('prtdiag')
if not output.nil?
output.each_line do |pd|
- result = "vmware" if pd =~ /VMware|Parallels/
+ result = "parallels" if pd =~ /Parallels/
+ result = "vmware" if pd =~ /VMware/
end
end
end
@@ -78,15 +101,14 @@ Facter.add("virtual") do
result
end
end
-
+
Facter.add("is_virtual") do
- confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX}
+ confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX Darwin}
setcode do
- case Facter.value(:virtual)
- when "xenu", "openvzve", "vmware", "kvm", "vserver", "jail", "zone", "hpvm"
+ if Facter.value(:virtual) != "physical" && Facter.value(:virtual) != "xen0"
"true"
- else
+ else
"false"
end
end