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
@@ -26,7 +26,7 @@ module Facter
26
26
  @config_file_external_dir = []
27
27
  @default_external_dir = []
28
28
  @fact_groups = {}
29
- @sequential = false
29
+ @sequential = true
30
30
  @ttls = []
31
31
  @block_list = []
32
32
  @color = true
@@ -192,7 +192,7 @@ module Facter
192
192
  @fact_groups = {}
193
193
  @block_list = {}
194
194
  @color = true
195
- @sequential = false
195
+ @sequential = true
196
196
  @ttls = []
197
197
  @trace = false
198
198
  @timing = false
@@ -100,10 +100,10 @@ module Facter
100
100
  end
101
101
 
102
102
  def log_exception(exception)
103
- msg = colorize(exception.message, RED) + "\n"
104
- msg += exception.backtrace.join("\n") if Options[:trace]
103
+ msg = exception.message
104
+ msg += "\n" + exception.backtrace.join("\n") if Options[:trace]
105
105
 
106
- @@logger.error(@class_name + ' - ' + msg)
106
+ error(msg, true)
107
107
  end
108
108
 
109
109
  private
@@ -4,6 +4,7 @@ module Facter
4
4
  class FactCollection < Hash
5
5
  def initialize
6
6
  super
7
+ @log = Log.new(self)
7
8
  end
8
9
 
9
10
  def build_fact_collection!(facts)
@@ -39,7 +40,16 @@ module Facter
39
40
  private
40
41
 
41
42
  def bury_fact(fact)
42
- bury(*fact.name.split('.') + fact.filter_tokens << fact.value)
43
+ split_fact_name = extract_fact_name(fact)
44
+ bury(*split_fact_name + fact.filter_tokens << fact.value)
45
+ rescue NoMethodError
46
+ @log.error("#{fact.type.to_s.capitalize} fact `#{fact.name}` cannot be added to collection."\
47
+ ' The format of this fact is incompatible with other'\
48
+ " facts that belong to `#{fact.name.split('.').first}` group")
49
+ end
50
+
51
+ def extract_fact_name(fact)
52
+ fact.type == :legacy ? [fact.name] : fact.name.split('.')
43
53
  end
44
54
  end
45
55
  end
@@ -3,13 +3,14 @@
3
3
  module Facter
4
4
  class LoadedFact
5
5
  attr_reader :name, :klass, :type
6
- attr_accessor :file
6
+ attr_accessor :file, :is_env
7
7
 
8
8
  def initialize(name, klass, type = nil, file = nil)
9
9
  @name = name
10
10
  @klass = klass
11
11
  @type = type.nil? ? :core : type
12
12
  @file = file
13
+ @is_env = false
13
14
  end
14
15
  end
15
16
  end
@@ -13,7 +13,7 @@ module Facter
13
13
  end
14
14
 
15
15
  def read_agent_version
16
- aio_agent_version = Util::FileHelper.safe_read('/opt/puppetlabs/puppet/VERSION', nil)&.chomp
16
+ aio_agent_version = Facter::Util::FileHelper.safe_read('/opt/puppetlabs/puppet/VERSION', nil)&.chomp
17
17
  aio_agent_version = aio_agent_version&.match(/^\d+\.\d+\.\d+(\.\d+){0,2}/)&.to_s
18
18
  @fact_list[:aio_agent_version] = aio_agent_version
19
19
  end
@@ -14,10 +14,10 @@ module Facter
14
14
  end
15
15
 
16
16
  def read_architecture(fact_name)
17
- require_relative 'utils/odm_query'
17
+ require 'facter/util/aix/odm_query'
18
18
 
19
19
  proc_number = read_proc
20
- odmquery = ODMQuery.new
20
+ odmquery = Facter::Util::Aix::ODMQuery.new
21
21
  odmquery
22
22
  .equals('name', proc_number)
23
23
  .equals('attribute', 'type')
@@ -37,7 +37,7 @@ module Facter
37
37
  end
38
38
 
39
39
  def read_proc
40
- odmquery = ODMQuery.new
40
+ odmquery = Facter::Util::Aix::ODMQuery.new
41
41
  odmquery
42
42
  .equals('PdDvLn', 'processor/sys/proc_rspc')
43
43
  .equals('status', '1')
@@ -34,7 +34,7 @@ module Facter
34
34
 
35
35
  return if stdout.empty?
36
36
 
37
- info_size = InfoExtractor.extract(stdout, /PP SIZE:|TOTAL PPs:|FREE PPs:|PV STATE:/)
37
+ info_size = Facter::Util::Aix::InfoExtractor.extract(stdout, /PP SIZE:|TOTAL PPs:|FREE PPs:|PV STATE:/)
38
38
 
39
39
  return unless info_size['PV STATE']
40
40
 
@@ -42,7 +42,7 @@ module Facter
42
42
 
43
43
  {
44
44
  size_bytes: size_bytes,
45
- size: Facter::FactsUtils::UnitConverter.bytes_to_human_readable(size_bytes)
45
+ size: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(size_bytes)
46
46
  }
47
47
  end
48
48
 
@@ -50,9 +50,9 @@ module Facter
50
50
  physical_partitions = size_hash['TOTAL PPs'].to_i + size_hash['FREE PPs'].to_i
51
51
  size_physical_partition = size_hash['PP SIZE']
52
52
  exp = if size_physical_partition[/mega/]
53
- InfoExtractor::MEGABYTES_EXPONENT
53
+ Facter::Util::Aix::InfoExtractor::MEGABYTES_EXPONENT
54
54
  else
55
- InfoExtractor::GIGABYTES_EXPONENT
55
+ Facter::Util::Aix::InfoExtractor::GIGABYTES_EXPONENT
56
56
  end
57
57
  size_physical_partition.to_i * physical_partitions * exp
58
58
  end
@@ -14,7 +14,7 @@ module Facter
14
14
  end
15
15
 
16
16
  def read_vtf_file(fact_name)
17
- file_content = Util::FileHelper.safe_readlines('/etc/vfs')
17
+ file_content = Facter::Util::FileHelper.safe_readlines('/etc/vfs')
18
18
  return if file_content.empty?
19
19
 
20
20
  file_content = file_content.map do |line|
@@ -14,8 +14,8 @@ module Facter
14
14
  end
15
15
 
16
16
  def read_hardware(fact_name)
17
- require_relative 'utils/odm_query'
18
- odmquery = Facter::ODMQuery.new
17
+ require 'facter/util/aix/odm_query'
18
+ odmquery = Facter::Util::Aix::ODMQuery.new
19
19
  odmquery
20
20
  .equals('name', 'sys0')
21
21
  .equals('attribute', 'modelname')
@@ -44,7 +44,7 @@ module Facter
44
44
  { available_bytes: content[3].to_i * pagesize,
45
45
  total_bytes: total,
46
46
  used_bytes: used,
47
- capacity: FilesystemHelper.compute_capacity(used, total) }
47
+ capacity: Facter::Util::Resolvers::FilesystemHelper.compute_capacity(used, total) }
48
48
  end
49
49
 
50
50
  def populate_swap(content, pagesize)
@@ -56,7 +56,7 @@ module Facter
56
56
  { available_bytes: total - used,
57
57
  total_bytes: total,
58
58
  used_bytes: used,
59
- capacity: FilesystemHelper.compute_capacity(used, total) }
59
+ capacity: Facter::Util::Resolvers::FilesystemHelper.compute_capacity(used, total) }
60
60
  end
61
61
  end
62
62
  end
@@ -53,13 +53,13 @@ module Facter
53
53
  used_bytes = info[2]
54
54
  size_bytes = info[1]
55
55
  @fact_list[:mountpoints][info.last].merge!(
56
- capacity: FilesystemHelper.compute_capacity(used_bytes, size_bytes),
56
+ capacity: Facter::Util::Resolvers::FilesystemHelper.compute_capacity(used_bytes, size_bytes),
57
57
  available_bytes: available_bytes,
58
58
  used_bytes: used_bytes,
59
59
  size_bytes: size_bytes,
60
- available: FactsUtils::UnitConverter.bytes_to_human_readable(available_bytes),
61
- used: FactsUtils::UnitConverter.bytes_to_human_readable(used_bytes),
62
- size: FactsUtils::UnitConverter.bytes_to_human_readable(size_bytes)
60
+ available: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(available_bytes),
61
+ used: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(used_bytes),
62
+ size: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(size_bytes)
63
63
  )
64
64
  end
65
65
  end
@@ -21,7 +21,7 @@ module Facter
21
21
 
22
22
  populate_with_mtu_and_mac!(@fact_list[:interfaces])
23
23
  get_primary_interface_info(output)
24
- ::Resolvers::Utils::Networking.expand_main_bindings(@fact_list)
24
+ Facter::Util::Resolvers::Networking.expand_main_bindings(@fact_list)
25
25
  @fact_list[fact_name]
26
26
  end
27
27
 
@@ -49,7 +49,8 @@ module Facter
49
49
  mask_length = mask_length.to_i - 1 unless is_ipv4
50
50
  @fact_list[:interfaces][name] ||= {}
51
51
  @fact_list[:interfaces][name][bind_to_add] ||= []
52
- @fact_list[:interfaces][name][bind_to_add] << ::Resolvers::Utils::Networking.build_binding(ip, mask_length)
52
+ @fact_list[:interfaces][name][bind_to_add] << Facter::Util::Resolvers::Networking
53
+ .build_binding(ip, mask_length)
53
54
  end
54
55
 
55
56
  def populate_with_mtu_and_mac!(interfaces)
@@ -14,7 +14,7 @@ module Facter
14
14
  end
15
15
 
16
16
  def query_cudv(fact_name)
17
- odmquery = Facter::ODMQuery.new
17
+ odmquery = Facter::Util::Aix::ODMQuery.new
18
18
  odmquery.equals('PdDvLn', 'logical_volume/lvsubclass/lvtype')
19
19
 
20
20
  result = odmquery.execute
@@ -40,13 +40,13 @@ module Facter
40
40
 
41
41
  return if stdout.empty?
42
42
 
43
- info_hash = InfoExtractor.extract(stdout, /PPs:|PP SIZE|TYPE:|LABEL:|MOUNT/)
43
+ info_hash = Facter::Util::Aix::InfoExtractor.extract(stdout, /PPs:|PP SIZE|TYPE:|LABEL:|MOUNT/)
44
44
  size_bytes = compute_size(info_hash)
45
45
 
46
46
  part_info = {
47
47
  filesystem: info_hash['TYPE'],
48
48
  size_bytes: size_bytes,
49
- size: Facter::FactsUtils::UnitConverter.bytes_to_human_readable(size_bytes)
49
+ size: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(size_bytes)
50
50
  }
51
51
  mount = info_hash['MOUNT POINT']
52
52
  label = info_hash['LABEL']
@@ -59,9 +59,9 @@ module Facter
59
59
  physical_partitions = info_hash['PPs'].to_i
60
60
  size_physical_partition = info_hash['PP SIZE']
61
61
  exp = if size_physical_partition[/mega/]
62
- InfoExtractor::MEGABYTES_EXPONENT
62
+ Facter::Util::Aix::InfoExtractor::MEGABYTES_EXPONENT
63
63
  else
64
- InfoExtractor::GIGABYTES_EXPONENT
64
+ Facter::Util::Aix::InfoExtractor::GIGABYTES_EXPONENT
65
65
  end
66
66
  size_physical_partition.to_i * physical_partitions * exp
67
67
  end
@@ -17,7 +17,7 @@ module Facter
17
17
  @fact_list[:models] = []
18
18
  @fact_list[:logical_count] = 0
19
19
 
20
- odmquery = Facter::ODMQuery.new
20
+ odmquery = Facter::Util::Aix::ODMQuery.new
21
21
  odmquery.equals('class', 'processor')
22
22
 
23
23
  result = odmquery.execute
@@ -32,7 +32,7 @@ module Facter
32
32
  end
33
33
 
34
34
  def populate_from_cudv(name)
35
- odmquery = Facter::ODMQuery.new
35
+ odmquery = Facter::Util::Aix::ODMQuery.new
36
36
  odmquery.equals('PdDvLn', name)
37
37
 
38
38
  result = odmquery.execute
@@ -45,7 +45,7 @@ module Facter
45
45
  end
46
46
 
47
47
  def query_cuat(name)
48
- odmquery = Facter::ODMQuery.new
48
+ odmquery = Facter::Util::Aix::ODMQuery.new
49
49
  odmquery.equals('name', name)
50
50
 
51
51
  result = odmquery.execute
@@ -14,7 +14,7 @@ module Facter
14
14
  end
15
15
 
16
16
  def read_serialnumber(fact_name)
17
- odmquery = Facter::ODMQuery.new
17
+ odmquery = Facter::Util::Aix::ODMQuery.new
18
18
  odmquery
19
19
  .equals('name', 'sys0')
20
20
  .equals('attribute', 'systemid')
@@ -27,6 +27,9 @@ module Facter
27
27
 
28
28
  cache_nil_for_unresolved_facts(fact_name)
29
29
  end
30
+ rescue NoMethodError => e
31
+ log.debug("Could not resolve #{fact_name}, got #{e}")
32
+ @fact_list[fact_name] = nil
30
33
  rescue LoadError, NameError => e
31
34
  log.debug("resolving fact #{fact_name}, but #{e}")
32
35
  @fact_list[fact_name] = nil
@@ -23,7 +23,7 @@ module Facter
23
23
  files.select! { |filename| filename =~ /^dhclient.*lease.*$/ }
24
24
  files.each do |file|
25
25
  path = File.join([path, file])
26
- output = Util::FileHelper.safe_read(path)
26
+ output = Facter::Util::FileHelper.safe_read(path)
27
27
 
28
28
  if output.include?('option unknown-245') || output.include?('option 245')
29
29
  @fact_list[:cloud_provider] = 'azure'
@@ -18,8 +18,8 @@ module Facter
18
18
  end
19
19
 
20
20
  def read_cgroup(fact_name)
21
- output_cgroup = Util::FileHelper.safe_read('/proc/1/cgroup', nil)
22
- output_environ = Util::FileHelper.safe_read('/proc/1/environ', nil)
21
+ output_cgroup = Facter::Util::FileHelper.safe_read('/proc/1/cgroup', nil)
22
+ output_environ = Facter::Util::FileHelper.safe_read('/proc/1/environ', nil)
23
23
  return unless output_cgroup && output_environ
24
24
 
25
25
  output_docker = %r{docker/(.+)}.match(output_cgroup)
@@ -49,7 +49,7 @@ module Facter
49
49
  nspawn = /container=systemd-nspawn/ =~ output_environ
50
50
  if nspawn
51
51
  vm = 'systemd_nspawn'
52
- info = Util::FileHelper.safe_read('/etc/machine-id', nil)
52
+ info = Facter::Util::FileHelper.safe_read('/etc/machine-id', nil)
53
53
  end
54
54
  [info ? { 'id' => info.strip } : {}, vm]
55
55
  end
@@ -17,7 +17,7 @@ module Facter
17
17
  end
18
18
 
19
19
  def read_debian_version(fact_name)
20
- file_content = Util::FileHelper.safe_read('/etc/debian_version')
20
+ file_content = Facter::Util::FileHelper.safe_read('/etc/debian_version')
21
21
  @fact_list[:version] = file_content.strip unless file_content.empty?
22
22
 
23
23
  @fact_list[fact_name]
@@ -25,7 +25,7 @@ module Facter
25
25
  @fact_list[:disks].each do |disk, value|
26
26
  file_path = File.join(DIR, disk, file)
27
27
 
28
- result = Util::FileHelper.safe_read(file_path).strip
28
+ result = Facter::Util::FileHelper.safe_read(file_path).strip
29
29
  next if result.empty?
30
30
 
31
31
  value[key] = case key
@@ -55,7 +55,7 @@ module Facter
55
55
  def construct_size(facts, value)
56
56
  value = value.to_i * 512
57
57
  facts[:size_bytes] = value
58
- facts[:size] = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(value)
58
+ facts[:size] = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(value)
59
59
  end
60
60
  end
61
61
  end
@@ -35,7 +35,7 @@ module Facter
35
35
  product_serial product_uuid]
36
36
  return unless File.directory?('/sys/class/dmi')
37
37
 
38
- file_content = Util::FileHelper.safe_read("/sys/class/dmi/id/#{fact_name}", nil)
38
+ file_content = Facter::Util::FileHelper.safe_read("/sys/class/dmi/id/#{fact_name}", nil)
39
39
  if files.include?(fact_name.to_s) && file_content
40
40
  file_content = file_content.strip
41
41
  @fact_list[fact_name] = file_content unless file_content.empty?
@@ -50,7 +50,9 @@ module Facter
50
50
  end
51
51
 
52
52
  def get_data_from(url)
53
- Utils::Http.get_request(url, {}, { session: determine_session_timeout })
53
+ headers = {}
54
+ headers['X-aws-ec2-metadata-token'] = Facter::Util::Resolvers::AwsToken.get if ENV['AWS_IMDSv2']
55
+ Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout })
54
56
  end
55
57
 
56
58
  def determine_session_timeout
@@ -17,7 +17,7 @@ module Facter
17
17
  end
18
18
 
19
19
  def read_eos_release(fact_name)
20
- output = Util::FileHelper.safe_read('/etc/Eos-release', nil)
20
+ output = Facter::Util::FileHelper.safe_read('/etc/Eos-release', nil)
21
21
  return @fact_list[fact_name] = nil if output.nil?
22
22
 
23
23
  output_strings = output.split(' ')
@@ -18,7 +18,7 @@ module Facter
18
18
  end
19
19
 
20
20
  def read_filesystems(fact_name)
21
- output = Util::FileHelper.safe_readlines('/proc/filesystems', nil)
21
+ output = Facter::Util::FileHelper.safe_readlines('/proc/filesystems', nil)
22
22
  return unless output
23
23
 
24
24
  filesystems = []
@@ -18,7 +18,7 @@ module Facter
18
18
  end
19
19
 
20
20
  def read_fips_file(fact_name)
21
- file_output = Util::FileHelper.safe_read('/proc/sys/crypto/fips_enabled')
21
+ file_output = Facter::Util::FileHelper.safe_read('/proc/sys/crypto/fips_enabled')
22
22
  @fact_list[:fips_enabled] = file_output.strip == '1'
23
23
  @fact_list[fact_name]
24
24
  end
@@ -51,7 +51,7 @@ module Facter
51
51
  mediasize = Integer(mediasize.value)
52
52
 
53
53
  res[:size_bytes] = mediasize
54
- res[:size] = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(mediasize)
54
+ res[:size] = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(mediasize)
55
55
  res
56
56
  end
57
57
 
@@ -21,8 +21,9 @@ module Facter
21
21
  @fact_list[:total_bytes] = kilobytes_to_bytes(data.map { |line| line[1].to_i }.inject(:+))
22
22
  @fact_list[:used_bytes] = kilobytes_to_bytes(data.map { |line| line[2].to_i }.inject(:+))
23
23
  @fact_list[:available_bytes] = kilobytes_to_bytes(data.map { |line| line[3].to_i }.inject(:+))
24
- @fact_list[:capacity] = FilesystemHelper.compute_capacity(@fact_list[:used_bytes],
25
- @fact_list[:total_bytes])
24
+ @fact_list[:capacity] = Facter::Util::Resolvers::FilesystemHelper
25
+ .compute_capacity(@fact_list[:used_bytes],
26
+ @fact_list[:total_bytes])
26
27
  @fact_list[:encrypted] = data.map { |line| line[0].end_with?('.eli') }.all?
27
28
  end
28
29
 
@@ -18,7 +18,8 @@ module Facter
18
18
  read_available_memory_in_bytes
19
19
 
20
20
  @fact_list[:used_bytes] = @fact_list[:total_bytes] - @fact_list[:available_bytes]
21
- @fact_list[:capacity] = FilesystemHelper.compute_capacity(@fact_list[:used_bytes], @fact_list[:total_bytes])
21
+ @fact_list[:capacity] = Facter::Util::Resolvers::FilesystemHelper
22
+ .compute_capacity(@fact_list[:used_bytes], @fact_list[:total_bytes])
22
23
 
23
24
  @fact_list[fact_name]
24
25
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Resolvers
5
+ module Freebsd
6
+ class Virtual < BaseResolver
7
+ init_resolver
8
+
9
+ class << self
10
+ #:model
11
+
12
+ VM_GUEST_SYSCTL_NAMES = {
13
+ 'hv' => 'hyperv',
14
+ 'microsoft' => 'hyperv',
15
+ 'oracle' => 'virtualbox',
16
+ 'xen' => 'xenu',
17
+ 'none' => nil
18
+ }.freeze
19
+
20
+ private
21
+
22
+ def post_resolve(fact_name)
23
+ @fact_list.fetch(fact_name) { read_facts(fact_name) }
24
+ end
25
+
26
+ def read_facts(fact_name)
27
+ require_relative 'ffi/ffi_helper'
28
+
29
+ if Facter::Freebsd::FfiHelper.sysctl_by_name(:long, 'security.jail.jailed').zero?
30
+ vm = Facter::Freebsd::FfiHelper.sysctl_by_name(:string, 'kern.vm_guest')
31
+
32
+ vm = VM_GUEST_SYSCTL_NAMES[vm] if VM_GUEST_SYSCTL_NAMES.key?(vm)
33
+
34
+ @fact_list[:vm] = vm
35
+ else
36
+ @fact_list[:vm] = 'jail'
37
+ end
38
+
39
+ @fact_list[fact_name]
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end