facter 4.0.52 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +202 -0
- data/lib/facter.rb +21 -21
- data/lib/facter/config.rb +2 -0
- data/lib/facter/custom_facts/core/execution/base.rb +7 -3
- data/lib/facter/custom_facts/core/execution/popen3.rb +13 -1
- data/lib/facter/custom_facts/core/execution/posix.rb +2 -2
- data/lib/facter/custom_facts/core/execution/windows.rb +1 -1
- data/lib/facter/custom_facts/util/collection.rb +5 -0
- data/lib/facter/custom_facts/util/directory_loader.rb +1 -1
- data/lib/facter/custom_facts/util/normalization.rb +7 -2
- data/lib/facter/custom_facts/util/windows_root.rb +2 -1
- data/lib/facter/facts/aix/processors/cores.rb +16 -0
- data/lib/facter/facts/aix/processors/threads.rb +16 -0
- data/lib/facter/facts/freebsd/is_virtual.rb +1 -5
- data/lib/facter/facts/freebsd/virtual.rb +1 -2
- data/lib/facter/facts/linux/az_metadata.rb +1 -5
- data/lib/facter/facts/linux/cloud/provider.rb +5 -2
- data/lib/facter/facts/linux/ec2_metadata.rb +1 -5
- data/lib/facter/facts/linux/ec2_userdata.rb +1 -5
- data/lib/facter/facts/linux/hypervisors/xen.rb +1 -4
- data/lib/facter/facts/linux/is_virtual.rb +1 -5
- data/lib/facter/facts/linux/processors/cores.rb +16 -0
- data/lib/facter/facts/linux/processors/threads.rb +16 -0
- data/lib/facter/facts/linux/virtual.rb +1 -2
- data/lib/facter/facts/macosx/os/macosx/version.rb +15 -4
- data/lib/facter/facts/macosx/processors/cores.rb +16 -0
- data/lib/facter/facts/macosx/processors/threads.rb +16 -0
- data/lib/facter/facts/solaris/hypervisors/ldom.rb +1 -1
- data/lib/facter/facts/solaris/hypervisors/zone.rb +1 -1
- data/lib/facter/facts/solaris/mountpoints.rb +1 -1
- data/lib/facter/facts/solaris/processors/cores.rb +16 -0
- data/lib/facter/facts/solaris/processors/threads.rb +16 -0
- data/lib/facter/facts/windows/az_metadata.rb +1 -5
- data/lib/facter/facts/windows/cloud/provider.rb +6 -2
- data/lib/facter/facts/windows/ec2_metadata.rb +1 -1
- data/lib/facter/facts/windows/ec2_userdata.rb +1 -1
- data/lib/facter/facts/windows/gce.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/hyperv.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/kvm.rb +2 -1
- data/lib/facter/facts/windows/hypervisors/virtualbox.rb +2 -2
- data/lib/facter/facts/windows/hypervisors/vmware.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/xen.rb +3 -1
- data/lib/facter/facts/windows/is_virtual.rb +15 -0
- data/lib/facter/facts/windows/{virtualization/is_virtual.rb → processors/cores.rb} +4 -4
- data/lib/facter/facts/windows/{virtualization/virtual.rb → processors/threads.rb} +4 -4
- data/lib/facter/facts/windows/virtual.rb +15 -0
- data/lib/facter/framework/cli/cli.rb +13 -15
- data/lib/facter/framework/core/cache_manager.rb +2 -2
- data/lib/facter/framework/core/fact/external/external_fact_manager.rb +0 -1
- data/lib/facter/framework/core/fact/internal/internal_fact_manager.rb +41 -39
- data/lib/facter/framework/core/fact_filter.rb +4 -14
- data/lib/facter/framework/core/fact_loaders/external_fact_loader.rb +9 -6
- data/lib/facter/framework/core/fact_loaders/fact_loader.rb +39 -36
- data/lib/facter/framework/core/fact_manager.rb +82 -14
- data/lib/facter/framework/core/file_loader.rb +1 -1
- data/lib/facter/framework/core/options/config_file_options.rb +7 -0
- data/lib/facter/framework/core/options/option_store.rb +3 -1
- data/lib/facter/framework/formatters/formatter_helper.rb +3 -5
- data/lib/facter/framework/parsers/query_parser.rb +10 -24
- data/lib/facter/models/fact_collection.rb +48 -5
- data/lib/facter/models/resolved_fact.rb +2 -3
- data/lib/facter/models/searched_fact.rb +2 -3
- data/lib/facter/resolvers/aix/ffi/ffi_helper.rb +1 -1
- data/lib/facter/resolvers/aix/processors.rb +4 -0
- data/lib/facter/resolvers/base_resolver.rb +2 -2
- data/lib/facter/resolvers/dmi_decode.rb +0 -1
- data/lib/facter/resolvers/ec2.rb +8 -1
- data/lib/facter/resolvers/linux/hostname.rb +16 -5
- data/lib/facter/resolvers/linux/networking.rb +18 -1
- data/lib/facter/resolvers/lsb_release.rb +1 -2
- data/lib/facter/resolvers/macosx/mountpoints.rb +14 -1
- data/lib/facter/resolvers/macosx/processor.rb +16 -1
- data/lib/facter/resolvers/mountpoints.rb +16 -8
- data/lib/facter/resolvers/networking.rb +6 -3
- data/lib/facter/resolvers/partitions.rb +1 -3
- data/lib/facter/resolvers/processors_lscpu.rb +44 -0
- data/lib/facter/resolvers/ruby.rb +1 -1
- data/lib/facter/resolvers/selinux.rb +5 -7
- data/lib/facter/resolvers/solaris/ffi/structs.rb +12 -0
- data/lib/facter/resolvers/solaris/mountpoints.rb +22 -16
- data/lib/facter/resolvers/solaris/networking.rb +20 -5
- data/lib/facter/resolvers/solaris/processors.rb +7 -0
- data/lib/facter/resolvers/solaris/zone.rb +0 -1
- data/lib/facter/resolvers/windows/ffi/identity_ffi.rb +5 -0
- data/lib/facter/resolvers/windows/ffi/kernel_ffi.rb +1 -1
- data/lib/facter/resolvers/windows/identity.rb +1 -6
- data/lib/facter/resolvers/windows/processors.rb +41 -4
- data/lib/facter/resolvers/windows/uptime.rb +3 -22
- data/lib/facter/resolvers/windows/virtualization.rb +46 -44
- data/lib/facter/resolvers/xen.rb +6 -1
- data/lib/facter/templates/man.erb +6 -6
- data/lib/facter/util/facts/posix/virtual_detector.rb +74 -0
- data/lib/facter/util/facts/unit_converter.rb +2 -2
- data/lib/facter/util/linux/dhcp.rb +4 -1
- data/lib/facter/util/linux/if_inet6.rb +73 -0
- data/lib/facter/util/linux/socket_parser.rb +18 -3
- data/lib/facter/util/resolvers/http.rb +7 -1
- data/lib/facter/util/resolvers/networking/primary_interface.rb +11 -5
- data/lib/facter/util/utils.rb +18 -1
- data/lib/facter/version.rb +1 -1
- metadata +60 -11
- data/lib/facter/framework/core/fact_augmenter.rb +0 -37
- data/lib/facter/util/facts/virtual_detector.rb +0 -90
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Facter
|
4
|
-
module FactAugmenter
|
5
|
-
def self.augment_resolved_facts(searched_facts, resolved_facts)
|
6
|
-
augumented_resolved_facts = []
|
7
|
-
searched_facts.each do |searched_fact|
|
8
|
-
matched_facts = get_resolved_facts_for_searched_fact(searched_fact, resolved_facts)
|
9
|
-
augment_resolved_fact_for_user_query!(searched_fact, matched_facts)
|
10
|
-
augumented_resolved_facts.concat(matched_facts)
|
11
|
-
end
|
12
|
-
|
13
|
-
augumented_resolved_facts
|
14
|
-
end
|
15
|
-
|
16
|
-
private_class_method def self.get_resolved_facts_for_searched_fact(searched_fact, resolved_facts)
|
17
|
-
if searched_fact.name.include?('.*')
|
18
|
-
resolved_facts
|
19
|
-
.select { |resolved_fact| resolved_fact.name.match(searched_fact.name) }
|
20
|
-
.reject(&:user_query)
|
21
|
-
.uniq(&:name)
|
22
|
-
else
|
23
|
-
resolved_facts
|
24
|
-
.select { |resolved_fact| searched_fact.name.eql?(resolved_fact.name) }
|
25
|
-
.reject(&:user_query)
|
26
|
-
.uniq(&:name)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private_class_method def self.augment_resolved_fact_for_user_query!(searched_fact, matched_facts)
|
31
|
-
matched_facts.each do |matched_fact|
|
32
|
-
matched_fact.user_query = searched_fact.user_query
|
33
|
-
matched_fact.filter_tokens = searched_fact.filter_tokens
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Facter
|
4
|
-
module Util
|
5
|
-
module Facts
|
6
|
-
class VirtualDetector
|
7
|
-
def initialize
|
8
|
-
@log = Facter::Log.new(self)
|
9
|
-
end
|
10
|
-
|
11
|
-
def platform
|
12
|
-
fact_value = check_docker_lxc || check_dmi || check_freebsd || check_gce || retrieve_from_virt_what
|
13
|
-
fact_value ||= check_vmware || check_open_vz || check_vserver || check_xen || check_other_facts
|
14
|
-
fact_value ||= check_lspci || 'physical'
|
15
|
-
|
16
|
-
fact_value
|
17
|
-
end
|
18
|
-
|
19
|
-
def check_docker_lxc
|
20
|
-
@log.debug('Checking Docker and LXC')
|
21
|
-
Facter::Resolvers::Containers.resolve(:vm)
|
22
|
-
end
|
23
|
-
|
24
|
-
def check_dmi
|
25
|
-
@log.debug('Checking DMI')
|
26
|
-
vendor = Facter::Resolvers::DmiDecode.resolve(:vendor)
|
27
|
-
@log.debug("dmi detected vendor: #{vendor}")
|
28
|
-
return 'kvm' if vendor =~ /Amazon/
|
29
|
-
|
30
|
-
'xen' if vendor =~ /Xen/
|
31
|
-
end
|
32
|
-
|
33
|
-
def check_gce
|
34
|
-
@log.debug('Checking GCE')
|
35
|
-
bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
|
36
|
-
'gce' if bios_vendor&.include?('Google')
|
37
|
-
end
|
38
|
-
|
39
|
-
def check_vmware
|
40
|
-
@log.debug('Checking VMware')
|
41
|
-
Facter::Resolvers::Vmware.resolve(:vm)
|
42
|
-
end
|
43
|
-
|
44
|
-
def retrieve_from_virt_what
|
45
|
-
@log.debug('Checking virtual_what')
|
46
|
-
Facter::Resolvers::VirtWhat.resolve(:vm)
|
47
|
-
end
|
48
|
-
|
49
|
-
def check_open_vz
|
50
|
-
@log.debug('Checking OpenVZ')
|
51
|
-
Facter::Resolvers::OpenVz.resolve(:vm)
|
52
|
-
end
|
53
|
-
|
54
|
-
def check_vserver
|
55
|
-
@log.debug('Checking VServer')
|
56
|
-
Facter::Resolvers::VirtWhat.resolve(:vserver)
|
57
|
-
end
|
58
|
-
|
59
|
-
def check_xen
|
60
|
-
@log.debug('Checking XEN')
|
61
|
-
Facter::Resolvers::Xen.resolve(:vm)
|
62
|
-
end
|
63
|
-
|
64
|
-
def check_freebsd
|
65
|
-
return unless Object.const_defined?('Facter::Resolvers::Freebsd::Virtual')
|
66
|
-
|
67
|
-
@log.debug('Checking if jailed')
|
68
|
-
Facter::Resolvers::Freebsd::Virtual.resolve(:vm)
|
69
|
-
end
|
70
|
-
|
71
|
-
def check_other_facts
|
72
|
-
@log.debug('Checking others')
|
73
|
-
product_name = Facter::Resolvers::Linux::DmiBios.resolve(:product_name)
|
74
|
-
bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
|
75
|
-
return 'kvm' if bios_vendor&.include?('Amazon EC2')
|
76
|
-
return unless product_name
|
77
|
-
|
78
|
-
Facter::Util::Facts::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
|
79
|
-
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
|
83
|
-
def check_lspci
|
84
|
-
@log.debug('Checking lspci')
|
85
|
-
Facter::Resolvers::Lspci.resolve(:vm)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|