# File lib/facter/util/virtual.rb, line 94 def self.hpvm? Facter::Util::Resolution.exec("/usr/bin/getconf MACHINE_MODEL").chomp =~ /Virtual Machine/ end
# File lib/facter/util/virtual.rb, line 86 def self.jail? path = case Facter.value(:kernel) when "FreeBSD" then "/sbin" when "GNU/kFreeBSD" then "/bin" end Facter::Util::Resolution.exec("#{path}/sysctl -n security.jail.jailed") == "1" end
# File lib/facter/util/virtual.rb, line 70 def self.kvm? txt = if FileTest.exists?("/proc/cpuinfo") File.read("/proc/cpuinfo") elsif ["FreeBSD", "OpenBSD"].include? Facter.value(:kernel) Facter::Util::Resolution.exec("/sbin/sysctl -n hw.model") end (txt =~ /QEMU Virtual CPU/) ? true : false end
# File lib/facter/util/virtual.rb, line 79 def self.kvm_type # TODO Tell the difference between kvm and qemu # Can't work out a way to do this at the moment that doesn't # require a special binary "kvm" end
lspci is a delegating helper method intended to make it easier to stub the system call without affecting other calls to Facter::Util::Resolution.exec
# File lib/facter/util/virtual.rb, line 13 def self.lspci(command = "lspci 2>/dev/null") Facter::Util::Resolution.exec command end
# File lib/facter/util/virtual.rb, line 17 def self.openvz? FileTest.directory?("/proc/vz") and not self.openvz_cloudlinux? end
Cloudlinux uses OpenVZ to a degree, but always has an empty /proc/vz/ and has /proc/lve/list present
# File lib/facter/util/virtual.rb, line 36 def self.openvz_cloudlinux? FileTest.file?("/proc/lve/list") or Dir.glob('/proc/vz/*').empty? end
So one can either have #6728 work on OpenVZ or Cloudlinux. Whoo.
# File lib/facter/util/virtual.rb, line 22 def self.openvz_type return false unless self.openvz? return false unless FileTest.exists?( '/proc/self/status' ) envid = Facter::Util::Resolution.exec( 'grep "envID" /proc/self/status' ) if envid =~ /^envID:\s+0$/ return 'openvzhn' elsif envid =~ /^envID:\s+(\d+)$/ return 'openvzve' end end
virt_what is a delegating helper method intended to make it easier to stub the system call without affecting other calls to Facter::Util::Resolution.exec
# File lib/facter/util/virtual.rb, line 6 def self.virt_what(command = "virt-what") Facter::Util::Resolution.exec command end
# File lib/facter/util/virtual.rb, line 47 def self.vserver? return false unless FileTest.exists?("/proc/self/status") txt = File.open("/proc/self/status", "rb").read return true if txt =~ /^(s_context|VxID):[[:blank:]]*[0-9]/ return false end
# File lib/facter/util/virtual.rb, line 54 def self.vserver_type if self.vserver? if FileTest.exists?("/proc/virtual") "vserver_host" else "vserver" end end end
# File lib/facter/util/virtual.rb, line 64 def self.xen? ["/proc/sys/xen", "/sys/bus/xen", "/proc/xen" ].detect do |f| FileTest.exists?(f) end end
Generated with the Darkfish Rdoc Generator 2.