class Facter::Resolvers::VirtWhat
Private Class Methods
determine_other(output)
click to toggle source
# File lib/facter/resolvers/virt_what.rb, line 37 def determine_other(output) values = output.split("\n") other_vm = values.first return unless other_vm return 'zlinux' if /ibm_systemz/.match?(other_vm) return retrieve_vserver if /linux_vserver/.match?(other_vm) return (values - ['redhat']).first if values.include?('redhat') other_vm end
determine_xen(output)
click to toggle source
# File lib/facter/resolvers/virt_what.rb, line 25 def determine_xen(output) xen_info = /^xen\n.*/.match(output) return unless xen_info xen_info = xen_info.to_s return 'xenu' if /xen-domu/.match?(xen_info) return 'xenhvm' if /xen-hvm/.match?(xen_info) 'xen0' if /xen-dom0/.match?(xen_info) end
post_resolve(fact_name, _options)
click to toggle source
# File lib/facter/resolvers/virt_what.rb, line 11 def post_resolve(fact_name, _options) @fact_list.fetch(fact_name) { retrieve_from_virt_what(fact_name) } end
retrieve_from_virt_what(fact_name)
click to toggle source
# File lib/facter/resolvers/virt_what.rb, line 15 def retrieve_from_virt_what(fact_name) output = Facter::Core::Execution.execute('virt-what', logger: log) @fact_list[:vm] = determine_xen(output) @fact_list[:vm] ||= determine_other(output) retrieve_vserver unless @fact_list[:vserver] @fact_list[fact_name] end
retrieve_vserver()
click to toggle source
# File lib/facter/resolvers/virt_what.rb, line 49 def retrieve_vserver proc_status_content = Facter::Util::FileHelper.safe_readlines('/proc/self/status', nil) return unless proc_status_content proc_status_content.each do |line| parts = line.split("\s") next unless parts.size.equal?(2) next unless /^s_context:|^VxID:/.match?(parts[0]) return @fact_list[:vserver] = 'vserver_host' if parts[1] == '0' return @fact_list[:vserver] = 'vserver' end end