diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/facter/util/virtual.rb | 16 | ||||
| -rw-r--r-- | lib/facter/virtual.rb | 39 |
2 files changed, 35 insertions, 20 deletions
diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb index 8db57a3..0c3fb73 100644 --- a/lib/facter/util/virtual.rb +++ b/lib/facter/util/virtual.rb @@ -24,4 +24,20 @@ module Facter::Util::Virtual return true if txt =~ /^(s_context|VxID):[[:blank:]]*[1-9]/ return false end + + def self.vserver_type + if self.vserver? + if FileTest.exists?("/proc/virtual") + "vserver_host" + else + "vserver" + end + end + end + + def self.xen? + ["/proc/sys/xen", "/sys/bus/xen", "/proc/xen" ].detect do |f| + FileTest.exists?(f) + end + end end diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb index 299ebb4..78413a9 100644 --- a/lib/facter/virtual.rb +++ b/lib/facter/virtual.rb @@ -13,24 +13,24 @@ Facter.add("virtual") do result = Facter::Util::Virtual.openvz_type() end - result = "vserver" if Facter::Util::Virtual.vserver? - - if FileTest.exists?("/proc/virtual") - result = "vserver_host" + if Facter::Util::Virtual.vserver? + result = Facter::Util::Virtual.vserver_type() end - # new Xen domains have this in dom0 not domu :( - if FileTest.exists?("/proc/sys/xen/independent_wallclock") - result = "xenu" - end - if FileTest.exists?("/sys/bus/xen") - result = "xenu" - end + if Facter::Util::Virtual.xen? + # new Xen domains have this in dom0 not domu :( + if FileTest.exists?("/proc/sys/xen/independent_wallclock") + result = "xenu" + end + if FileTest.exists?("/sys/bus/xen") + result = "xenu" + end - if FileTest.exists?("/proc/xen/capabilities") - txt = File.read("/proc/xen/capabilities") - if txt =~ /control_d/i - result = "xen0" + if FileTest.exists?("/proc/xen/capabilities") + txt = File.read("/proc/xen/capabilities") + if txt =~ /control_d/i + result = "xen0" + end end end @@ -57,11 +57,10 @@ Facter.add("virtual") do end end end - end - - # VMware server 1.0.3 rpm places vmware-vmx in this place, other versions or platforms may not. - if FileTest.exists?("/usr/lib/vmware/bin/vmware-vmx") - result = "vmware_server" + # VMware server 1.0.3 rpm places vmware-vmx in this place, other versions or platforms may not. + if FileTest.exists?("/usr/lib/vmware/bin/vmware-vmx") + result = "vmware_server" + end end result |
