facter 4.6.1 → 4.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/docs/generate.rb +6 -1
- data/lib/facter/config.rb +3 -2
- data/lib/facter/custom_facts/core/aggregate.rb +5 -1
- data/lib/facter/custom_facts/util/confine.rb +4 -2
- data/lib/facter/facts/linux/cloud/provider.rb +6 -3
- data/lib/facter/facts/openbsd/augeas/version.rb +19 -0
- data/lib/facter/facts/openbsd/dmi/bios/vendor.rb +19 -0
- data/lib/facter/facts/openbsd/dmi/bios/version.rb +19 -0
- data/lib/facter/facts/openbsd/dmi/manufacturer.rb +17 -0
- data/lib/facter/facts/openbsd/dmi/product/name.rb +19 -0
- data/lib/facter/facts/openbsd/dmi/product/serial_number.rb +19 -0
- data/lib/facter/facts/openbsd/dmi/product/uuid.rb +19 -0
- data/lib/facter/facts/openbsd/ec2_metadata.rb +23 -0
- data/lib/facter/facts/openbsd/ec2_userdata.rb +23 -0
- data/lib/facter/facts/openbsd/facterversion.rb +14 -0
- data/lib/facter/facts/openbsd/identity/gid.rb +16 -0
- data/lib/facter/facts/openbsd/identity/group.rb +18 -0
- data/lib/facter/facts/openbsd/identity/privileged.rb +16 -0
- data/lib/facter/facts/openbsd/identity/uid.rb +16 -0
- data/lib/facter/facts/openbsd/identity/user.rb +17 -0
- data/lib/facter/facts/openbsd/ipaddress6_interfaces.rb +20 -0
- data/lib/facter/facts/openbsd/ipaddress_interfaces.rb +20 -0
- data/lib/facter/facts/openbsd/is_virtual.rb +21 -0
- data/lib/facter/facts/openbsd/kernel.rb +14 -0
- data/lib/facter/facts/openbsd/kernelrelease.rb +14 -0
- data/lib/facter/facts/openbsd/mountpoints.rb +21 -0
- data/lib/facter/facts/openbsd/netmask6_interfaces.rb +20 -0
- data/lib/facter/facts/openbsd/netmask_interfaces.rb +20 -0
- data/lib/facter/facts/openbsd/network6_interfaces.rb +20 -0
- data/lib/facter/facts/openbsd/network_interfaces.rb +20 -0
- data/lib/facter/facts/openbsd/networking/dhcp.rb +17 -0
- data/lib/facter/facts/openbsd/networking/domain.rb +18 -0
- data/lib/facter/facts/openbsd/networking/fqdn.rb +18 -0
- data/lib/facter/facts/openbsd/networking/hostname.rb +18 -0
- data/lib/facter/facts/openbsd/networking/interfaces.rb +17 -0
- data/lib/facter/facts/openbsd/networking/ip.rb +18 -0
- data/lib/facter/facts/openbsd/networking/ip6.rb +18 -0
- data/lib/facter/facts/openbsd/networking/mac.rb +18 -0
- data/lib/facter/facts/openbsd/networking/mtu.rb +17 -0
- data/lib/facter/facts/openbsd/networking/netmask.rb +18 -0
- data/lib/facter/facts/openbsd/networking/netmask6.rb +18 -0
- data/lib/facter/facts/openbsd/networking/network.rb +18 -0
- data/lib/facter/facts/openbsd/networking/network6.rb +18 -0
- data/lib/facter/facts/openbsd/networking/primary.rb +17 -0
- data/lib/facter/facts/openbsd/networking/scope6.rb +17 -0
- data/lib/facter/facts/openbsd/os/architecture.rb +18 -0
- data/lib/facter/facts/openbsd/os/hardware.rb +18 -0
- data/lib/facter/facts/openbsd/os/name.rb +18 -0
- data/lib/facter/facts/openbsd/os/release.rb +23 -0
- data/lib/facter/facts/openbsd/path.rb +15 -0
- data/lib/facter/facts/openbsd/processors/isa.rb +17 -0
- data/lib/facter/facts/openbsd/ruby/platform.rb +18 -0
- data/lib/facter/facts/openbsd/ruby/sitedir.rb +18 -0
- data/lib/facter/facts/openbsd/ruby/version.rb +18 -0
- data/lib/facter/facts/openbsd/ssh.rb +26 -0
- data/lib/facter/facts/openbsd/sshalgorithmkey.rb +17 -0
- data/lib/facter/facts/openbsd/sshfp_algorithm.rb +20 -0
- data/lib/facter/facts/openbsd/system_uptime/days.rb +18 -0
- data/lib/facter/facts/openbsd/system_uptime/hours.rb +18 -0
- data/lib/facter/facts/openbsd/system_uptime/seconds.rb +18 -0
- data/lib/facter/facts/openbsd/system_uptime/uptime.rb +18 -0
- data/lib/facter/facts/openbsd/timezone.rb +15 -0
- data/lib/facter/facts/openbsd/virtual.rb +15 -0
- data/lib/facter/facts/solaris/ldom.rb +1 -1
- data/lib/facter/facts/windows/cloud/provider.rb +6 -3
- data/lib/facter/framework/cli/cli.rb +3 -3
- data/lib/facter/framework/core/file_loader.rb +59 -0
- data/lib/facter/framework/detector/os_detector.rb +2 -0
- data/lib/facter/framework/logging/logger.rb +3 -2
- data/lib/facter/resolvers/aix/serialnumber.rb +1 -1
- data/lib/facter/resolvers/az.rb +1 -1
- data/lib/facter/resolvers/base_resolver.rb +3 -2
- data/lib/facter/resolvers/bsd/processors.rb +0 -1
- data/lib/facter/resolvers/disks.rb +0 -2
- data/lib/facter/resolvers/dmi.rb +0 -2
- data/lib/facter/resolvers/ec2.rb +1 -1
- data/lib/facter/resolvers/filesystems.rb +0 -2
- data/lib/facter/resolvers/fips_enabled.rb +0 -2
- data/lib/facter/resolvers/freebsd/processors.rb +0 -1
- data/lib/facter/resolvers/freebsd/swap_memory.rb +1 -1
- data/lib/facter/resolvers/gce.rb +1 -1
- data/lib/facter/resolvers/hostname.rb +5 -0
- data/lib/facter/resolvers/identity.rb +0 -2
- data/lib/facter/resolvers/macosx/mountpoints.rb +0 -2
- data/lib/facter/resolvers/memory.rb +0 -2
- data/lib/facter/resolvers/mountpoints.rb +0 -2
- data/lib/facter/resolvers/networking.rb +1 -1
- data/lib/facter/resolvers/openbsd/dhcp.rb +21 -0
- data/lib/facter/resolvers/openbsd/dmi.rb +41 -0
- data/lib/facter/resolvers/openbsd/mountpoints.rb +72 -0
- data/lib/facter/resolvers/openbsd/virtual.rb +45 -0
- data/lib/facter/resolvers/partitions.rb +2 -2
- data/lib/facter/resolvers/processors.rb +0 -2
- data/lib/facter/resolvers/solaris/mountpoints.rb +0 -2
- data/lib/facter/resolvers/solaris/networking.rb +0 -1
- data/lib/facter/resolvers/ssh.rb +0 -2
- data/lib/facter/resolvers/windows/dmi_bios.rb +0 -1
- data/lib/facter/resolvers/windows/dmi_computersystem.rb +0 -1
- data/lib/facter/resolvers/windows/hardware_architecture.rb +0 -1
- data/lib/facter/resolvers/windows/identity.rb +0 -1
- data/lib/facter/resolvers/windows/kernel.rb +0 -2
- data/lib/facter/resolvers/windows/memory.rb +0 -2
- data/lib/facter/resolvers/windows/networking.rb +0 -1
- data/lib/facter/resolvers/windows/ssh.rb +0 -2
- data/lib/facter/resolvers/windows/system32.rb +0 -2
- data/lib/facter/resolvers/windows/timezone.rb +0 -1
- data/lib/facter/resolvers/windows/uptime.rb +0 -2
- data/lib/facter/resolvers/windows/virtualization.rb +9 -4
- data/lib/facter/resolvers/windows/win_os_description.rb +0 -2
- data/lib/facter/resolvers/xen.rb +2 -0
- data/lib/facter/templates/man.erb +5 -2
- data/lib/facter/util/api_debugger.rb +2 -2
- data/lib/facter/util/facts/posix/virtual_detector.rb +7 -1
- data/lib/facter/util/resolvers/http.rb +31 -20
- data/lib/facter/version.rb +1 -1
- 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
|
|
@@ -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
|
data/lib/facter/resolvers/az.rb
CHANGED
@@ -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
|
-
|
7
|
-
|
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
|
data/lib/facter/resolvers/dmi.rb
CHANGED
data/lib/facter/resolvers/ec2.rb
CHANGED
@@ -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
|
@@ -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
|
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(:+))
|
data/lib/facter/resolvers/gce.rb
CHANGED
@@ -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)
|
@@ -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
|
|
data/lib/facter/resolvers/ssh.rb
CHANGED
@@ -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 = {
|
16
|
-
|
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
|
|