facter 4.6.1 → 4.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/docs/generate.rb +6 -1
  3. data/lib/facter/config.rb +3 -2
  4. data/lib/facter/custom_facts/core/aggregate.rb +5 -1
  5. data/lib/facter/custom_facts/util/confine.rb +4 -2
  6. data/lib/facter/facts/linux/cloud/provider.rb +6 -3
  7. data/lib/facter/facts/openbsd/augeas/version.rb +19 -0
  8. data/lib/facter/facts/openbsd/dmi/bios/vendor.rb +19 -0
  9. data/lib/facter/facts/openbsd/dmi/bios/version.rb +19 -0
  10. data/lib/facter/facts/openbsd/dmi/manufacturer.rb +17 -0
  11. data/lib/facter/facts/openbsd/dmi/product/name.rb +19 -0
  12. data/lib/facter/facts/openbsd/dmi/product/serial_number.rb +19 -0
  13. data/lib/facter/facts/openbsd/dmi/product/uuid.rb +19 -0
  14. data/lib/facter/facts/openbsd/ec2_metadata.rb +23 -0
  15. data/lib/facter/facts/openbsd/ec2_userdata.rb +23 -0
  16. data/lib/facter/facts/openbsd/facterversion.rb +14 -0
  17. data/lib/facter/facts/openbsd/identity/gid.rb +16 -0
  18. data/lib/facter/facts/openbsd/identity/group.rb +18 -0
  19. data/lib/facter/facts/openbsd/identity/privileged.rb +16 -0
  20. data/lib/facter/facts/openbsd/identity/uid.rb +16 -0
  21. data/lib/facter/facts/openbsd/identity/user.rb +17 -0
  22. data/lib/facter/facts/openbsd/ipaddress6_interfaces.rb +20 -0
  23. data/lib/facter/facts/openbsd/ipaddress_interfaces.rb +20 -0
  24. data/lib/facter/facts/openbsd/is_virtual.rb +21 -0
  25. data/lib/facter/facts/openbsd/kernel.rb +14 -0
  26. data/lib/facter/facts/openbsd/kernelrelease.rb +14 -0
  27. data/lib/facter/facts/openbsd/mountpoints.rb +21 -0
  28. data/lib/facter/facts/openbsd/netmask6_interfaces.rb +20 -0
  29. data/lib/facter/facts/openbsd/netmask_interfaces.rb +20 -0
  30. data/lib/facter/facts/openbsd/network6_interfaces.rb +20 -0
  31. data/lib/facter/facts/openbsd/network_interfaces.rb +20 -0
  32. data/lib/facter/facts/openbsd/networking/dhcp.rb +17 -0
  33. data/lib/facter/facts/openbsd/networking/domain.rb +18 -0
  34. data/lib/facter/facts/openbsd/networking/fqdn.rb +18 -0
  35. data/lib/facter/facts/openbsd/networking/hostname.rb +18 -0
  36. data/lib/facter/facts/openbsd/networking/interfaces.rb +17 -0
  37. data/lib/facter/facts/openbsd/networking/ip.rb +18 -0
  38. data/lib/facter/facts/openbsd/networking/ip6.rb +18 -0
  39. data/lib/facter/facts/openbsd/networking/mac.rb +18 -0
  40. data/lib/facter/facts/openbsd/networking/mtu.rb +17 -0
  41. data/lib/facter/facts/openbsd/networking/netmask.rb +18 -0
  42. data/lib/facter/facts/openbsd/networking/netmask6.rb +18 -0
  43. data/lib/facter/facts/openbsd/networking/network.rb +18 -0
  44. data/lib/facter/facts/openbsd/networking/network6.rb +18 -0
  45. data/lib/facter/facts/openbsd/networking/primary.rb +17 -0
  46. data/lib/facter/facts/openbsd/networking/scope6.rb +17 -0
  47. data/lib/facter/facts/openbsd/os/architecture.rb +18 -0
  48. data/lib/facter/facts/openbsd/os/hardware.rb +18 -0
  49. data/lib/facter/facts/openbsd/os/name.rb +18 -0
  50. data/lib/facter/facts/openbsd/os/release.rb +23 -0
  51. data/lib/facter/facts/openbsd/path.rb +15 -0
  52. data/lib/facter/facts/openbsd/processors/isa.rb +17 -0
  53. data/lib/facter/facts/openbsd/ruby/platform.rb +18 -0
  54. data/lib/facter/facts/openbsd/ruby/sitedir.rb +18 -0
  55. data/lib/facter/facts/openbsd/ruby/version.rb +18 -0
  56. data/lib/facter/facts/openbsd/ssh.rb +26 -0
  57. data/lib/facter/facts/openbsd/sshalgorithmkey.rb +17 -0
  58. data/lib/facter/facts/openbsd/sshfp_algorithm.rb +20 -0
  59. data/lib/facter/facts/openbsd/system_uptime/days.rb +18 -0
  60. data/lib/facter/facts/openbsd/system_uptime/hours.rb +18 -0
  61. data/lib/facter/facts/openbsd/system_uptime/seconds.rb +18 -0
  62. data/lib/facter/facts/openbsd/system_uptime/uptime.rb +18 -0
  63. data/lib/facter/facts/openbsd/timezone.rb +15 -0
  64. data/lib/facter/facts/openbsd/virtual.rb +15 -0
  65. data/lib/facter/facts/solaris/ldom.rb +1 -1
  66. data/lib/facter/facts/windows/cloud/provider.rb +6 -3
  67. data/lib/facter/framework/cli/cli.rb +3 -3
  68. data/lib/facter/framework/core/file_loader.rb +59 -0
  69. data/lib/facter/framework/detector/os_detector.rb +2 -0
  70. data/lib/facter/framework/logging/logger.rb +3 -2
  71. data/lib/facter/resolvers/aix/serialnumber.rb +1 -1
  72. data/lib/facter/resolvers/az.rb +1 -1
  73. data/lib/facter/resolvers/base_resolver.rb +3 -2
  74. data/lib/facter/resolvers/bsd/processors.rb +0 -1
  75. data/lib/facter/resolvers/disks.rb +0 -2
  76. data/lib/facter/resolvers/dmi.rb +0 -2
  77. data/lib/facter/resolvers/ec2.rb +1 -1
  78. data/lib/facter/resolvers/filesystems.rb +0 -2
  79. data/lib/facter/resolvers/fips_enabled.rb +0 -2
  80. data/lib/facter/resolvers/freebsd/processors.rb +0 -1
  81. data/lib/facter/resolvers/freebsd/swap_memory.rb +1 -1
  82. data/lib/facter/resolvers/gce.rb +1 -1
  83. data/lib/facter/resolvers/hostname.rb +5 -0
  84. data/lib/facter/resolvers/identity.rb +0 -2
  85. data/lib/facter/resolvers/macosx/mountpoints.rb +0 -2
  86. data/lib/facter/resolvers/memory.rb +0 -2
  87. data/lib/facter/resolvers/mountpoints.rb +0 -2
  88. data/lib/facter/resolvers/networking.rb +1 -1
  89. data/lib/facter/resolvers/openbsd/dhcp.rb +21 -0
  90. data/lib/facter/resolvers/openbsd/dmi.rb +41 -0
  91. data/lib/facter/resolvers/openbsd/mountpoints.rb +72 -0
  92. data/lib/facter/resolvers/openbsd/virtual.rb +45 -0
  93. data/lib/facter/resolvers/partitions.rb +2 -2
  94. data/lib/facter/resolvers/processors.rb +0 -2
  95. data/lib/facter/resolvers/solaris/mountpoints.rb +0 -2
  96. data/lib/facter/resolvers/solaris/networking.rb +0 -1
  97. data/lib/facter/resolvers/ssh.rb +0 -2
  98. data/lib/facter/resolvers/windows/dmi_bios.rb +0 -1
  99. data/lib/facter/resolvers/windows/dmi_computersystem.rb +0 -1
  100. data/lib/facter/resolvers/windows/hardware_architecture.rb +0 -1
  101. data/lib/facter/resolvers/windows/identity.rb +0 -1
  102. data/lib/facter/resolvers/windows/kernel.rb +0 -2
  103. data/lib/facter/resolvers/windows/memory.rb +0 -2
  104. data/lib/facter/resolvers/windows/networking.rb +0 -1
  105. data/lib/facter/resolvers/windows/ssh.rb +0 -2
  106. data/lib/facter/resolvers/windows/system32.rb +0 -2
  107. data/lib/facter/resolvers/windows/timezone.rb +0 -1
  108. data/lib/facter/resolvers/windows/uptime.rb +0 -2
  109. data/lib/facter/resolvers/windows/virtualization.rb +9 -4
  110. data/lib/facter/resolvers/windows/win_os_description.rb +0 -2
  111. data/lib/facter/resolvers/xen.rb +2 -0
  112. data/lib/facter/templates/man.erb +5 -2
  113. data/lib/facter/util/api_debugger.rb +2 -2
  114. data/lib/facter/util/facts/posix/virtual_detector.rb +7 -1
  115. data/lib/facter/util/resolvers/http.rb +31 -20
  116. data/lib/facter/version.rb +1 -1
  117. metadata +99 -13
@@ -650,6 +650,65 @@ os_hierarchy.each do |os|
650
650
  require_relative '../../facts/ol/os/distro/description'
651
651
  require_relative '../../facts/ol/os/distro/id'
652
652
 
653
+ when 'openbsd'
654
+ require_relative '../../facts/openbsd/augeas/version'
655
+ require_relative '../../facts/openbsd/ec2_metadata'
656
+ require_relative '../../facts/openbsd/ec2_userdata'
657
+ require_relative '../../facts/openbsd/facterversion'
658
+ require_relative '../../facts/openbsd/is_virtual'
659
+ require_relative '../../facts/openbsd/kernel'
660
+ require_relative '../../facts/openbsd/kernelrelease'
661
+ require_relative '../../facts/openbsd/mountpoints'
662
+ require_relative '../../facts/openbsd/path'
663
+ require_relative '../../facts/openbsd/ssh'
664
+ require_relative '../../facts/openbsd/sshalgorithmkey'
665
+ require_relative '../../facts/openbsd/sshfp_algorithm'
666
+ require_relative '../../facts/openbsd/timezone'
667
+ require_relative '../../facts/openbsd/virtual'
668
+ require_relative '../../facts/openbsd/dmi/bios/vendor'
669
+ require_relative '../../facts/openbsd/dmi/bios/version'
670
+ require_relative '../../facts/openbsd/dmi/manufacturer'
671
+ require_relative '../../facts/openbsd/dmi/product/name'
672
+ require_relative '../../facts/openbsd/dmi/product/serial_number'
673
+ require_relative '../../facts/openbsd/dmi/product/uuid'
674
+ require_relative '../../facts/openbsd/identity/group'
675
+ require_relative '../../facts/openbsd/identity/gid'
676
+ require_relative '../../facts/openbsd/identity/privileged'
677
+ require_relative '../../facts/openbsd/identity/uid'
678
+ require_relative '../../facts/openbsd/identity/user'
679
+ require_relative '../../facts/openbsd/networking/dhcp'
680
+ require_relative '../../facts/openbsd/networking/domain'
681
+ require_relative '../../facts/openbsd/networking/fqdn'
682
+ require_relative '../../facts/openbsd/networking/hostname'
683
+ require_relative '../../facts/openbsd/networking/interfaces'
684
+ require_relative '../../facts/openbsd/networking/ip'
685
+ require_relative '../../facts/openbsd/networking/ip6'
686
+ require_relative '../../facts/openbsd/networking/mac'
687
+ require_relative '../../facts/openbsd/networking/mtu'
688
+ require_relative '../../facts/openbsd/networking/netmask'
689
+ require_relative '../../facts/openbsd/networking/netmask6'
690
+ require_relative '../../facts/openbsd/networking/network'
691
+ require_relative '../../facts/openbsd/networking/network6'
692
+ require_relative '../../facts/openbsd/networking/primary'
693
+ require_relative '../../facts/openbsd/networking/scope6'
694
+ require_relative '../../facts/openbsd/os/architecture'
695
+ require_relative '../../facts/openbsd/os/hardware'
696
+ require_relative '../../facts/openbsd/os/name'
697
+ require_relative '../../facts/openbsd/os/release'
698
+ require_relative '../../facts/openbsd/processors/isa'
699
+ require_relative '../../facts/openbsd/ruby/platform'
700
+ require_relative '../../facts/openbsd/ruby/sitedir'
701
+ require_relative '../../facts/openbsd/ruby/version'
702
+ require_relative '../../facts/openbsd/system_uptime/days'
703
+ require_relative '../../facts/openbsd/system_uptime/hours'
704
+ require_relative '../../facts/openbsd/system_uptime/seconds'
705
+ require_relative '../../facts/openbsd/system_uptime/uptime'
706
+
707
+ require_relative '../../resolvers/openbsd/dhcp'
708
+ require_relative '../../resolvers/openbsd/dmi'
709
+ require_relative '../../resolvers/openbsd/mountpoints'
710
+ require_relative '../../resolvers/openbsd/virtual'
711
+
653
712
  when 'openwrt'
654
713
  require_relative '../../facts/openwrt/os/release'
655
714
 
@@ -26,6 +26,8 @@ class OsDetector
26
26
  detect_distro
27
27
  when /freebsd/
28
28
  :freebsd
29
+ when /openbsd/i
30
+ :openbsd
29
31
  when /bsd/
30
32
  :bsd
31
33
  when /solaris/
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logger'
4
+ require 'set'
4
5
 
5
6
  module Facter
6
7
  RED = "\e[31m"
@@ -15,8 +16,8 @@ module Facter
15
16
  @@logger = nil
16
17
  @@message_callback = nil
17
18
  @@has_errors = false
18
- @@debug_messages = []
19
- @@warn_messages = []
19
+ @@debug_messages = Set.new
20
+ @@warn_messages = Set.new
20
21
  @@timing = false
21
22
 
22
23
  class << self
@@ -22,7 +22,7 @@ module Facter
22
22
 
23
23
  result.each_line do |line|
24
24
  if line.include?('value')
25
- @fact_list[:serialnumber] = line.split('=')[1].strip.delete('\"')[6..]
25
+ @fact_list[:serialnumber] = line.split('=')[1].strip.delete('\"')[6..-1]
26
26
  break
27
27
  end
28
28
  end
@@ -26,7 +26,7 @@ module Facter
26
26
 
27
27
  def get_data_from(url)
28
28
  headers = { Metadata: 'true' }
29
- Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout })
29
+ Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout }, false)
30
30
  end
31
31
 
32
32
  def determine_session_timeout
@@ -3,8 +3,8 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class BaseResolver
6
- def self.log
7
- @log ||= Log.new(self)
6
+ class << self
7
+ attr_reader :log
8
8
  end
9
9
 
10
10
  def self.invalidate_cache
@@ -14,6 +14,7 @@ module Facter
14
14
  def self.init_resolver
15
15
  @fact_list = {}
16
16
  @semaphore = Mutex.new
17
+ @log = Log.new(self)
17
18
  end
18
19
 
19
20
  def self.subscribe_to_manager
@@ -5,7 +5,6 @@ module Facter
5
5
  module Bsd
6
6
  class Processors < BaseResolver
7
7
  init_resolver
8
- @log = Facter::Log.new(self)
9
8
 
10
9
  class << self
11
10
  private
@@ -4,8 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  module Linux
6
6
  class Disks < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
7
  init_resolver
10
8
 
11
9
  DIR = '/sys/block'
@@ -4,8 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  module Linux
6
6
  class DmiBios < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
7
  init_resolver
10
8
 
11
9
  class << self
@@ -52,7 +52,7 @@ module Facter
52
52
  def get_data_from(url)
53
53
  headers = {}
54
54
  headers['X-aws-ec2-metadata-token'] = v2_token if v2_token
55
- Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout })
55
+ Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout }, false)
56
56
  end
57
57
 
58
58
  def determine_session_timeout
@@ -8,8 +8,6 @@ module Facter
8
8
 
9
9
  init_resolver
10
10
 
11
- @log = Facter::Log.new(self)
12
-
13
11
  class << self
14
12
  private
15
13
 
@@ -8,8 +8,6 @@ module Facter
8
8
 
9
9
  init_resolver
10
10
 
11
- @log = Facter::Log.new(self)
12
-
13
11
  class << self
14
12
  private
15
13
 
@@ -7,7 +7,6 @@ module Facter
7
7
  module Freebsd
8
8
  class Processors < BaseResolver
9
9
  init_resolver
10
- @log = Facter::Log.new(self)
11
10
 
12
11
  class << self
13
12
  private
@@ -15,7 +15,7 @@ module Facter
15
15
 
16
16
  def read_swap_memory(fact_name)
17
17
  output = Facter::Core::Execution.execute('swapinfo -k', logger: log)
18
- data = output.split("\n")[1..].map { |line| line.split(/\s+/) }
18
+ data = output.split("\n")[1..-1].map { |line| line.split(/\s+/) }
19
19
 
20
20
  unless data.empty?
21
21
  @fact_list[:total_bytes] = kilobytes_to_bytes(data.map { |line| line[1].to_i }.inject(:+))
@@ -22,7 +22,7 @@ module Facter
22
22
  end
23
23
 
24
24
  def query_for_metadata
25
- gce_data = extract_to_hash(Facter::Util::Resolvers::Http.get_request(METADATA_URL, HEADERS))
25
+ gce_data = extract_to_hash(Facter::Util::Resolvers::Http.get_request(METADATA_URL, HEADERS, false))
26
26
  parse_instance(gce_data)
27
27
 
28
28
  gce_data.empty? ? nil : gce_data
@@ -19,6 +19,11 @@ module Facter
19
19
  def retrieve_info(fact_name)
20
20
  require 'socket'
21
21
  output = Socket.gethostname
22
+ unless output
23
+ log.debug('Socket.gethostname failed to return hostname')
24
+ return
25
+ end
26
+
22
27
  hostname, domain = retrieve_from_fqdn(output)
23
28
 
24
29
  fqdn = retrieve_with_addrinfo(hostname) if hostname_and_no_domain?(hostname, domain)
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class PosxIdentity < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  class << self
@@ -7,8 +7,6 @@ module Facter
7
7
  include Facter::Util::Resolvers::FilesystemHelper
8
8
  init_resolver
9
9
 
10
- @log = Facter::Log.new(self)
11
-
12
10
  class << self
13
11
  private
14
12
 
@@ -6,8 +6,6 @@ module Facter
6
6
  class Memory < BaseResolver
7
7
  init_resolver
8
8
 
9
- @log = Facter::Log.new(self)
10
-
11
9
  class << self
12
10
  private
13
11
 
@@ -7,8 +7,6 @@ module Facter
7
7
 
8
8
  init_resolver
9
9
 
10
- @log = Facter::Log.new(self)
11
-
12
10
  class << self
13
11
  private
14
12
 
@@ -44,7 +44,7 @@ module Facter
44
44
 
45
45
  def parse_interfaces_response(response)
46
46
  parsed_interfaces_data = {}
47
- interfaces_data = Hash[*response.split(/^([A-Za-z0-9_.]+): /)[1..]]
47
+ interfaces_data = Hash[*response.split(/^([A-Za-z0-9_.]+): /)[1..-1]]
48
48
 
49
49
  interfaces_data.each do |interface_name, raw_data|
50
50
  parsed_interface_data = {}
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../networking'
4
+
5
+ module Facter
6
+ module Resolvers
7
+ module Openbsd
8
+ class Dhcp < Facter::Resolvers::Networking
9
+ init_resolver
10
+ class << self
11
+ def extract_dhcp(interface_name, raw_data, parsed_interface_data)
12
+ return unless raw_data.match?(/status:\s+active/)
13
+
14
+ result = Facter::Core::Execution.execute("dhcpleasectl -l #{interface_name}", logger: log)
15
+ parsed_interface_data[:dhcp] = extract_values(result, /\sdhcp server (\S+)/).first unless result.empty?
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Resolvers
5
+ module Openbsd
6
+ class DmiBios < BaseResolver
7
+ init_resolver
8
+
9
+ class << self
10
+ private
11
+
12
+ def post_resolve(fact_name, _options)
13
+ @fact_list.fetch(fact_name) { read_facts(fact_name) }
14
+ end
15
+
16
+ CTL_HW = 6
17
+ HW_VENDOR = 14
18
+ HW_PRODUCT = 15
19
+ HW_VERSION = 16
20
+ HW_SERIALNO = 17
21
+ HW_UUID = 18
22
+
23
+ def read_facts(fact_name)
24
+ require 'facter/resolvers/bsd/ffi/ffi_helper'
25
+
26
+ @fact_list[:bios_vendor] = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_VENDOR])
27
+ @fact_list[:bios_version] = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_VERSION])
28
+
29
+ @fact_list[:product_name] = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_PRODUCT])
30
+ @fact_list[:product_serial] = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_SERIALNO])
31
+ @fact_list[:product_uuid] = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_UUID])
32
+
33
+ @fact_list[:sys_vendor] = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_VENDOR])
34
+
35
+ @fact_list[fact_name]
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Resolvers
5
+ module Openbsd
6
+ class Mountpoints < BaseResolver
7
+ init_resolver
8
+
9
+ BLOCK_SIZE = 512
10
+
11
+ class << self
12
+ private
13
+
14
+ def post_resolve(fact_name, _options)
15
+ @fact_list.fetch(fact_name) { read_mount(fact_name) }
16
+ end
17
+
18
+ def read_mount(fact_name)
19
+ @fact_list[:mountpoints] = {}
20
+ output = Facter::Core::Execution.execute('mount', logger: log)
21
+ output.split("\n").map do |line|
22
+ add_mount_points_fact(line)
23
+ end
24
+
25
+ retrieve_sizes_for_mounts
26
+ @fact_list[fact_name]
27
+ end
28
+
29
+ def add_mount_points_fact(line)
30
+ elem = line.split("\s")
31
+ options = elem.drop(5)
32
+ options.each { |option| option.tr!('(),', '') }
33
+ @fact_list[:mountpoints][elem[2]] = { device: elem[0], filesystem: elem[4],
34
+ options: options }
35
+ end
36
+
37
+ def retrieve_sizes_for_mounts
38
+ output = Facter::Core::Execution.execute('df -P', logger: log)
39
+ output.split("\n").drop(1).map do |line|
40
+ next if line.match?(/-\s+-\s+-/)
41
+
42
+ mount_info = line.split("\s")
43
+ mount_info[3] = translate_to_bytes(mount_info[3])
44
+ mount_info[2] = translate_to_bytes(mount_info[2])
45
+ mount_info[1] = translate_to_bytes(mount_info[1])
46
+ compute_sizes(mount_info)
47
+ end
48
+ end
49
+
50
+ def translate_to_bytes(strin_size)
51
+ strin_size.to_i * BLOCK_SIZE
52
+ end
53
+
54
+ def compute_sizes(info)
55
+ available_bytes = info[3]
56
+ used_bytes = info[2]
57
+ size_bytes = info[1]
58
+ @fact_list[:mountpoints][info.last].merge!(
59
+ capacity: Facter::Util::Resolvers::FilesystemHelper.compute_capacity(used_bytes, size_bytes),
60
+ available_bytes: available_bytes,
61
+ used_bytes: used_bytes,
62
+ size_bytes: size_bytes,
63
+ available: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(available_bytes),
64
+ used: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(used_bytes),
65
+ size: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(size_bytes)
66
+ )
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Resolvers
5
+ module Openbsd
6
+ class Virtual < BaseResolver
7
+ init_resolver
8
+
9
+ class << self
10
+ # :model
11
+
12
+ VM_GUEST_SYSCTL_NAMES = {
13
+ 'VMM' => 'vmm',
14
+ 'vServer' => 'vserver',
15
+ 'oracle' => 'virtualbox',
16
+ 'xen' => 'xenu',
17
+ 'none' => nil
18
+ }.freeze
19
+
20
+ private
21
+
22
+ def post_resolve(fact_name, _options)
23
+ @fact_list.fetch(fact_name) { read_facts(fact_name) }
24
+ end
25
+
26
+ CTL_HW = 6
27
+ HW_PRODUCT = 15
28
+
29
+ def read_facts(fact_name)
30
+ require 'facter/resolvers/bsd/ffi/ffi_helper'
31
+
32
+ vm = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_PRODUCT])
33
+ vm = if VM_GUEST_SYSCTL_NAMES.key?(vm)
34
+ VM_GUEST_SYSCTL_NAMES[vm]
35
+ else
36
+ 'physical'
37
+ end
38
+ @fact_list[:vm] = vm
39
+ @fact_list[fact_name]
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -112,9 +112,9 @@ module Facter
112
112
 
113
113
  def execute_and_extract_blkid_info
114
114
  stdout = Facter::Core::Execution.execute('blkid', logger: log)
115
- output_hash = Hash[*stdout.split(/^([^:]+):/)[1..]]
115
+ output_hash = Hash[*stdout.split(/^([^:]+):/)[1..-1]]
116
116
  output_hash.each do |key, value|
117
- output_hash[key] = Hash[*value.delete('"').chomp.rstrip.split(/ ([^= ]+)=/)[1..]]
117
+ output_hash[key] = Hash[*value.delete('"').chomp.rstrip.split(/ ([^= ]+)=/)[1..-1]]
118
118
  end
119
119
  end
120
120
 
@@ -4,8 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  module Linux
6
6
  class Processors < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
7
  init_resolver
10
8
 
11
9
  MHZ_TO_HZ = 1_000_000
@@ -7,8 +7,6 @@ module Facter
7
7
  include Facter::Util::Resolvers::FilesystemHelper
8
8
  init_resolver
9
9
 
10
- @log = Facter::Log.new(self)
11
-
12
10
  class << self
13
11
  private
14
12
 
@@ -6,7 +6,6 @@ module Facter
6
6
  module Solaris
7
7
  class Networking < BaseResolver
8
8
  init_resolver
9
- @log = Facter::Log.new(self)
10
9
 
11
10
  class << self
12
11
  private
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class Ssh < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  FILE_NAMES = %w[ssh_host_rsa_key.pub ssh_host_dsa_key.pub ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub].freeze
@@ -3,7 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class DMIBios < BaseResolver
6
- @log = Facter::Log.new(self)
7
6
  init_resolver
8
7
 
9
8
  class << self
@@ -3,7 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class DMIComputerSystem < BaseResolver
6
- @log = Facter::Log.new(self)
7
6
  init_resolver
8
7
 
9
8
  class << self
@@ -24,7 +24,6 @@ module Facter
24
24
  build_facts_list(hardware: hard, architecture: arch)
25
25
  @fact_list[fact_name]
26
26
  rescue LoadError => e
27
- log = Facter::Log.new(self)
28
27
  log.debug("The ffi gem has not been installed: #{e}")
29
28
  end
30
29
 
@@ -4,7 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  class Identity < BaseResolver
6
6
  NAME_SAM_COMPATIBLE = 2
7
- @log = Facter::Log.new(self)
8
7
 
9
8
  init_resolver
10
9
 
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class Kernel < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  class << self
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class Memory < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  class << self
@@ -4,7 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  module Windows
6
6
  class Networking < BaseResolver
7
- @log = Facter::Log.new(self)
8
7
  init_resolver
9
8
 
10
9
  class << self
@@ -4,8 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  module Windows
6
6
  class Ssh < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
7
  init_resolver
10
8
 
11
9
  FILE_NAMES = %w[ssh_host_rsa_key.pub ssh_host_dsa_key.pub
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class System32 < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  class << self
@@ -34,7 +34,6 @@ module Facter
34
34
  require_relative '../../../facter/resolvers/windows/ffi/winnls_ffi'
35
35
  WinnlsFFI.GetACP.to_s
36
36
  rescue LoadError => e
37
- log = Facter::Log.new(self)
38
37
  log.debug("Could not retrieve codepage: #{e}")
39
38
  end
40
39
  end
@@ -6,8 +6,6 @@ module Facter
6
6
  module Resolvers
7
7
  module Windows
8
8
  class Uptime < BaseResolver
9
- @log = Facter::Log.new(self)
10
-
11
9
  init_resolver
12
10
 
13
11
  class << self
@@ -4,16 +4,21 @@ module Facter
4
4
  module Resolvers
5
5
  module Windows
6
6
  class Virtualization < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
7
  init_resolver
10
8
 
11
9
  class << self
12
10
  # Virtual
13
11
  # Is_Virtual
14
12
 
15
- MODEL_HASH = { 'VirtualBox' => 'virtualbox', 'VMware' => 'vmware', 'KVM' => 'kvm',
16
- 'Bochs' => 'bochs', 'Google' => 'gce', 'OpenStack' => 'openstack' }.freeze
13
+ MODEL_HASH = {
14
+ 'VirtualBox' => 'virtualbox',
15
+ 'VMware' => 'vmware',
16
+ 'KVM' => 'kvm',
17
+ 'Bochs' => 'bochs',
18
+ 'Google' => 'gce',
19
+ 'OpenStack' => 'openstack',
20
+ 'AHV' => 'ahv'
21
+ }.freeze
17
22
 
18
23
  private
19
24