summaryrefslogtreecommitdiffstats
path: root/lib/facter/virtual.rb
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-12-22 19:42:03 +1100
committerJames Turnbull <james@lovedthanlost.net>2008-12-22 19:42:03 +1100
commita70184a1bd94a045c5e62b2e6a355da34ddf697f (patch)
tree58c30136574966d4c025f6d528659e194640b134 /lib/facter/virtual.rb
parent99833a1b5b32e87dc73f66d16fc57ba91c070b13 (diff)
downloadfacter-a70184a1bd94a045c5e62b2e6a355da34ddf697f.tar.gz
facter-a70184a1bd94a045c5e62b2e6a355da34ddf697f.tar.xz
facter-a70184a1bd94a045c5e62b2e6a355da34ddf697f.zip
Fixed #1791 - support for virtual fact on Solaris 10
Diffstat (limited to 'lib/facter/virtual.rb')
-rw-r--r--lib/facter/virtual.rb26
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index 17d6538..db8dc33 100644
--- a/lib/facter/virtual.rb
+++ b/lib/facter/virtual.rb
@@ -1,5 +1,5 @@
Facter.add("virtual") do
- confine :kernel => %w{Linux FreeBSD OpenBSD}
+ confine :kernel => %w{Linux FreeBSD OpenBSD SunOS}
result = "physical"
@@ -27,22 +27,30 @@ Facter.add("virtual") do
end
if result == "physical"
- lspciexists = system "which lspci > /dev/null 2>&1"
- if $?.exitstatus == 0
- output = %x{lspci}
+ path = %x{which lspci 2> /dev/null}.chomp
+ if path !~ /no lspci/
+ output = %x{#{path}}
output.each {|p|
# --- 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/
}
else
- dmidecodeexists = system "which dmidecode > /dev/null 2>&1"
- if $?.exitstatus == 0
- outputd = %x{dmidecode}
- outputd.each {|pd|
+ path = %x{which dmidecode 2> /dev/null}.chomp
+ if path !~ /no dmidecode/
+ output = %x{#{path}}
+ output.each {|pd|
result = "vmware" if pd =~ /VMware|Parallels/
}
- end
+ else
+ path = %x{which prtdiag 2> /dev/null}.chomp
+ if path !~ /no prtdiag/
+ output = %x{#{path}}
+ output.each {|pd|
+ result = "vmware" if pd =~ /VMware|Parallels/
+ }
+ end
+ end
end
end