7
if FileTest.exists?("/proc/user_beancounters")
8
# openvz. can be hardware node or virtual environment
9
# read the init process' status file, it has laxer permissions
10
# than /proc/user_beancounters (so this won't fail as non-root)
11
txt = File.read("/proc/1/status")
12
if txt =~ /^envID:[[:blank:]]+0$/mi
9
if FileTest.exists?("/sbin/zonename")
10
z = %x{"/sbin/zonename"}.chomp
16
if FileTest.exists?("/proc/vz/veinfo")
17
if FileTest.exists?("/proc/vz/version")
13
18
result = "openvzhn"
15
20
result = "openvzve"
19
if FileTest.exists?("/proc/xen/capabilities") && FileTest.readable?("/proc/xen/capabilities")
24
if FileTest.exists?("/proc/self/status")
25
txt = File.read("/proc/self/status")
26
if txt =~ /^(s_context|VxID):[[:blank:]]*[1-9]/
31
if FileTest.exists?("/proc/virtual")
32
result = "vserver_host"
35
# new Xen domains have this in dom0 not domu :(
36
if FileTest.exists?("/proc/sys/xen/independent_wallclock")
39
if FileTest.exists?("/sys/bus/xen")
43
if FileTest.exists?("/proc/xen/capabilities")
20
44
txt = File.read("/proc/xen/capabilities")
21
45
if txt =~ /control_d/i
28
50
if result == "physical"
29
path = %x{which lspci 2> /dev/null}.chomp
51
output = Facter::Util::Resolution.exec('lspci')
53
output.each_line do |p|
33
54
# --- look for the vmware video card to determine if it is virtual => vmware.
34
55
# --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter
35
56
result = "vmware" if p =~ /VM[wW]are/
38
path = %x{which dmidecode 2> /dev/null}.chomp
39
if path !~ /no dmidecode/
59
output = Facter::Util::Resolution.exec('dmidecode')
61
output.each_line do |pd|
42
62
result = "vmware" if pd =~ /VMware|Parallels/
45
path = %x{which prtdiag 2> /dev/null}.chomp
46
if path !~ /no prtdiag/
65
output = Facter::Util::Resolution.exec('prtdiag')
67
output.each_line do |pd|
49
68
result = "vmware" if pd =~ /VMware|Parallels/
58
77
result = "vmware_server"
61
mountexists = system "which mount > /dev/null 2>&1"
65
result = "vserver" if p =~ /\/dev\/hdv1/
69
if FileTest.directory?('/proc/virtual')
70
result = "vserver_host"
84
Facter.add("is_virtual") do
85
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS}
88
case Facter.value(:virtual)
89
when "xenu", "openvzve", "vmware"