facter 4.0.46 → 4.0.47

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/lib/docs/generate.rb +32 -0
  3. data/lib/docs/template.erb +34 -0
  4. data/lib/facter.rb +38 -6
  5. data/lib/facter/config.rb +32 -1
  6. data/lib/facter/custom_facts/util/collection.rb +1 -2
  7. data/lib/facter/custom_facts/util/directory_loader.rb +1 -1
  8. data/lib/facter/custom_facts/util/fact.rb +18 -1
  9. data/lib/facter/custom_facts/util/loader.rb +1 -1
  10. data/lib/facter/custom_facts/util/resolution.rb +1 -1
  11. data/lib/facter/facts/aix/interfaces.rb +1 -0
  12. data/lib/facter/facts/aix/memory/swap/available.rb +1 -1
  13. data/lib/facter/facts/aix/memory/swap/available_bytes.rb +1 -1
  14. data/lib/facter/facts/aix/memory/swap/total.rb +1 -1
  15. data/lib/facter/facts/aix/memory/swap/total_bytes.rb +1 -1
  16. data/lib/facter/facts/aix/memory/swap/used.rb +1 -1
  17. data/lib/facter/facts/aix/memory/system/available.rb +1 -1
  18. data/lib/facter/facts/aix/memory/system/available_bytes.rb +1 -1
  19. data/lib/facter/facts/aix/memory/system/total.rb +1 -1
  20. data/lib/facter/facts/aix/memory/system/total_bytes.rb +1 -1
  21. data/lib/facter/facts/aix/memory/system/used.rb +1 -1
  22. data/lib/facter/facts/aix/processors/speed.rb +1 -1
  23. data/lib/facter/facts/bsd/processors/speed.rb +1 -1
  24. data/lib/facter/facts/freebsd/is_virtual.rb +25 -0
  25. data/lib/facter/facts/freebsd/memory/swap/available.rb +1 -1
  26. data/lib/facter/facts/freebsd/memory/swap/available_bytes.rb +1 -1
  27. data/lib/facter/facts/freebsd/memory/swap/total.rb +1 -1
  28. data/lib/facter/facts/freebsd/memory/swap/total_bytes.rb +1 -1
  29. data/lib/facter/facts/freebsd/memory/swap/used.rb +1 -1
  30. data/lib/facter/facts/freebsd/memory/system/available.rb +1 -1
  31. data/lib/facter/facts/freebsd/memory/system/available_bytes.rb +1 -1
  32. data/lib/facter/facts/freebsd/memory/system/total.rb +1 -1
  33. data/lib/facter/facts/freebsd/memory/system/total_bytes.rb +1 -1
  34. data/lib/facter/facts/freebsd/memory/system/used.rb +1 -1
  35. data/lib/facter/facts/freebsd/processors/speed.rb +1 -1
  36. data/lib/facter/facts/freebsd/virtual.rb +22 -0
  37. data/lib/facter/facts/linux/dhcp_servers.rb +1 -0
  38. data/lib/facter/facts/linux/ec2_metadata.rb +1 -1
  39. data/lib/facter/facts/linux/ec2_userdata.rb +1 -1
  40. data/lib/facter/facts/linux/hypervisors/kvm.rb +1 -1
  41. data/lib/facter/facts/linux/hypervisors/xen.rb +1 -1
  42. data/lib/facter/facts/linux/interfaces.rb +1 -0
  43. data/lib/facter/facts/linux/is_virtual.rb +2 -2
  44. data/lib/facter/facts/linux/memory/swap/available.rb +1 -1
  45. data/lib/facter/facts/linux/memory/swap/available_bytes.rb +1 -1
  46. data/lib/facter/facts/linux/memory/swap/total.rb +1 -1
  47. data/lib/facter/facts/linux/memory/swap/total_bytes.rb +1 -1
  48. data/lib/facter/facts/linux/memory/swap/used.rb +1 -1
  49. data/lib/facter/facts/linux/memory/system/available.rb +1 -1
  50. data/lib/facter/facts/linux/memory/system/available_bytes.rb +1 -1
  51. data/lib/facter/facts/linux/memory/system/total.rb +1 -1
  52. data/lib/facter/facts/linux/memory/system/total_bytes.rb +1 -1
  53. data/lib/facter/facts/linux/memory/system/used.rb +1 -1
  54. data/lib/facter/facts/linux/processors/speed.rb +1 -1
  55. data/lib/facter/facts/linux/virtual.rb +1 -1
  56. data/lib/facter/facts/macosx/dhcp_servers.rb +1 -0
  57. data/lib/facter/facts/macosx/interfaces.rb +1 -0
  58. data/lib/facter/facts/macosx/memory/swap/available.rb +1 -1
  59. data/lib/facter/facts/macosx/memory/swap/available_bytes.rb +1 -1
  60. data/lib/facter/facts/macosx/memory/swap/total.rb +1 -1
  61. data/lib/facter/facts/macosx/memory/swap/total_bytes.rb +1 -1
  62. data/lib/facter/facts/macosx/memory/swap/used.rb +1 -1
  63. data/lib/facter/facts/macosx/memory/system/available.rb +1 -1
  64. data/lib/facter/facts/macosx/memory/system/available_bytes.rb +1 -1
  65. data/lib/facter/facts/macosx/memory/system/total.rb +1 -1
  66. data/lib/facter/facts/macosx/memory/system/total_bytes.rb +1 -1
  67. data/lib/facter/facts/macosx/memory/system/used.rb +1 -1
  68. data/lib/facter/facts/macosx/processors/speed.rb +1 -1
  69. data/lib/facter/facts/solaris/dhcp_servers.rb +1 -0
  70. data/lib/facter/facts/solaris/interfaces.rb +1 -0
  71. data/lib/facter/facts/solaris/is_virtual.rb +2 -2
  72. data/lib/facter/facts/solaris/ldom.rb +31 -4
  73. data/lib/facter/facts/solaris/memory/swap/available.rb +1 -1
  74. data/lib/facter/facts/solaris/memory/swap/available_bytes.rb +1 -1
  75. data/lib/facter/facts/solaris/memory/swap/total.rb +1 -1
  76. data/lib/facter/facts/solaris/memory/swap/total_bytes.rb +1 -1
  77. data/lib/facter/facts/solaris/memory/swap/used.rb +1 -1
  78. data/lib/facter/facts/solaris/memory/system/available.rb +1 -1
  79. data/lib/facter/facts/solaris/memory/system/available_bytes.rb +1 -1
  80. data/lib/facter/facts/solaris/memory/system/total.rb +1 -1
  81. data/lib/facter/facts/solaris/memory/system/total_bytes.rb +1 -1
  82. data/lib/facter/facts/solaris/memory/system/used.rb +1 -1
  83. data/lib/facter/facts/solaris/processors/speed.rb +1 -1
  84. data/lib/facter/facts/solaris/virtual.rb +1 -1
  85. data/lib/facter/facts/windows/dhcp_servers.rb +1 -0
  86. data/lib/facter/facts/windows/interfaces.rb +1 -0
  87. data/lib/facter/facts/windows/memory/system/available.rb +1 -1
  88. data/lib/facter/facts/windows/memory/system/available_bytes.rb +1 -1
  89. data/lib/facter/facts/windows/memory/system/total.rb +1 -1
  90. data/lib/facter/facts/windows/memory/system/total_bytes.rb +1 -1
  91. data/lib/facter/facts/windows/memory/system/used.rb +1 -1
  92. data/lib/facter/facts/windows/os/release.rb +1 -1
  93. data/lib/facter/framework/cli/cli.rb +1 -1
  94. data/lib/facter/framework/core/cache_manager.rb +1 -1
  95. data/lib/facter/framework/core/fact_loaders/external_fact_loader.rb +4 -2
  96. data/lib/facter/framework/core/fact_loaders/fact_loader.rb +16 -0
  97. data/lib/facter/framework/core/fact_manager.rb +14 -2
  98. data/lib/facter/framework/core/file_loader.rb +6 -2
  99. data/lib/facter/framework/core/options/option_store.rb +2 -2
  100. data/lib/facter/framework/logging/logger.rb +3 -3
  101. data/lib/facter/models/fact_collection.rb +11 -1
  102. data/lib/facter/models/loaded_fact.rb +2 -1
  103. data/lib/facter/resolvers/aio_agent_version.rb +1 -1
  104. data/lib/facter/resolvers/aix/architecture_resolver.rb +3 -3
  105. data/lib/facter/resolvers/aix/disks.rb +4 -4
  106. data/lib/facter/resolvers/aix/filesystem_resolver.rb +1 -1
  107. data/lib/facter/resolvers/aix/hardware_resolver.rb +2 -2
  108. data/lib/facter/resolvers/aix/memory.rb +2 -2
  109. data/lib/facter/resolvers/aix/mountpoints.rb +4 -4
  110. data/lib/facter/resolvers/aix/networking_resolver.rb +3 -2
  111. data/lib/facter/resolvers/aix/partitions.rb +5 -5
  112. data/lib/facter/resolvers/aix/processors.rb +3 -3
  113. data/lib/facter/resolvers/aix/serialnumber.rb +1 -1
  114. data/lib/facter/resolvers/base_resolver.rb +3 -0
  115. data/lib/facter/resolvers/cloud.rb +1 -1
  116. data/lib/facter/resolvers/containers.rb +3 -3
  117. data/lib/facter/resolvers/debian_version.rb +1 -1
  118. data/lib/facter/resolvers/disk_resolver.rb +2 -2
  119. data/lib/facter/resolvers/dmi_resolver.rb +1 -1
  120. data/lib/facter/resolvers/ec2.rb +3 -1
  121. data/lib/facter/resolvers/eos_release_resolver.rb +1 -1
  122. data/lib/facter/resolvers/filesystems_resolver.rb +1 -1
  123. data/lib/facter/resolvers/fips_enabled_resolver.rb +1 -1
  124. data/lib/facter/resolvers/freebsd/geom_resolver.rb +1 -1
  125. data/lib/facter/resolvers/freebsd/swap_memory_resolver.rb +3 -2
  126. data/lib/facter/resolvers/freebsd/system_memory_resolver.rb +2 -1
  127. data/lib/facter/resolvers/freebsd/virtual_resolver.rb +45 -0
  128. data/lib/facter/resolvers/gce.rb +1 -1
  129. data/lib/facter/resolvers/hostname_resolver.rb +67 -20
  130. data/lib/facter/resolvers/linux/docker_uptime.rb +1 -1
  131. data/lib/facter/resolvers/linux/load_averages.rb +1 -1
  132. data/lib/facter/resolvers/load_averages.rb +3 -2
  133. data/lib/facter/resolvers/macosx/mountpoints_resolver.rb +7 -7
  134. data/lib/facter/resolvers/macosx/system_profiler_resolver.rb +3 -3
  135. data/lib/facter/resolvers/memory_resolver.rb +1 -1
  136. data/lib/facter/resolvers/mountpoints_resolver.rb +8 -8
  137. data/lib/facter/resolvers/networking_linux_resolver.rb +183 -85
  138. data/lib/facter/resolvers/networking_resolver.rb +8 -5
  139. data/lib/facter/resolvers/open_vz.rb +1 -3
  140. data/lib/facter/resolvers/os_release_resolver.rb +1 -1
  141. data/lib/facter/resolvers/partitions.rb +5 -5
  142. data/lib/facter/resolvers/processors_resolver.rb +2 -2
  143. data/lib/facter/resolvers/redhat_release_resolver.rb +1 -1
  144. data/lib/facter/resolvers/selinux_resolver.rb +3 -3
  145. data/lib/facter/resolvers/solaris/disks.rb +1 -1
  146. data/lib/facter/resolvers/solaris/memory.rb +2 -2
  147. data/lib/facter/resolvers/solaris/mountpoints.rb +11 -10
  148. data/lib/facter/resolvers/solaris/networking.rb +49 -41
  149. data/lib/facter/resolvers/solaris/os_release.rb +1 -1
  150. data/lib/facter/resolvers/ssh_resolver.rb +3 -2
  151. data/lib/facter/resolvers/suse_release_resolver.rb +1 -1
  152. data/lib/facter/resolvers/uptime_resolver.rb +2 -2
  153. data/lib/facter/resolvers/windows/aio_agent_version.rb +1 -1
  154. data/lib/facter/resolvers/windows/dmi_bios_resolver.rb +1 -1
  155. data/lib/facter/resolvers/windows/dmi_computersystem_resolver.rb +1 -1
  156. data/lib/facter/resolvers/windows/memory_resolver.rb +4 -0
  157. data/lib/facter/resolvers/windows/networking_resolver.rb +3 -3
  158. data/lib/facter/resolvers/windows/processors_resolver.rb +1 -1
  159. data/lib/facter/resolvers/windows/ssh.rb +2 -2
  160. data/lib/facter/resolvers/windows/uptime_resolver.rb +1 -1
  161. data/lib/facter/resolvers/windows/virtualization_resolver.rb +1 -1
  162. data/lib/facter/resolvers/windows/win_os_description_resolver.rb +1 -1
  163. data/lib/facter/resolvers/xen.rb +1 -1
  164. data/lib/facter/util/aix/info_extractor.rb +24 -0
  165. data/lib/facter/util/aix/odm_query.rb +46 -0
  166. data/lib/facter/util/api_debugger.rb +33 -29
  167. data/lib/facter/util/facts/facts_utils.rb +14 -0
  168. data/lib/facter/util/facts/unit_converter.rb +61 -0
  169. data/lib/facter/util/facts/uptime_parser.rb +128 -0
  170. data/lib/facter/util/facts/virtual_detector.rb +90 -0
  171. data/lib/facter/util/facts/windows_release_finder.rb +55 -0
  172. data/lib/facter/{resolvers/macosx/utils → util/macosx}/system_profile_executor.rb +1 -1
  173. data/lib/facter/util/resolvers/aws_token.rb +37 -0
  174. data/lib/facter/{resolvers/utils → util/resolvers}/ffi/load_averages.rb +2 -2
  175. data/lib/facter/util/resolvers/filesystem_helper.rb +47 -0
  176. data/lib/facter/util/resolvers/fingerprint.rb +15 -0
  177. data/lib/facter/{resolvers/utils → util/resolvers}/http.rb +17 -10
  178. data/lib/facter/util/resolvers/networking.rb +90 -0
  179. data/lib/facter/util/resolvers/networking/dhcp.rb +21 -0
  180. data/lib/facter/util/resolvers/networking/networking.rb +109 -0
  181. data/lib/facter/util/resolvers/networking/primary_interface.rb +82 -0
  182. data/lib/facter/util/resolvers/ssh.rb +17 -0
  183. data/lib/facter/util/resolvers/ssh_helper.rb +31 -0
  184. data/lib/facter/{resolvers/utils → util/resolvers}/uptime_helper.rb +2 -2
  185. data/lib/facter/{framework/utils → util}/utils.rb +0 -0
  186. data/lib/facter/util/windows/win32ole.rb +30 -0
  187. data/lib/facter/version.rb +1 -1
  188. metadata +29 -41
  189. data/lib/facter/facts/aix/puppet_version.rb +0 -15
  190. data/lib/facter/facts/freebsd/puppet_version.rb +0 -15
  191. data/lib/facter/facts/linux/puppet_version.rb +0 -15
  192. data/lib/facter/facts/macosx/puppet_version.rb +0 -15
  193. data/lib/facter/facts/solaris/puppet_version.rb +0 -15
  194. data/lib/facter/facts/windows/puppet_version.rb +0 -15
  195. data/lib/facter/facts_utils/facts_utils.rb +0 -12
  196. data/lib/facter/facts_utils/unit_converter.rb +0 -59
  197. data/lib/facter/facts_utils/uptime_parser.rb +0 -124
  198. data/lib/facter/facts_utils/virtual_detector.rb +0 -78
  199. data/lib/facter/facts_utils/windows_release_finder.rb +0 -51
  200. data/lib/facter/resolvers/aix/utils/info_extractor.rb +0 -20
  201. data/lib/facter/resolvers/aix/utils/odm_query.rb +0 -42
  202. data/lib/facter/resolvers/puppet_version_resolver.rb +0 -26
  203. data/lib/facter/resolvers/utils/filesystem_helper.rb +0 -43
  204. data/lib/facter/resolvers/utils/fingerprint.rb +0 -11
  205. data/lib/facter/resolvers/utils/networking.rb +0 -88
  206. data/lib/facter/resolvers/utils/ssh.rb +0 -13
  207. data/lib/facter/resolvers/utils/ssh_helper.rb +0 -27
  208. data/lib/facter/resolvers/windows/utils/win32ole.rb +0 -24
@@ -11,7 +11,7 @@ module Facts
11
11
  def call_the_resolver
12
12
  fact_value = Facter::Resolvers::Macosx::SystemMemory.resolve(:total_bytes)
13
13
  [Facter::ResolvedFact.new(FACT_NAME, fact_value),
14
- Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
14
+ Facter::ResolvedFact.new(ALIASES, Facter::Util::Facts::UnitConverter.bytes_to_mb(fact_value), :legacy)]
15
15
  end
16
16
  end
17
17
  end
@@ -9,7 +9,7 @@ module Facts
9
9
 
10
10
  def call_the_resolver
11
11
  fact_value = Facter::Resolvers::Macosx::SystemMemory.resolve(:used_bytes)
12
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
12
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value)
13
13
 
14
14
  Facter::ResolvedFact.new(FACT_NAME, fact_value)
15
15
  end
@@ -8,7 +8,7 @@ module Facts
8
8
 
9
9
  def call_the_resolver
10
10
  fact_value = Facter::Resolvers::Macosx::Processors.resolve(:speed)
11
- speed = Facter::FactsUtils::UnitConverter.hertz_to_human_readable(fact_value)
11
+ speed = Facter::Util::Facts::UnitConverter.hertz_to_human_readable(fact_value)
12
12
  Facter::ResolvedFact.new(FACT_NAME, speed)
13
13
  end
14
14
  end
@@ -4,6 +4,7 @@ module Facts
4
4
  module Solaris
5
5
  class DhcpServers
6
6
  FACT_NAME = 'dhcp_servers'
7
+ TYPE = :legacy
7
8
 
8
9
  def call_the_resolver
9
10
  fact_value = construct_addresses_hash
@@ -4,6 +4,7 @@ module Facts
4
4
  module Solaris
5
5
  class Interfaces
6
6
  FACT_NAME = 'interfaces'
7
+ TYPE = :legacy
7
8
 
8
9
  def call_the_resolver
9
10
  fact_value = Facter::Resolvers::Solaris::Networking.resolve(:interfaces)
@@ -51,13 +51,13 @@ module Facts
51
51
 
52
52
  return unless product_name
53
53
 
54
- Facter::FactsUtils::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
54
+ Facter::Util::Facts::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
55
55
 
56
56
  nil
57
57
  end
58
58
 
59
59
  def check_if_virtual(found_vm)
60
- Facter::FactsUtils::PHYSICAL_HYPERVISORS.count(found_vm).zero?
60
+ Facter::Util::Facts::PHYSICAL_HYPERVISORS.count(found_vm).zero?
61
61
  end
62
62
  end
63
63
  end
@@ -4,16 +4,35 @@ module Facts
4
4
  module Solaris
5
5
  class Ldom
6
6
  FACT_NAME = 'ldom'
7
+ ALIASES = %w[
8
+ ldom_domainchassis
9
+ ldom_domaincontrol
10
+ ldom_domainname
11
+ ldom_domainrole_control
12
+ ldom_domainrole_impl
13
+ ldom_domainrole_io
14
+ ldom_domainrole_root
15
+ ldom_domainrole_service
16
+ ldom_domainuuid
17
+ ].freeze
7
18
 
8
19
  def initialize
9
20
  @log = Facter::Log.new(self)
10
21
  end
11
22
 
12
23
  def call_the_resolver
24
+ @log.debug('Solving the ldom fact.')
25
+ fact_value = resolve_fact
26
+ return Facter::ResolvedFact.new(FACT_NAME, nil) if fact_value.nil?
27
+
28
+ create_resolved_facts_list(fact_value)
29
+ end
30
+
31
+ def resolve_fact
13
32
  chassis_serial = resolve(:chassis_serial)
14
- return Facter::ResolvedFact.new(FACT_NAME, nil) if !chassis_serial || chassis_serial.empty?
33
+ return nil if !chassis_serial || chassis_serial.empty?
15
34
 
16
- fact_value = {
35
+ {
17
36
  domainchassis: chassis_serial,
18
37
  domaincontrol: resolve(:control_domain),
19
38
  domainname: resolve(:domain_name),
@@ -26,13 +45,21 @@ module Facts
26
45
  },
27
46
  domainuuid: resolve(:domain_uuid)
28
47
  }
29
-
30
- Facter::ResolvedFact.new(FACT_NAME, fact_value)
31
48
  end
32
49
 
33
50
  def resolve(key)
34
51
  Facter::Resolvers::Solaris::Ldom.resolve(key)
35
52
  end
53
+
54
+ def create_resolved_facts_list(fact_value)
55
+ resolved_facts = [Facter::ResolvedFact.new(FACT_NAME, fact_value)]
56
+ ALIASES.each do |fact_alias|
57
+ key = fact_alias.split('_')[1..-1].map!(&:to_sym)
58
+ resolved_facts << Facter::ResolvedFact.new(fact_alias, fact_value.dig(*key), :legacy)
59
+ end
60
+
61
+ resolved_facts
62
+ end
36
63
  end
37
64
  end
38
65
  end
@@ -11,7 +11,7 @@ module Facts
11
11
  def call_the_resolver
12
12
  fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
13
13
  if fact_value
14
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:available_bytes])
14
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value[:available_bytes])
15
15
  end
16
16
  [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
17
17
  end
@@ -13,7 +13,7 @@ module Facts
13
13
  fact_value = fact_value[:available_bytes] if fact_value
14
14
 
15
15
  [Facter::ResolvedFact.new(FACT_NAME, fact_value),
16
- Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
16
+ Facter::ResolvedFact.new(ALIASES, Facter::Util::Facts::UnitConverter.bytes_to_mb(fact_value), :legacy)]
17
17
  end
18
18
  end
19
19
  end
@@ -11,7 +11,7 @@ module Facts
11
11
  def call_the_resolver
12
12
  fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
13
13
  if fact_value
14
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:total_bytes])
14
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value[:total_bytes])
15
15
  end
16
16
  [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
17
17
  end
@@ -13,7 +13,7 @@ module Facts
13
13
  fact_value = fact_value[:total_bytes] if fact_value
14
14
 
15
15
  [Facter::ResolvedFact.new(FACT_NAME, fact_value),
16
- Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
16
+ Facter::ResolvedFact.new(ALIASES, Facter::Util::Facts::UnitConverter.bytes_to_mb(fact_value), :legacy)]
17
17
  end
18
18
  end
19
19
  end
@@ -10,7 +10,7 @@ module Facts
10
10
  def call_the_resolver
11
11
  fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
12
12
  if fact_value
13
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:used_bytes])
13
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value[:used_bytes])
14
14
  end
15
15
  Facter::ResolvedFact.new(FACT_NAME, fact_value)
16
16
  end
@@ -11,7 +11,7 @@ module Facts
11
11
  def call_the_resolver
12
12
  fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
13
13
  if fact_value
14
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:available_bytes])
14
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value[:available_bytes])
15
15
  end
16
16
  [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
17
17
  end
@@ -13,7 +13,7 @@ module Facts
13
13
  fact_value = fact_value[:available_bytes] if fact_value
14
14
 
15
15
  [Facter::ResolvedFact.new(FACT_NAME, fact_value),
16
- Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
16
+ Facter::ResolvedFact.new(ALIASES, Facter::Util::Facts::UnitConverter.bytes_to_mb(fact_value), :legacy)]
17
17
  end
18
18
  end
19
19
  end
@@ -11,7 +11,7 @@ module Facts
11
11
  def call_the_resolver
12
12
  fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
13
13
  if fact_value
14
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:total_bytes])
14
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value[:total_bytes])
15
15
  end
16
16
  [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
17
17
  end
@@ -13,7 +13,7 @@ module Facts
13
13
  fact_value = fact_value[:total_bytes] if fact_value
14
14
 
15
15
  [Facter::ResolvedFact.new(FACT_NAME, fact_value),
16
- Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
16
+ Facter::ResolvedFact.new(ALIASES, Facter::Util::Facts::UnitConverter.bytes_to_mb(fact_value), :legacy)]
17
17
  end
18
18
  end
19
19
  end
@@ -10,7 +10,7 @@ module Facts
10
10
  def call_the_resolver
11
11
  fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
12
12
  if fact_value
13
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:used_bytes])
13
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value[:used_bytes])
14
14
  end
15
15
  Facter::ResolvedFact.new(FACT_NAME, fact_value)
16
16
  end
@@ -8,7 +8,7 @@ module Facts
8
8
 
9
9
  def call_the_resolver
10
10
  fact_value = Facter::Resolvers::Solaris::Processors.resolve(:speed)
11
- speed = Facter::FactsUtils::UnitConverter.hertz_to_human_readable(fact_value)
11
+ speed = Facter::Util::Facts::UnitConverter.hertz_to_human_readable(fact_value)
12
12
  Facter::ResolvedFact.new(FACT_NAME, speed)
13
13
  end
14
14
  end
@@ -51,7 +51,7 @@ module Facts
51
51
 
52
52
  return unless product_name
53
53
 
54
- Facter::FactsUtils::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
54
+ Facter::Util::Facts::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
55
55
 
56
56
  nil
57
57
  end
@@ -4,6 +4,7 @@ module Facts
4
4
  module Windows
5
5
  class DhcpServers
6
6
  FACT_NAME = 'dhcp_servers'
7
+ TYPE = :legacy
7
8
 
8
9
  def call_the_resolver
9
10
  fact_value = construct_addresses_hash
@@ -4,6 +4,7 @@ module Facts
4
4
  module Windows
5
5
  class Interfaces
6
6
  FACT_NAME = 'interfaces'
7
+ TYPE = :legacy
7
8
 
8
9
  def call_the_resolver
9
10
  fact_value = Facter::Resolvers::Windows::Networking.resolve(:interfaces)
@@ -10,7 +10,7 @@ module Facts
10
10
 
11
11
  def call_the_resolver
12
12
  fact_value = Facter::Resolvers::Memory.resolve(:available_bytes)
13
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
13
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value)
14
14
 
15
15
  [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
16
16
  end
@@ -12,7 +12,7 @@ module Facts
12
12
  fact_value = Facter::Resolvers::Memory.resolve(:available_bytes)
13
13
 
14
14
  [Facter::ResolvedFact.new(FACT_NAME, fact_value),
15
- Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
15
+ Facter::ResolvedFact.new(ALIASES, Facter::Util::Facts::UnitConverter.bytes_to_mb(fact_value), :legacy)]
16
16
  end
17
17
  end
18
18
  end
@@ -10,7 +10,7 @@ module Facts
10
10
 
11
11
  def call_the_resolver
12
12
  fact_value = Facter::Resolvers::Memory.resolve(:total_bytes)
13
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
13
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value)
14
14
 
15
15
  [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
16
16
  end
@@ -12,7 +12,7 @@ module Facts
12
12
  fact_value = Facter::Resolvers::Memory.resolve(:total_bytes)
13
13
 
14
14
  [Facter::ResolvedFact.new(FACT_NAME, fact_value),
15
- Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
15
+ Facter::ResolvedFact.new(ALIASES, Facter::Util::Facts::UnitConverter.bytes_to_mb(fact_value), :legacy)]
16
16
  end
17
17
  end
18
18
  end
@@ -9,7 +9,7 @@ module Facts
9
9
 
10
10
  def call_the_resolver
11
11
  fact_value = Facter::Resolvers::Memory.resolve(:used_bytes)
12
- fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
12
+ fact_value = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(fact_value)
13
13
 
14
14
  Facter::ResolvedFact.new(FACT_NAME, fact_value)
15
15
  end
@@ -16,7 +16,7 @@ module Facts
16
16
  kernel_version: kernel_resolver(:kernelversion)
17
17
  }
18
18
 
19
- fact_value = Facter::WindowsReleaseFinder.find_release(input)
19
+ fact_value = Facter::Util::Facts::WindowsReleaseFinder.find_release(input)
20
20
  arr << Facter::ResolvedFact.new(FACT_NAME, ({ full: fact_value, major: fact_value } if fact_value))
21
21
  ALIASES.each { |aliass| arr << Facter::ResolvedFact.new(aliass, fact_value, :legacy) }
22
22
  arr
@@ -184,7 +184,7 @@ module Facter
184
184
  def help_header(_args)
185
185
  path = File.join(File.dirname(__FILE__), '../../')
186
186
 
187
- Util::FileHelper.safe_read("#{path}fixtures/facter_help_header")
187
+ Facter::Util::FileHelper.safe_read("#{path}fixtures/facter_help_header")
188
188
  end
189
189
 
190
190
  IGNORE_OPTIONS = %w[log_level color no_color].freeze
@@ -181,7 +181,7 @@ cache_format_version is incorrect!")
181
181
 
182
182
  cache_file_name = File.join(@cache_dir, group_name)
183
183
  data = nil
184
- file = Util::FileHelper.safe_read(cache_file_name)
184
+ file = Facter::Util::FileHelper.safe_read(cache_file_name)
185
185
  begin
186
186
  data = JSON.parse(file) unless file.nil?
187
187
  rescue JSON::ParserError
@@ -21,8 +21,9 @@ module Facter
21
21
 
22
22
  custom_facts_to_load = LegacyFacter.collection.custom_facts
23
23
 
24
- custom_facts_to_load&.each do |custom_fact_name|
25
- loaded_fact = LoadedFact.new(custom_fact_name.to_s, nil, :custom)
24
+ custom_facts_to_load&.each do |k, v|
25
+ loaded_fact = LoadedFact.new(k.to_s, nil, :custom)
26
+ loaded_fact.is_env = v.options[:is_env] if v.options[:is_env]
26
27
  custom_facts << loaded_fact
27
28
  end
28
29
 
@@ -37,6 +38,7 @@ module Facter
37
38
  external_facts_to_load&.each do |k, v|
38
39
  loaded_fact = LoadedFact.new(k.to_s, nil, :external)
39
40
  loaded_fact.file = v.options[:file]
41
+ loaded_fact.is_env = v.options[:is_env]
40
42
  external_facts << loaded_fact
41
43
  end
42
44
 
@@ -24,11 +24,27 @@ module Facter
24
24
  @internal_facts = load_internal_facts(options)
25
25
  @external_facts = load_external_facts(options)
26
26
 
27
+ filter_env_facts
28
+
27
29
  @facts = @internal_facts + @external_facts
28
30
  end
29
31
 
30
32
  private
31
33
 
34
+ def filter_env_facts
35
+ env_fact_names = @external_facts.select { |fact| fact.is_env == true }.map(&:name)
36
+ return unless env_fact_names.any?
37
+
38
+ @internal_facts.delete_if do |fact|
39
+ if env_fact_names.include?(fact.name)
40
+ @log.debug("Reading #{fact.name} fact from environment variable")
41
+ true
42
+ else
43
+ false
44
+ end
45
+ end
46
+ end
47
+
32
48
  def load_internal_facts(options)
33
49
  @log.debug('Loading internal facts')
34
50
  internal_facts = []
@@ -17,8 +17,7 @@ module Facter
17
17
  end
18
18
 
19
19
  def resolve_facts(user_query = [])
20
- loaded_facts = @fact_loader.load(Options.get)
21
- searched_facts = QueryParser.parse(user_query, loaded_facts)
20
+ searched_facts = parse_user_query(user_query)
22
21
 
23
22
  cache_manager = Facter::CacheManager.new
24
23
  searched_facts, cached_facts = cache_manager.resolve_facts(searched_facts)
@@ -32,6 +31,7 @@ module Facter
32
31
 
33
32
  FactFilter.new.filter_facts!(resolved_facts)
34
33
 
34
+ log_resolved_facts(resolved_facts)
35
35
  resolved_facts
36
36
  end
37
37
 
@@ -47,6 +47,12 @@ module Facter
47
47
 
48
48
  private
49
49
 
50
+ def parse_user_query(user_query)
51
+ loaded_facts = @fact_loader.load(Options.get)
52
+
53
+ QueryParser.parse(user_query, loaded_facts)
54
+ end
55
+
50
56
  def override_core_facts(core_facts, custom_facts)
51
57
  return core_facts unless custom_facts
52
58
 
@@ -60,5 +66,11 @@ module Facter
60
66
  def root_fact_name(fact)
61
67
  fact.name.split('.').first
62
68
  end
69
+
70
+ def log_resolved_facts(resolved_facts)
71
+ resolved_facts.each do |fact|
72
+ @log.debug("fact \"#{fact.name}\" has resolved to: #{fact.value}") unless fact.value.nil?
73
+ end
74
+ end
63
75
  end
64
76
  end
@@ -34,7 +34,11 @@ require 'facter/framework/config/fact_groups'
34
34
 
35
35
  load_dir(['config'])
36
36
 
37
- load_dir(%w[resolvers utils])
37
+ load_dir(['util'])
38
+ load_dir(%w[util resolvers])
39
+ load_dir(%w[util facts])
40
+ load_dir(%w[util resolvers networking])
41
+
38
42
  load_dir(['resolvers'])
39
43
  load_dir(['facts_utils'])
40
44
  load_dir(%w[framework core])
@@ -47,12 +51,12 @@ load_dir(%w[framework core fact external])
47
51
  load_dir(%w[framework formatters])
48
52
 
49
53
  os_hierarchy = OsDetector.instance.hierarchy
54
+ os_hierarchy.each { |operating_system| load_dir(['util', operating_system.downcase, '**']) }
50
55
  os_hierarchy.each { |operating_system| load_dir(['facts', operating_system.downcase, '**']) }
51
56
  os_hierarchy.each { |operating_system| load_dir(['resolvers', operating_system.downcase, '**']) }
52
57
 
53
58
  require 'facter/custom_facts/core/legacy_facter'
54
59
  load_dir(%w[framework utils])
55
- load_dir(['util'])
56
60
 
57
61
  require 'facter/framework/core/fact_augmenter'
58
62
  require 'facter/framework/parsers/query_parser'