summaryrefslogtreecommitdiffstats
path: root/lib/facter/virtual.rb
diff options
context:
space:
mode:
authorPeter Meier <peter.meier@immerda.ch>2009-03-10 21:33:29 +0100
committerJames Turnbull <james@lovedthanlost.net>2009-03-17 23:46:09 +1100
commita6d6ba5454a805cf95a7aa4def0c12afc180b958 (patch)
tree9c76a17378566698134b4d541be0a24642eec823 /lib/facter/virtual.rb
parent89a3aa8097c2e4690c835905dec49df2bc333b30 (diff)
downloadfacter-a6d6ba5454a805cf95a7aa4def0c12afc180b958.tar.gz
facter-a6d6ba5454a805cf95a7aa4def0c12afc180b958.tar.xz
facter-a6d6ba5454a805cf95a7aa4def0c12afc180b958.zip
Use resultion.exec util instead of which checks
Use rather our util to exec commands than implementing our own hack.
Diffstat (limited to 'lib/facter/virtual.rb')
-rw-r--r--lib/facter/virtual.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index 2c92532..97d7cba 100644
--- a/lib/facter/virtual.rb
+++ b/lib/facter/virtual.rb
@@ -30,25 +30,22 @@ Facter.add("virtual") do
end
if result == "physical"
- path = %x{which lspci 2> /dev/null}.chomp
- if path !~ /no lspci/
- output = %x{#{path}}
+ output = Facter::Util::Resolution.exec('lspci')
+ if not output.nil?
output.each do |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/
end
else
- path = %x{which dmidecode 2> /dev/null}.chomp
- if path !~ /no dmidecode/
- output = %x{#{path}}
+ output = Facter::Util::Resolution.exec('dmidecode')
+ if not output.nil?
output.each do |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 = Facter::Util::Resolution.exec('prtdiag')
+ if not output.nil?
output.each do |pd|
result = "vmware" if pd =~ /VMware|Parallels/
end
@@ -62,9 +59,8 @@ Facter.add("virtual") do
result = "vmware_server"
end
- mountexists = system "which mount > /dev/null 2>&1"
- if $?.exitstatus == 0
- output = %x{mount}
+ output = Facter::Util::Resolution.exec('mount')
+ if not output.nil?
output.each do |p|
result = "vserver" if p =~ /\/dev\/hdv1/
end