diff options
author | James Turnbull <james@lovedthanlost.net> | 2008-10-07 11:29:10 +1100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-10-21 10:20:33 +1100 |
commit | 6393e82e86def14891b204803aba156059736749 (patch) | |
tree | 8e6e8d75e26243b645bfd9639456a27d8eb11e21 /lib/facter/virtual.rb | |
parent | 37b14d219f89fdef8aea4a7bddb13eeb736b0dc7 (diff) | |
download | facter-6393e82e86def14891b204803aba156059736749.tar.gz facter-6393e82e86def14891b204803aba156059736749.tar.xz facter-6393e82e86def14891b204803aba156059736749.zip |
Fixed #1634 - Update virtual fact to differentiate OpenVZ hardware nodes and virtual environments
Diffstat (limited to 'lib/facter/virtual.rb')
-rw-r--r-- | lib/facter/virtual.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb index 4404ae9..fd05d43 100644 --- a/lib/facter/virtual.rb +++ b/lib/facter/virtual.rb @@ -8,7 +8,15 @@ Facter.add("virtual") do setcode do if FileTest.exists?("/proc/user_beancounters") - result = "openvz" + # openvz. can be hardware node or virtual environment + # read the init process' status file, it has laxer permissions + # than /proc/user_beancounters (so this won't fail as non-root) + txt = File.read("/proc/1/status") + if txt =~ /^envID:[[:blank:]]+0$/mi + result = "openvzhn" + else + result = "openvzve" + end end if FileTest.exists?("/proc/xen/capabilities") && FileTest.readable?("/proc/xen/capabilities") |