facter 4.0.44 → 4.0.46

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/lib/facter.rb +15 -1
  3. data/lib/facter/config.rb +1 -0
  4. data/lib/facter/custom_facts/core/execution.rb +28 -4
  5. data/lib/facter/custom_facts/core/execution/base.rb +33 -33
  6. data/lib/facter/custom_facts/util/parser.rb +17 -3
  7. data/lib/facter/facts/solaris/hypervisors/ldom.rb +3 -0
  8. data/lib/facter/facts/solaris/ldom.rb +4 -1
  9. data/lib/facter/framework/cli/cli.rb +19 -5
  10. data/lib/facter/framework/config/fact_groups.rb +5 -3
  11. data/lib/facter/framework/core/cache_manager.rb +57 -15
  12. data/lib/facter/framework/core/fact/internal/core_fact.rb +6 -1
  13. data/lib/facter/framework/core/fact/internal/internal_fact_manager.rb +38 -4
  14. data/lib/facter/framework/core/fact_augmenter.rb +1 -1
  15. data/lib/facter/framework/core/fact_loaders/fact_loader.rb +1 -1
  16. data/lib/facter/framework/core/fact_manager.rb +1 -1
  17. data/lib/facter/framework/core/options/config_file_options.rb +16 -5
  18. data/lib/facter/framework/core/options/option_store.rb +7 -3
  19. data/lib/facter/resolvers/aio_agent_version.rb +1 -1
  20. data/lib/facter/resolvers/aix/architecture_resolver.rb +2 -1
  21. data/lib/facter/resolvers/aix/disks.rb +2 -1
  22. data/lib/facter/resolvers/aix/filesystem_resolver.rb +1 -1
  23. data/lib/facter/resolvers/aix/hardware_resolver.rb +2 -1
  24. data/lib/facter/resolvers/aix/load_averages_resolver.rb +2 -1
  25. data/lib/facter/resolvers/aix/memory.rb +2 -1
  26. data/lib/facter/resolvers/aix/mountpoints.rb +2 -1
  27. data/lib/facter/resolvers/aix/networking_resolver.rb +1 -1
  28. data/lib/facter/resolvers/aix/nim.rb +1 -1
  29. data/lib/facter/resolvers/aix/os_level.rb +1 -1
  30. data/lib/facter/resolvers/aix/partitions.rb +2 -1
  31. data/lib/facter/resolvers/aix/processors.rb +2 -1
  32. data/lib/facter/resolvers/aix/serialnumber.rb +1 -1
  33. data/lib/facter/resolvers/augeas_resolver.rb +1 -1
  34. data/lib/facter/resolvers/base_resolver.rb +11 -4
  35. data/lib/facter/resolvers/bsd/processors.rb +2 -1
  36. data/lib/facter/resolvers/cloud.rb +1 -1
  37. data/lib/facter/resolvers/containers.rb +2 -1
  38. data/lib/facter/resolvers/debian_version.rb +1 -1
  39. data/lib/facter/resolvers/disk_resolver.rb +4 -1
  40. data/lib/facter/resolvers/dmi_decode.rb +1 -1
  41. data/lib/facter/resolvers/dmi_resolver.rb +2 -1
  42. data/lib/facter/resolvers/ec2.rb +2 -1
  43. data/lib/facter/resolvers/eos_release_resolver.rb +1 -1
  44. data/lib/facter/resolvers/facterversion_resolver.rb +1 -1
  45. data/lib/facter/resolvers/filesystems_resolver.rb +4 -1
  46. data/lib/facter/resolvers/fips_enabled_resolver.rb +4 -1
  47. data/lib/facter/resolvers/freebsd/dmi_resolver.rb +1 -1
  48. data/lib/facter/resolvers/freebsd/freebsd_version_resolver.rb +9 -7
  49. data/lib/facter/resolvers/freebsd/geom_resolver.rb +2 -1
  50. data/lib/facter/resolvers/freebsd/processors.rb +2 -1
  51. data/lib/facter/resolvers/freebsd/swap_memory_resolver.rb +2 -1
  52. data/lib/facter/resolvers/freebsd/system_memory_resolver.rb +2 -1
  53. data/lib/facter/resolvers/gce.rb +2 -1
  54. data/lib/facter/resolvers/hostname_resolver.rb +2 -1
  55. data/lib/facter/resolvers/identity_resolver.rb +2 -1
  56. data/lib/facter/resolvers/linux/docker_uptime.rb +2 -1
  57. data/lib/facter/resolvers/linux/load_averages.rb +2 -1
  58. data/lib/facter/resolvers/load_averages.rb +2 -1
  59. data/lib/facter/resolvers/lpar_resolver.rb +1 -1
  60. data/lib/facter/resolvers/lsb_release_resolver.rb +1 -1
  61. data/lib/facter/resolvers/lspci.rb +1 -1
  62. data/lib/facter/resolvers/macosx/dmi_resolver.rb +1 -1
  63. data/lib/facter/resolvers/macosx/filesystems_resolver.rb +1 -1
  64. data/lib/facter/resolvers/macosx/load_averages_resolver.rb +2 -1
  65. data/lib/facter/resolvers/macosx/mountpoints_resolver.rb +2 -1
  66. data/lib/facter/resolvers/macosx/processor_resolver.rb +2 -1
  67. data/lib/facter/resolvers/macosx/swap_memory_resolver.rb +2 -1
  68. data/lib/facter/resolvers/macosx/system_memory_resolver.rb +2 -1
  69. data/lib/facter/resolvers/macosx/system_profiler_resolver.rb +1 -3
  70. data/lib/facter/resolvers/memory_resolver.rb +3 -1
  71. data/lib/facter/resolvers/mountpoints_resolver.rb +4 -1
  72. data/lib/facter/resolvers/networking_linux_resolver.rb +5 -4
  73. data/lib/facter/resolvers/networking_resolver.rb +1 -1
  74. data/lib/facter/resolvers/open_vz.rb +1 -1
  75. data/lib/facter/resolvers/os_release_resolver.rb +1 -1
  76. data/lib/facter/resolvers/partitions.rb +2 -1
  77. data/lib/facter/resolvers/path_resolver.rb +1 -1
  78. data/lib/facter/resolvers/processors_resolver.rb +4 -1
  79. data/lib/facter/resolvers/puppet_version_resolver.rb +1 -1
  80. data/lib/facter/resolvers/redhat_release_resolver.rb +1 -1
  81. data/lib/facter/resolvers/ruby_resolver.rb +1 -1
  82. data/lib/facter/resolvers/selinux_resolver.rb +1 -1
  83. data/lib/facter/resolvers/solaris/disks.rb +1 -1
  84. data/lib/facter/resolvers/solaris/dmi.rb +1 -1
  85. data/lib/facter/resolvers/solaris/dmi_sparc.rb +1 -1
  86. data/lib/facter/resolvers/solaris/filesystems.rb +1 -1
  87. data/lib/facter/resolvers/solaris/ipaddress.rb +2 -1
  88. data/lib/facter/resolvers/solaris/ldom.rb +1 -3
  89. data/lib/facter/resolvers/solaris/memory.rb +2 -1
  90. data/lib/facter/resolvers/solaris/mountpoints.rb +2 -2
  91. data/lib/facter/resolvers/solaris/networking.rb +1 -1
  92. data/lib/facter/resolvers/solaris/os_release.rb +2 -1
  93. data/lib/facter/resolvers/solaris/processors.rb +2 -1
  94. data/lib/facter/resolvers/solaris/zone.rb +1 -1
  95. data/lib/facter/resolvers/solaris/zone_name.rb +1 -1
  96. data/lib/facter/resolvers/ssh_resolver.rb +4 -1
  97. data/lib/facter/resolvers/suse_release_resolver.rb +1 -1
  98. data/lib/facter/resolvers/sw_vers_resolver.rb +2 -2
  99. data/lib/facter/resolvers/timezone_resolver.rb +1 -1
  100. data/lib/facter/resolvers/uname_resolver.rb +1 -1
  101. data/lib/facter/resolvers/uptime_resolver.rb +1 -1
  102. data/lib/facter/resolvers/utils/networking.rb +2 -0
  103. data/lib/facter/resolvers/virt_what.rb +1 -1
  104. data/lib/facter/resolvers/vmware.rb +1 -1
  105. data/lib/facter/resolvers/windows/aio_agent_version.rb +1 -1
  106. data/lib/facter/resolvers/windows/dmi_bios_resolver.rb +1 -1
  107. data/lib/facter/resolvers/windows/dmi_computersystem_resolver.rb +1 -1
  108. data/lib/facter/resolvers/windows/fips_resolver.rb +2 -1
  109. data/lib/facter/resolvers/windows/hardware_architecture_resolver.rb +2 -1
  110. data/lib/facter/resolvers/windows/identity_resolver.rb +2 -1
  111. data/lib/facter/resolvers/windows/kernel_resolver.rb +3 -1
  112. data/lib/facter/resolvers/windows/memory_resolver.rb +3 -1
  113. data/lib/facter/resolvers/windows/netkvm_resolver.rb +2 -1
  114. data/lib/facter/resolvers/windows/networking_resolver.rb +2 -1
  115. data/lib/facter/resolvers/windows/processors_resolver.rb +2 -1
  116. data/lib/facter/resolvers/windows/product_release_resolver.rb +2 -1
  117. data/lib/facter/resolvers/windows/ssh.rb +3 -1
  118. data/lib/facter/resolvers/windows/system32_resolver.rb +3 -1
  119. data/lib/facter/resolvers/windows/uptime_resolver.rb +2 -1
  120. data/lib/facter/resolvers/windows/virtualization_resolver.rb +2 -1
  121. data/lib/facter/resolvers/windows/win_os_description_resolver.rb +3 -1
  122. data/lib/facter/resolvers/wpar_resolver.rb +1 -1
  123. data/lib/facter/resolvers/xen.rb +1 -1
  124. data/lib/facter/resolvers/zfs.rb +2 -1
  125. data/lib/facter/resolvers/zpool.rb +2 -1
  126. data/lib/facter/version.rb +1 -1
  127. metadata +4 -3
@@ -11,7 +11,12 @@ module Facter
11
11
 
12
12
  return unless fact_class
13
13
 
14
- fact_class.new.call_the_resolver
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 = resolve(internal_searched_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 resolve(searched_facts)
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 = nil
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.user_query) }
19
+ .select { |resolved_fact| resolved_fact.name.match(searched_fact.name) }
20
20
  .reject(&:user_query)
21
21
  .uniq(&:name)
22
22
  else
@@ -84,7 +84,7 @@ module Facter
84
84
 
85
85
  blocked_facts.each do |blocked|
86
86
  facts.each do |fact|
87
- next unless fact.name =~ /^#{blocked}/
87
+ next unless fact.name =~ /^#{blocked}\..*|^#{blocked}$/
88
88
 
89
89
  if fact.type == :core
90
90
  reject_list_core << fact
@@ -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
- augment_cli(Facter::ConfigReader.cli)
24
- augment_ruby(Facter::ConfigReader.global)
25
- end
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
- augment_facts(Facter::ConfigReader.ttls, Facter::ConfigReader.fact_groups)
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 = []
@@ -3,7 +3,7 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class AioAgentVersion < BaseResolver
6
- @fact_list ||= {}
6
+ init_resolver
7
7
 
8
8
  class << self
9
9
  private
@@ -4,7 +4,8 @@ module Facter
4
4
  module Resolvers
5
5
  class Architecture < BaseResolver
6
6
  # :architecture
7
- @fact_list ||= {}
7
+ init_resolver
8
+
8
9
  class << self
9
10
  private
10
11
 
@@ -4,7 +4,8 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class Disks < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
+
8
9
  class << self
9
10
  private
10
11
 
@@ -4,7 +4,7 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class Filesystem < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
8
 
9
9
  class << self
10
10
  private
@@ -4,7 +4,8 @@ module Facter
4
4
  module Resolvers
5
5
  class Hardware < BaseResolver
6
6
  # :hardware
7
- @fact_list ||= {}
7
+ init_resolver
8
+
8
9
  class << self
9
10
  private
10
11
 
@@ -4,7 +4,8 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class LoadAverages < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
+
8
9
  class << self
9
10
  private
10
11
 
@@ -4,8 +4,9 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class Memory < BaseResolver
7
+ init_resolver
7
8
  # :hardware
8
- @fact_list ||= {}
9
+
9
10
  class << self
10
11
  private
11
12
 
@@ -4,7 +4,8 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class Mountpoints < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
+
8
9
  BLOCK_SIZE = 512
9
10
 
10
11
  class << self
@@ -4,7 +4,7 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class Networking < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
8
 
9
9
  class << self
10
10
  private
@@ -4,7 +4,7 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class Nim < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
8
 
9
9
  class << self
10
10
  private
@@ -4,7 +4,7 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class OsLevel < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
8
 
9
9
  class << self
10
10
  private
@@ -4,7 +4,8 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class Partitions < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
+
8
9
  class << self
9
10
  private
10
11
 
@@ -4,7 +4,8 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class Processors < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
+
8
9
  class << self
9
10
  private
10
11
 
@@ -4,7 +4,7 @@ module Facter
4
4
  module Resolvers
5
5
  module Aix
6
6
  class Serialnumber < BaseResolver
7
- @fact_list ||= {}
7
+ init_resolver
8
8
 
9
9
  class << self
10
10
  private
@@ -3,7 +3,7 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class Augeas < BaseResolver
6
- @fact_list ||= {}
6
+ init_resolver
7
7
 
8
8
  class << self
9
9
  private
@@ -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
- subscribe_to_manager
20
- post_resolve(fact_name)
24
+ @semaphore.synchronize do
25
+ subscribe_to_manager
26
+ post_resolve(fact_name)
21
27
 
22
- validate_resolution(fact_name)
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.validate_resolution(fact_name)
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
@@ -4,8 +4,9 @@ module Facter
4
4
  module Resolvers
5
5
  module Bsd
6
6
  class Processors < BaseResolver
7
+ init_resolver
7
8
  @log = Facter::Log.new(self)
8
- @fact_list ||= {}
9
+
9
10
  class << self
10
11
  private
11
12
 
@@ -5,7 +5,7 @@ module Facter
5
5
  class Cloud < BaseResolver
6
6
  # cloud_provider
7
7
 
8
- @fact_list ||= {}
8
+ init_resolver
9
9
 
10
10
  class << self
11
11
  private
@@ -6,7 +6,8 @@ module Facter
6
6
  # :virtual
7
7
  # :hypervisor
8
8
 
9
- @fact_list ||= {}
9
+ init_resolver
10
+
10
11
  INFO = { 'docker' => 'id', 'lxc' => 'name' }.freeze
11
12
 
12
13
  class << self
@@ -7,7 +7,7 @@ module Facter
7
7
  # :minor
8
8
  # :full
9
9
 
10
- @fact_list ||= {}
10
+ init_resolver
11
11
 
12
12
  class << self
13
13
  private
@@ -5,9 +5,12 @@ module Facter
5
5
  module Linux
6
6
  class Disk < BaseResolver
7
7
  @log = Facter::Log.new(self)
8
- @fact_list ||= {}
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