summaryrefslogtreecommitdiffstats
path: root/lib/facter/virtual.rb
diff options
context:
space:
mode:
authorDonavan Miller <donavan@strewth.org>2010-11-30 10:35:17 -0800
committerMatt Robinson <matt@puppetlabs.com>2010-11-30 11:08:14 -0800
commit739040f234c356133e2cb72318f687e8c0e56b9b (patch)
tree9daf3312af367a9a7c73449884a9bec6bd22782b /lib/facter/virtual.rb
parent2cbbc2c1063cc46b1fb77e69e41a872d2e5bfae1 (diff)
downloadfacter-739040f234c356133e2cb72318f687e8c0e56b9b.tar.gz
facter-739040f234c356133e2cb72318f687e8c0e56b9b.tar.xz
facter-739040f234c356133e2cb72318f687e8c0e56b9b.zip
(#4754) Add support for Darwin and Parallels VM to "virtual" fact
Adds support for Parallels VM guest detection with existing operating systems. Detects Parallels based on hardware vendor name and pci id. The Parallels vendor id does not seem to be listed in most pci.ids. Adds resolution for "virtual" fact in the Darwin kernel. This uses the existing Facter::Util::Macosx module to resolve system profiler data. Both vendor name and vendor id values are checked. Resolution appears to vary based on VM Host product. Signed-off-by: donavanm <donavan@desinc.net>
Diffstat (limited to 'lib/facter/virtual.rb')
-rw-r--r--lib/facter/virtual.rb35
1 files changed, 29 insertions, 6 deletions
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index a8afb60..a3b7163 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,15 @@ 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"
+ when "xenu", "openvzve", "vmware", "kvm", "vserver", "jail", "zone", "hpvm", "parallels"
"true"
- else
+ else
"false"
end
end