# File lib/facter/util/virtual.rb, line 79 79: def self.hpvm? 80: Facter::Util::Resolution.exec("/usr/bin/getconf MACHINE_MODEL").chomp =~ /Virtual Machine/ 81: end
# File lib/facter/util/virtual.rb, line 71 71: def self.jail? 72: path = case Facter.value(:kernel) 73: when "FreeBSD" then "/sbin" 74: when "GNU/kFreeBSD" then "/bin" 75: end 76: Facter::Util::Resolution.exec("#{path}/sysctl -n security.jail.jailed") == "1" 77: end
# File lib/facter/util/virtual.rb, line 55 55: def self.kvm? 56: txt = if FileTest.exists?("/proc/cpuinfo") 57: File.read("/proc/cpuinfo") 58: elsif ["FreeBSD", "OpenBSD"].include? Facter.value(:kernel) 59: Facter::Util::Resolution.exec("/sbin/sysctl -n hw.model") 60: end 61: (txt =~ /QEMU Virtual CPU/) ? true : false 62: end
# File lib/facter/util/virtual.rb, line 64 64: def self.kvm_type 65: # TODO Tell the difference between kvm and qemu 66: # Can't work out a way to do this at the moment that doesn't 67: # require a special binary 68: "kvm" 69: end
# File lib/facter/util/virtual.rb, line 2 2: def self.openvz? 3: FileTest.directory?("/proc/vz") and not self.openvz_cloudlinux? 4: 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 21 21: def self.openvz_cloudlinux? 22: FileTest.file?("/proc/lve/list") or Dir.glob('/proc/vz/*').empty? 23: end
So one can either have #6728 work on OpenVZ or Cloudlinux. Whoo.
# File lib/facter/util/virtual.rb, line 7 7: def self.openvz_type 8: return false unless self.openvz? 9: return false unless FileTest.exists?( '/proc/self/status' ) 10: 11: envid = Facter::Util::Resolution.exec( 'grep "envID" /proc/self/status' ) 12: if envid =~ /^envID:\s+0$/ 13: return 'openvzhn' 14: elsif envid =~ /^envID:\s+(\d+)$/ 15: return 'openvzve' 16: end 17: end
# File lib/facter/util/virtual.rb, line 32 32: def self.vserver? 33: return false unless FileTest.exists?("/proc/self/status") 34: txt = File.open("/proc/self/status", "rb").read 35: return true if txt =~ /^(s_context|VxID):[[:blank:]]*[0-9]/ 36: return false 37: end
# File lib/facter/util/virtual.rb, line 39 39: def self.vserver_type 40: if self.vserver? 41: if FileTest.exists?("/proc/virtual") 42: "vserver_host" 43: else 44: "vserver" 45: end 46: end 47: end
# File lib/facter/util/virtual.rb, line 49 49: def self.xen? 50: ["/proc/sys/xen", "/sys/bus/xen", "/proc/xen" ].detect do |f| 51: FileTest.exists?(f) 52: end 53: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.