git.diff
| b/lib/facter/virtual.rb | ||
|---|---|---|
| 46 | 46 |
result = "xen0" |
| 47 | 47 |
end |
| 48 | 48 |
end |
| 49 |
|
|
| 49 | ||
| 50 |
if Facter.value(:manufacturer) =~ /vmware/i |
|
| 51 |
result = "vmware" |
|
| 52 |
end |
|
| 53 | ||
| 50 | 54 |
if result == "physical" |
| 51 |
output = Facter::Util::Resolution.exec('lspci')
|
|
| 52 |
if not output.nil? |
|
| 53 |
output.each_line do |p| |
|
| 54 |
# --- look for the vmware video card to determine if it is virtual => vmware. |
|
| 55 |
# --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter |
|
| 56 |
result = "vmware" if p =~ /VM[wW]are/ |
|
| 57 |
end |
|
| 58 |
else |
|
| 59 |
output = Facter::Util::Resolution.exec('dmidecode')
|
|
| 60 |
if not output.nil? |
|
| 61 |
output.each_line do |pd| |
|
| 62 |
result = "vmware" if pd =~ /VMware|Parallels/ |
|
| 63 |
end |
|
| 64 |
else |
|
| 65 |
output = Facter::Util::Resolution.exec('prtdiag')
|
|
| 55 |
commands = [ |
|
| 56 |
'lspci', |
|
| 57 |
'dmidecode', |
|
| 58 |
'prtdiag', |
|
| 59 |
'vmware -v | awk \'{ print $1"_"$2 }\' | tr [:upper:] [:lower:]'
|
|
| 60 |
] |
|
| 61 | ||
| 62 |
virt_platforms = [ |
|
| 63 |
'vmware', |
|
| 64 |
'vmware_server', |
|
| 65 |
'vmware_workstation' |
|
| 66 |
] |
|
| 67 | ||
| 68 |
catch "ResultFound" do |
|
| 69 |
commands.each do |command| |
|
| 70 |
output = Facter::Util::Resolution.exec(command) |
|
| 66 | 71 |
if not output.nil? |
| 67 |
output.each_line do |pd| |
|
| 68 |
result = "vmware" if pd =~ /VMware|Parallels/ |
|
| 72 |
output.each_line do |p| |
|
| 73 |
virt_platforms.each do |vp| |
|
| 74 |
if vp =~ /#{p}/i
|
|
| 75 |
result = vp |
|
| 76 |
throw "ResultFound" |
|
| 77 |
end |
|
| 78 |
end |
|
| 69 | 79 |
end |
| 70 | 80 |
end |
| 71 | 81 |
end |
| 72 | 82 |
end |
| 73 | 83 |
end |
| 74 | 84 | |
| 75 |
# VMware server 1.0.3 rpm places vmware-vmx in this place, other versions or platforms may not. |
|
| 76 |
if FileTest.exists?("/usr/lib/vmware/bin/vmware-vmx")
|
|
| 77 |
result = "vmware_server" |
|
| 78 |
end |
|
| 79 | ||
| 80 | 85 |
result |
| 81 | 86 |
end |
| 82 | 87 |
end |
| ... | ... | |
| 88 | 93 |
case Facter.value(:virtual) |
| 89 | 94 |
when "xenu", "openvzve", "vmware" |
| 90 | 95 |
true |
| 91 |
else
|
|
| 96 |
else |
|
| 92 | 97 |
false |
| 93 | 98 |
end |
| 94 | 99 |
end |