facter 4.0.44 → 4.0.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/facter.rb +15 -1
- data/lib/facter/config.rb +1 -0
- data/lib/facter/custom_facts/core/execution.rb +28 -4
- data/lib/facter/custom_facts/core/execution/base.rb +33 -33
- data/lib/facter/custom_facts/util/parser.rb +17 -3
- data/lib/facter/facts/solaris/hypervisors/ldom.rb +3 -0
- data/lib/facter/facts/solaris/ldom.rb +4 -1
- data/lib/facter/framework/cli/cli.rb +19 -5
- data/lib/facter/framework/config/fact_groups.rb +5 -3
- data/lib/facter/framework/core/cache_manager.rb +57 -15
- data/lib/facter/framework/core/fact/internal/core_fact.rb +6 -1
- data/lib/facter/framework/core/fact/internal/internal_fact_manager.rb +38 -4
- data/lib/facter/framework/core/fact_augmenter.rb +1 -1
- data/lib/facter/framework/core/fact_loaders/fact_loader.rb +1 -1
- data/lib/facter/framework/core/fact_manager.rb +1 -1
- data/lib/facter/framework/core/options/config_file_options.rb +16 -5
- data/lib/facter/framework/core/options/option_store.rb +7 -3
- data/lib/facter/resolvers/aio_agent_version.rb +1 -1
- data/lib/facter/resolvers/aix/architecture_resolver.rb +2 -1
- data/lib/facter/resolvers/aix/disks.rb +2 -1
- data/lib/facter/resolvers/aix/filesystem_resolver.rb +1 -1
- data/lib/facter/resolvers/aix/hardware_resolver.rb +2 -1
- data/lib/facter/resolvers/aix/load_averages_resolver.rb +2 -1
- data/lib/facter/resolvers/aix/memory.rb +2 -1
- data/lib/facter/resolvers/aix/mountpoints.rb +2 -1
- data/lib/facter/resolvers/aix/networking_resolver.rb +1 -1
- data/lib/facter/resolvers/aix/nim.rb +1 -1
- data/lib/facter/resolvers/aix/os_level.rb +1 -1
- data/lib/facter/resolvers/aix/partitions.rb +2 -1
- data/lib/facter/resolvers/aix/processors.rb +2 -1
- data/lib/facter/resolvers/aix/serialnumber.rb +1 -1
- data/lib/facter/resolvers/augeas_resolver.rb +1 -1
- data/lib/facter/resolvers/base_resolver.rb +11 -4
- data/lib/facter/resolvers/bsd/processors.rb +2 -1
- data/lib/facter/resolvers/cloud.rb +1 -1
- data/lib/facter/resolvers/containers.rb +2 -1
- data/lib/facter/resolvers/debian_version.rb +1 -1
- data/lib/facter/resolvers/disk_resolver.rb +4 -1
- data/lib/facter/resolvers/dmi_decode.rb +1 -1
- data/lib/facter/resolvers/dmi_resolver.rb +2 -1
- data/lib/facter/resolvers/ec2.rb +2 -1
- data/lib/facter/resolvers/eos_release_resolver.rb +1 -1
- data/lib/facter/resolvers/facterversion_resolver.rb +1 -1
- data/lib/facter/resolvers/filesystems_resolver.rb +4 -1
- data/lib/facter/resolvers/fips_enabled_resolver.rb +4 -1
- data/lib/facter/resolvers/freebsd/dmi_resolver.rb +1 -1
- data/lib/facter/resolvers/freebsd/freebsd_version_resolver.rb +9 -7
- data/lib/facter/resolvers/freebsd/geom_resolver.rb +2 -1
- data/lib/facter/resolvers/freebsd/processors.rb +2 -1
- data/lib/facter/resolvers/freebsd/swap_memory_resolver.rb +2 -1
- data/lib/facter/resolvers/freebsd/system_memory_resolver.rb +2 -1
- data/lib/facter/resolvers/gce.rb +2 -1
- data/lib/facter/resolvers/hostname_resolver.rb +2 -1
- data/lib/facter/resolvers/identity_resolver.rb +2 -1
- data/lib/facter/resolvers/linux/docker_uptime.rb +2 -1
- data/lib/facter/resolvers/linux/load_averages.rb +2 -1
- data/lib/facter/resolvers/load_averages.rb +2 -1
- data/lib/facter/resolvers/lpar_resolver.rb +1 -1
- data/lib/facter/resolvers/lsb_release_resolver.rb +1 -1
- data/lib/facter/resolvers/lspci.rb +1 -1
- data/lib/facter/resolvers/macosx/dmi_resolver.rb +1 -1
- data/lib/facter/resolvers/macosx/filesystems_resolver.rb +1 -1
- data/lib/facter/resolvers/macosx/load_averages_resolver.rb +2 -1
- data/lib/facter/resolvers/macosx/mountpoints_resolver.rb +2 -1
- data/lib/facter/resolvers/macosx/processor_resolver.rb +2 -1
- data/lib/facter/resolvers/macosx/swap_memory_resolver.rb +2 -1
- data/lib/facter/resolvers/macosx/system_memory_resolver.rb +2 -1
- data/lib/facter/resolvers/macosx/system_profiler_resolver.rb +1 -3
- data/lib/facter/resolvers/memory_resolver.rb +3 -1
- data/lib/facter/resolvers/mountpoints_resolver.rb +4 -1
- data/lib/facter/resolvers/networking_linux_resolver.rb +5 -4
- data/lib/facter/resolvers/networking_resolver.rb +1 -1
- data/lib/facter/resolvers/open_vz.rb +1 -1
- data/lib/facter/resolvers/os_release_resolver.rb +1 -1
- data/lib/facter/resolvers/partitions.rb +2 -1
- data/lib/facter/resolvers/path_resolver.rb +1 -1
- data/lib/facter/resolvers/processors_resolver.rb +4 -1
- data/lib/facter/resolvers/puppet_version_resolver.rb +1 -1
- data/lib/facter/resolvers/redhat_release_resolver.rb +1 -1
- data/lib/facter/resolvers/ruby_resolver.rb +1 -1
- data/lib/facter/resolvers/selinux_resolver.rb +1 -1
- data/lib/facter/resolvers/solaris/disks.rb +1 -1
- data/lib/facter/resolvers/solaris/dmi.rb +1 -1
- data/lib/facter/resolvers/solaris/dmi_sparc.rb +1 -1
- data/lib/facter/resolvers/solaris/filesystems.rb +1 -1
- data/lib/facter/resolvers/solaris/ipaddress.rb +2 -1
- data/lib/facter/resolvers/solaris/ldom.rb +1 -3
- data/lib/facter/resolvers/solaris/memory.rb +2 -1
- data/lib/facter/resolvers/solaris/mountpoints.rb +2 -2
- data/lib/facter/resolvers/solaris/networking.rb +1 -1
- data/lib/facter/resolvers/solaris/os_release.rb +2 -1
- data/lib/facter/resolvers/solaris/processors.rb +2 -1
- data/lib/facter/resolvers/solaris/zone.rb +1 -1
- data/lib/facter/resolvers/solaris/zone_name.rb +1 -1
- data/lib/facter/resolvers/ssh_resolver.rb +4 -1
- data/lib/facter/resolvers/suse_release_resolver.rb +1 -1
- data/lib/facter/resolvers/sw_vers_resolver.rb +2 -2
- data/lib/facter/resolvers/timezone_resolver.rb +1 -1
- data/lib/facter/resolvers/uname_resolver.rb +1 -1
- data/lib/facter/resolvers/uptime_resolver.rb +1 -1
- data/lib/facter/resolvers/utils/networking.rb +2 -0
- data/lib/facter/resolvers/virt_what.rb +1 -1
- data/lib/facter/resolvers/vmware.rb +1 -1
- data/lib/facter/resolvers/windows/aio_agent_version.rb +1 -1
- data/lib/facter/resolvers/windows/dmi_bios_resolver.rb +1 -1
- data/lib/facter/resolvers/windows/dmi_computersystem_resolver.rb +1 -1
- data/lib/facter/resolvers/windows/fips_resolver.rb +2 -1
- data/lib/facter/resolvers/windows/hardware_architecture_resolver.rb +2 -1
- data/lib/facter/resolvers/windows/identity_resolver.rb +2 -1
- data/lib/facter/resolvers/windows/kernel_resolver.rb +3 -1
- data/lib/facter/resolvers/windows/memory_resolver.rb +3 -1
- data/lib/facter/resolvers/windows/netkvm_resolver.rb +2 -1
- data/lib/facter/resolvers/windows/networking_resolver.rb +2 -1
- data/lib/facter/resolvers/windows/processors_resolver.rb +2 -1
- data/lib/facter/resolvers/windows/product_release_resolver.rb +2 -1
- data/lib/facter/resolvers/windows/ssh.rb +3 -1
- data/lib/facter/resolvers/windows/system32_resolver.rb +3 -1
- data/lib/facter/resolvers/windows/uptime_resolver.rb +2 -1
- data/lib/facter/resolvers/windows/virtualization_resolver.rb +2 -1
- data/lib/facter/resolvers/windows/win_os_description_resolver.rb +3 -1
- data/lib/facter/resolvers/wpar_resolver.rb +1 -1
- data/lib/facter/resolvers/xen.rb +1 -1
- data/lib/facter/resolvers/zfs.rb +2 -1
- data/lib/facter/resolvers/zpool.rb +2 -1
- data/lib/facter/version.rb +1 -1
- metadata +4 -3
@@ -11,7 +11,12 @@ module Facter
|
|
11
11
|
|
12
12
|
return unless fact_class
|
13
13
|
|
14
|
-
|
14
|
+
fact_value = nil
|
15
|
+
Facter::Framework::Benchmarking::Timer.measure(@searched_fact.name) do
|
16
|
+
fact_value = fact_class.new.call_the_resolver
|
17
|
+
end
|
18
|
+
|
19
|
+
fact_value
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
@@ -7,7 +7,15 @@ module Facter
|
|
7
7
|
def resolve_facts(searched_facts)
|
8
8
|
internal_searched_facts = filter_internal_facts(searched_facts)
|
9
9
|
|
10
|
-
resolved_facts =
|
10
|
+
resolved_facts = if Options[:sequential]
|
11
|
+
@@log.debug('Resolving facts sequentially')
|
12
|
+
resolve_sequentially(internal_searched_facts)
|
13
|
+
else
|
14
|
+
@@log.debug('Resolving fact in parallel')
|
15
|
+
threads = start_threads(internal_searched_facts)
|
16
|
+
join_threads(threads, internal_searched_facts)
|
17
|
+
end
|
18
|
+
|
11
19
|
nil_resolved_facts = resolve_nil_facts(searched_facts)
|
12
20
|
|
13
21
|
resolved_facts.concat(nil_resolved_facts)
|
@@ -28,7 +36,7 @@ module Facter
|
|
28
36
|
resolved_facts
|
29
37
|
end
|
30
38
|
|
31
|
-
def
|
39
|
+
def resolve_sequentially(searched_facts)
|
32
40
|
resolved_facts = []
|
33
41
|
|
34
42
|
searched_facts
|
@@ -36,8 +44,7 @@ module Facter
|
|
36
44
|
.each do |searched_fact|
|
37
45
|
begin
|
38
46
|
fact = CoreFact.new(searched_fact)
|
39
|
-
fact_value =
|
40
|
-
Facter::Framework::Benchmarking::Timer.measure(searched_fact.name) { fact_value = fact.create }
|
47
|
+
fact_value = fact.create
|
41
48
|
resolved_facts << fact_value unless fact_value.nil?
|
42
49
|
rescue StandardError => e
|
43
50
|
@@log.log_exception(e)
|
@@ -47,5 +54,32 @@ module Facter
|
|
47
54
|
resolved_facts.flatten!
|
48
55
|
FactAugmenter.augment_resolved_facts(searched_facts, resolved_facts)
|
49
56
|
end
|
57
|
+
|
58
|
+
def start_threads(searched_facts)
|
59
|
+
# only resolve a fact once, even if multiple search facts depend on that fact
|
60
|
+
searched_facts
|
61
|
+
.uniq { |searched_fact| searched_fact.fact_class.name }
|
62
|
+
.map do |searched_fact|
|
63
|
+
Thread.new do
|
64
|
+
resolve_fact(searched_fact)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def join_threads(threads, searched_facts)
|
70
|
+
resolved_facts = threads.map(&:value)
|
71
|
+
resolved_facts.compact!
|
72
|
+
resolved_facts.flatten!
|
73
|
+
|
74
|
+
FactAugmenter.augment_resolved_facts(searched_facts, resolved_facts)
|
75
|
+
end
|
76
|
+
|
77
|
+
def resolve_fact(searched_fact)
|
78
|
+
fact = CoreFact.new(searched_fact)
|
79
|
+
fact.create
|
80
|
+
rescue StandardError => e
|
81
|
+
@@log.log_exception(e)
|
82
|
+
nil
|
83
|
+
end
|
50
84
|
end
|
51
85
|
end
|
@@ -16,7 +16,7 @@ module Facter
|
|
16
16
|
private_class_method def self.get_resolved_facts_for_searched_fact(searched_fact, resolved_facts)
|
17
17
|
if searched_fact.name.include?('.*')
|
18
18
|
resolved_facts
|
19
|
-
.select { |resolved_fact| resolved_fact.name.match(searched_fact.
|
19
|
+
.select { |resolved_fact| resolved_fact.name.match(searched_fact.name) }
|
20
20
|
.reject(&:user_query)
|
21
21
|
.uniq(&:name)
|
22
22
|
else
|
@@ -27,8 +27,8 @@ module Facter
|
|
27
27
|
|
28
28
|
resolved_facts = override_core_facts(internal_facts, external_facts)
|
29
29
|
|
30
|
-
cache_manager.cache_facts(resolved_facts)
|
31
30
|
resolved_facts = resolved_facts.concat(cached_facts)
|
31
|
+
cache_manager.cache_facts(resolved_facts)
|
32
32
|
|
33
33
|
FactFilter.new.filter_facts!(resolved_facts)
|
34
34
|
|
@@ -19,14 +19,18 @@ module Facter
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def augment_all
|
22
|
-
if Options.cli?
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
augment_cli(Facter::ConfigReader.cli) if Options.cli?
|
23
|
+
augment_globals
|
24
|
+
augment_facts(Facter::ConfigReader.ttls, Facter::ConfigReader.fact_groups)
|
25
|
+
end
|
26
|
+
|
27
|
+
def augment_globals
|
28
|
+
augment_ruby(Facter::ConfigReader.global)
|
29
|
+
|
26
30
|
augment_custom(Facter::ConfigReader.global)
|
27
31
|
augment_external(Facter::ConfigReader.global)
|
28
32
|
augment_show_legacy(Facter::ConfigReader.global)
|
29
|
-
|
33
|
+
augment_sequential(Facter::ConfigReader.global)
|
30
34
|
end
|
31
35
|
|
32
36
|
def augment_config_path(config_path)
|
@@ -68,6 +72,7 @@ module Facter
|
|
68
72
|
|
69
73
|
def augment_ruby(global_conf)
|
70
74
|
return unless global_conf
|
75
|
+
return unless Options.cli?
|
71
76
|
|
72
77
|
@options[:no_ruby] = global_conf['no-ruby'].nil? ? false : global_conf['no-ruby']
|
73
78
|
end
|
@@ -78,6 +83,12 @@ module Facter
|
|
78
83
|
@options[:show_legacy] = global_conf['show-legacy'] unless global_conf['show-legacy'].nil?
|
79
84
|
end
|
80
85
|
|
86
|
+
def augment_sequential(global_conf)
|
87
|
+
return unless global_conf
|
88
|
+
|
89
|
+
@options[:sequential] = global_conf['sequential'] unless global_conf['sequential'].nil?
|
90
|
+
end
|
91
|
+
|
81
92
|
def augment_facts(ttls, groups)
|
82
93
|
fact_groups = Facter::FactGroups.new
|
83
94
|
|
@@ -26,6 +26,8 @@ module Facter
|
|
26
26
|
@config_file_external_dir = []
|
27
27
|
@default_external_dir = []
|
28
28
|
@fact_groups = {}
|
29
|
+
@sequential = false
|
30
|
+
@ttls = []
|
29
31
|
@block_list = []
|
30
32
|
@color = true
|
31
33
|
@trace = false
|
@@ -40,7 +42,7 @@ module Facter
|
|
40
42
|
attr_accessor :config, :user_query, :strict, :json,
|
41
43
|
:cache, :yaml, :puppet, :ttls, :block, :cli, :config_file_custom_dir,
|
42
44
|
:config_file_external_dir, :default_external_dir, :fact_groups,
|
43
|
-
:block_list, :color, :trace, :timing
|
45
|
+
:block_list, :color, :trace, :sequential, :timing
|
44
46
|
|
45
47
|
attr_writer :external_dir
|
46
48
|
|
@@ -175,11 +177,11 @@ module Facter
|
|
175
177
|
@ttls = []
|
176
178
|
@block = true
|
177
179
|
@cli = nil
|
180
|
+
@custom_facts = true
|
178
181
|
reset_config
|
179
182
|
end
|
180
183
|
|
181
184
|
def reset_config
|
182
|
-
@custom_facts = true
|
183
185
|
@blocked_facts = []
|
184
186
|
@external_facts = true
|
185
187
|
@config = nil
|
@@ -188,8 +190,10 @@ module Facter
|
|
188
190
|
@config_file_external_dir = []
|
189
191
|
@default_external_dir = []
|
190
192
|
@fact_groups = {}
|
191
|
-
@block_list =
|
193
|
+
@block_list = {}
|
192
194
|
@color = true
|
195
|
+
@sequential = false
|
196
|
+
@ttls = []
|
193
197
|
@trace = false
|
194
198
|
@timing = false
|
195
199
|
@external_dir = []
|
@@ -11,21 +11,28 @@ module Facter
|
|
11
11
|
@fact_list = {}
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.init_resolver
|
15
|
+
@fact_list = {}
|
16
|
+
@semaphore = Mutex.new
|
17
|
+
end
|
18
|
+
|
14
19
|
def self.subscribe_to_manager
|
15
20
|
Facter::SessionCache.subscribe(self)
|
16
21
|
end
|
17
22
|
|
18
23
|
def self.resolve(fact_name)
|
19
|
-
|
20
|
-
|
24
|
+
@semaphore.synchronize do
|
25
|
+
subscribe_to_manager
|
26
|
+
post_resolve(fact_name)
|
21
27
|
|
22
|
-
|
28
|
+
cache_nil_for_unresolved_facts(fact_name)
|
29
|
+
end
|
23
30
|
rescue LoadError, NameError => e
|
24
31
|
log.debug("resolving fact #{fact_name}, but #{e}")
|
25
32
|
@fact_list[fact_name] = nil
|
26
33
|
end
|
27
34
|
|
28
|
-
def self.
|
35
|
+
def self.cache_nil_for_unresolved_facts(fact_name)
|
29
36
|
@fact_list.fetch(fact_name) { @fact_list[fact_name] = nil }
|
30
37
|
@fact_list[fact_name]
|
31
38
|
end
|
@@ -5,9 +5,12 @@ module Facter
|
|
5
5
|
module Linux
|
6
6
|
class Disk < BaseResolver
|
7
7
|
@log = Facter::Log.new(self)
|
8
|
-
|
8
|
+
|
9
|
+
init_resolver
|
10
|
+
|
9
11
|
DIR = '/sys/block'
|
10
12
|
FILE_PATHS = { model: 'device/model', size: 'size', vendor: 'device/vendor', type: 'queue/rotational' }.freeze
|
13
|
+
|
11
14
|
class << self
|
12
15
|
private
|
13
16
|
|