facter 4.0.52 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +202 -0
- data/lib/facter.rb +21 -21
- data/lib/facter/config.rb +2 -0
- data/lib/facter/custom_facts/core/execution/base.rb +7 -3
- data/lib/facter/custom_facts/core/execution/popen3.rb +13 -1
- data/lib/facter/custom_facts/core/execution/posix.rb +2 -2
- data/lib/facter/custom_facts/core/execution/windows.rb +1 -1
- data/lib/facter/custom_facts/util/collection.rb +5 -0
- data/lib/facter/custom_facts/util/directory_loader.rb +1 -1
- data/lib/facter/custom_facts/util/normalization.rb +7 -2
- data/lib/facter/custom_facts/util/windows_root.rb +2 -1
- data/lib/facter/facts/aix/processors/cores.rb +16 -0
- data/lib/facter/facts/aix/processors/threads.rb +16 -0
- data/lib/facter/facts/freebsd/is_virtual.rb +1 -5
- data/lib/facter/facts/freebsd/virtual.rb +1 -2
- data/lib/facter/facts/linux/az_metadata.rb +1 -5
- data/lib/facter/facts/linux/cloud/provider.rb +5 -2
- data/lib/facter/facts/linux/ec2_metadata.rb +1 -5
- data/lib/facter/facts/linux/ec2_userdata.rb +1 -5
- data/lib/facter/facts/linux/hypervisors/xen.rb +1 -4
- data/lib/facter/facts/linux/is_virtual.rb +1 -5
- data/lib/facter/facts/linux/processors/cores.rb +16 -0
- data/lib/facter/facts/linux/processors/threads.rb +16 -0
- data/lib/facter/facts/linux/virtual.rb +1 -2
- data/lib/facter/facts/macosx/os/macosx/version.rb +15 -4
- data/lib/facter/facts/macosx/processors/cores.rb +16 -0
- data/lib/facter/facts/macosx/processors/threads.rb +16 -0
- data/lib/facter/facts/solaris/hypervisors/ldom.rb +1 -1
- data/lib/facter/facts/solaris/hypervisors/zone.rb +1 -1
- data/lib/facter/facts/solaris/mountpoints.rb +1 -1
- data/lib/facter/facts/solaris/processors/cores.rb +16 -0
- data/lib/facter/facts/solaris/processors/threads.rb +16 -0
- data/lib/facter/facts/windows/az_metadata.rb +1 -5
- data/lib/facter/facts/windows/cloud/provider.rb +6 -2
- data/lib/facter/facts/windows/ec2_metadata.rb +1 -1
- data/lib/facter/facts/windows/ec2_userdata.rb +1 -1
- data/lib/facter/facts/windows/gce.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/hyperv.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/kvm.rb +2 -1
- data/lib/facter/facts/windows/hypervisors/virtualbox.rb +2 -2
- data/lib/facter/facts/windows/hypervisors/vmware.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/xen.rb +3 -1
- data/lib/facter/facts/windows/is_virtual.rb +15 -0
- data/lib/facter/facts/windows/{virtualization/is_virtual.rb → processors/cores.rb} +4 -4
- data/lib/facter/facts/windows/{virtualization/virtual.rb → processors/threads.rb} +4 -4
- data/lib/facter/facts/windows/virtual.rb +15 -0
- data/lib/facter/framework/cli/cli.rb +13 -15
- data/lib/facter/framework/core/cache_manager.rb +2 -2
- data/lib/facter/framework/core/fact/external/external_fact_manager.rb +0 -1
- data/lib/facter/framework/core/fact/internal/internal_fact_manager.rb +41 -39
- data/lib/facter/framework/core/fact_filter.rb +4 -14
- data/lib/facter/framework/core/fact_loaders/external_fact_loader.rb +9 -6
- data/lib/facter/framework/core/fact_loaders/fact_loader.rb +39 -36
- data/lib/facter/framework/core/fact_manager.rb +82 -14
- data/lib/facter/framework/core/file_loader.rb +1 -1
- data/lib/facter/framework/core/options/config_file_options.rb +7 -0
- data/lib/facter/framework/core/options/option_store.rb +3 -1
- data/lib/facter/framework/formatters/formatter_helper.rb +3 -5
- data/lib/facter/framework/parsers/query_parser.rb +10 -24
- data/lib/facter/models/fact_collection.rb +48 -5
- data/lib/facter/models/resolved_fact.rb +2 -3
- data/lib/facter/models/searched_fact.rb +2 -3
- data/lib/facter/resolvers/aix/ffi/ffi_helper.rb +1 -1
- data/lib/facter/resolvers/aix/processors.rb +4 -0
- data/lib/facter/resolvers/base_resolver.rb +2 -2
- data/lib/facter/resolvers/dmi_decode.rb +0 -1
- data/lib/facter/resolvers/ec2.rb +8 -1
- data/lib/facter/resolvers/linux/hostname.rb +16 -5
- data/lib/facter/resolvers/linux/networking.rb +18 -1
- data/lib/facter/resolvers/lsb_release.rb +1 -2
- data/lib/facter/resolvers/macosx/mountpoints.rb +14 -1
- data/lib/facter/resolvers/macosx/processor.rb +16 -1
- data/lib/facter/resolvers/mountpoints.rb +16 -8
- data/lib/facter/resolvers/networking.rb +6 -3
- data/lib/facter/resolvers/partitions.rb +1 -3
- data/lib/facter/resolvers/processors_lscpu.rb +44 -0
- data/lib/facter/resolvers/ruby.rb +1 -1
- data/lib/facter/resolvers/selinux.rb +5 -7
- data/lib/facter/resolvers/solaris/ffi/structs.rb +12 -0
- data/lib/facter/resolvers/solaris/mountpoints.rb +22 -16
- data/lib/facter/resolvers/solaris/networking.rb +20 -5
- data/lib/facter/resolvers/solaris/processors.rb +7 -0
- data/lib/facter/resolvers/solaris/zone.rb +0 -1
- data/lib/facter/resolvers/windows/ffi/identity_ffi.rb +5 -0
- data/lib/facter/resolvers/windows/ffi/kernel_ffi.rb +1 -1
- data/lib/facter/resolvers/windows/identity.rb +1 -6
- data/lib/facter/resolvers/windows/processors.rb +41 -4
- data/lib/facter/resolvers/windows/uptime.rb +3 -22
- data/lib/facter/resolvers/windows/virtualization.rb +46 -44
- data/lib/facter/resolvers/xen.rb +6 -1
- data/lib/facter/templates/man.erb +6 -6
- data/lib/facter/util/facts/posix/virtual_detector.rb +74 -0
- data/lib/facter/util/facts/unit_converter.rb +2 -2
- data/lib/facter/util/linux/dhcp.rb +4 -1
- data/lib/facter/util/linux/if_inet6.rb +73 -0
- data/lib/facter/util/linux/socket_parser.rb +18 -3
- data/lib/facter/util/resolvers/http.rb +7 -1
- data/lib/facter/util/resolvers/networking/primary_interface.rb +11 -5
- data/lib/facter/util/utils.rb +18 -1
- data/lib/facter/version.rb +1 -1
- metadata +60 -11
- data/lib/facter/framework/core/fact_augmenter.rb +0 -37
- data/lib/facter/util/facts/virtual_detector.rb +0 -90
@@ -8,18 +8,16 @@ module Facter
|
|
8
8
|
@internal_fact_mgr = InternalFactManager.new
|
9
9
|
@external_fact_mgr = ExternalFactManager.new
|
10
10
|
@fact_loader = FactLoader.instance
|
11
|
+
@options = Options.get
|
11
12
|
@log = Log.new(self)
|
12
13
|
end
|
13
14
|
|
14
|
-
def searched_facts(user_query = [])
|
15
|
-
loaded_facts = @fact_loader.load(Options.get)
|
16
|
-
QueryParser.parse(user_query, loaded_facts)
|
17
|
-
end
|
18
|
-
|
19
15
|
def resolve_facts(user_query = [])
|
20
|
-
|
21
|
-
|
16
|
+
@options[:user_query] = user_query
|
22
17
|
cache_manager = Facter::CacheManager.new
|
18
|
+
|
19
|
+
searched_facts = QueryParser.parse(user_query, @fact_loader.load(user_query, @options))
|
20
|
+
|
23
21
|
searched_facts, cached_facts = cache_manager.resolve_facts(searched_facts)
|
24
22
|
internal_facts = @internal_fact_mgr.resolve_facts(searched_facts)
|
25
23
|
external_facts = @external_fact_mgr.resolve_facts(searched_facts)
|
@@ -35,23 +33,93 @@ module Facter
|
|
35
33
|
resolved_facts
|
36
34
|
end
|
37
35
|
|
38
|
-
|
39
|
-
|
36
|
+
# resolve a fact by name, in a similar way that facter 3 does.
|
37
|
+
# search is done in multiple steps, and the next step is executed
|
38
|
+
# only if the previous one was not able to resolve the fact
|
39
|
+
# - load the `fact_name.rb` from the configured custom directories
|
40
|
+
# - load all the core facts, external facts and env facts
|
41
|
+
# - load all custom facts
|
42
|
+
def resolve_fact(user_query)
|
43
|
+
@options[:user_query] = user_query
|
44
|
+
@log.debug("resolving fact with user_query: #{user_query}")
|
45
|
+
|
46
|
+
@cache_manager = Facter::CacheManager.new
|
47
|
+
|
48
|
+
custom_facts = custom_fact_by_filename(user_query) || []
|
49
|
+
core_and_external_facts = core_or_external_fact(user_query) || []
|
50
|
+
resolved_facts = core_and_external_facts + custom_facts
|
51
|
+
|
52
|
+
resolved_facts = all_custom_facts(user_query) if resolved_facts.empty?
|
53
|
+
|
54
|
+
@cache_manager.cache_facts(resolved_facts)
|
55
|
+
|
56
|
+
log_resolved_facts(resolved_facts)
|
57
|
+
resolved_facts
|
58
|
+
end
|
59
|
+
|
60
|
+
def resolve_core(user_query = [], options = {})
|
61
|
+
@cache_manager = CacheManager.new
|
62
|
+
core_fact(user_query, options)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def core_fact(user_query, options)
|
68
|
+
loaded_facts_hash = @fact_loader.load_internal_facts(user_query, options)
|
40
69
|
|
41
70
|
searched_facts = QueryParser.parse(user_query, loaded_facts_hash)
|
71
|
+
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
72
|
+
|
42
73
|
resolved_facts = @internal_fact_mgr.resolve_facts(searched_facts)
|
74
|
+
resolved_facts = resolved_facts.concat(cached_facts)
|
75
|
+
|
43
76
|
FactFilter.new.filter_facts!(resolved_facts, user_query)
|
44
77
|
|
45
78
|
resolved_facts
|
46
79
|
end
|
47
80
|
|
48
|
-
|
81
|
+
def custom_fact_by_filename(user_query)
|
82
|
+
@log.debug("Searching fact: #{user_query} in file: #{user_query}.rb")
|
83
|
+
|
84
|
+
custom_fact = @fact_loader.load_custom_fact(@options, user_query)
|
85
|
+
return unless custom_fact.any?
|
86
|
+
|
87
|
+
searched_facts = parse_user_query(custom_fact, user_query)
|
88
|
+
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
89
|
+
|
90
|
+
resolved_facts = @external_fact_mgr.resolve_facts(searched_facts)
|
91
|
+
resolved_facts = resolved_facts.concat(cached_facts)
|
92
|
+
resolved_facts if resolved_facts.any?
|
93
|
+
end
|
49
94
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
95
|
+
def core_or_external_fact(user_query)
|
96
|
+
@log.debug("Searching fact: #{user_query} in core facts and external facts")
|
97
|
+
|
98
|
+
core_facts = core_fact([user_query], @options)
|
99
|
+
external_facts = @fact_loader.load_external_facts(@options)
|
100
|
+
searched_facts = parse_user_query(external_facts, user_query)
|
101
|
+
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
102
|
+
|
103
|
+
resolved_facts = @external_fact_mgr.resolve_facts(searched_facts)
|
104
|
+
resolved_facts = override_core_facts(core_facts, resolved_facts)
|
105
|
+
resolved_facts = resolved_facts.concat(cached_facts)
|
106
|
+
|
107
|
+
resolved_facts unless resolved_facts.map(&:value).compact.empty?
|
108
|
+
end
|
109
|
+
|
110
|
+
def all_custom_facts(user_query)
|
111
|
+
@log.debug("Searching fact: #{user_query} in all custom facts")
|
112
|
+
|
113
|
+
custom_facts = @fact_loader.load_custom_facts(@options)
|
114
|
+
searched_facts = parse_user_query(custom_facts, user_query)
|
115
|
+
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
116
|
+
|
117
|
+
resolved_facts = @external_fact_mgr.resolve_facts(searched_facts)
|
118
|
+
resolved_facts.concat(cached_facts)
|
119
|
+
end
|
54
120
|
|
121
|
+
def parse_user_query(loaded_facts, user_query)
|
122
|
+
user_query = Array(user_query)
|
55
123
|
QueryParser.parse(user_query, loaded_facts)
|
56
124
|
end
|
57
125
|
|
@@ -37,6 +37,7 @@ load_dir(['config'])
|
|
37
37
|
load_dir(['util'])
|
38
38
|
load_dir(%w[util resolvers])
|
39
39
|
load_dir(%w[util facts])
|
40
|
+
load_dir(%w[util facts posix])
|
40
41
|
load_dir(%w[util resolvers networking])
|
41
42
|
|
42
43
|
load_dir(['resolvers'])
|
@@ -58,5 +59,4 @@ os_hierarchy.each { |operating_system| load_dir(['resolvers', operating_system.d
|
|
58
59
|
require 'facter/custom_facts/core/legacy_facter'
|
59
60
|
load_dir(%w[framework utils])
|
60
61
|
|
61
|
-
require 'facter/framework/core/fact_augmenter'
|
62
62
|
require 'facter/framework/parsers/query_parser'
|
@@ -18,6 +18,12 @@ module Facter
|
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
+
def augment_structured_facts(global_conf)
|
22
|
+
return if !global_conf || global_conf['force-dot-resolution'].nil?
|
23
|
+
|
24
|
+
@options[:force_dot_resolution] = global_conf['force-dot-resolution']
|
25
|
+
end
|
26
|
+
|
21
27
|
def augment_all
|
22
28
|
augment_cli(Facter::ConfigReader.cli) if Options.cli?
|
23
29
|
augment_globals
|
@@ -27,6 +33,7 @@ module Facter
|
|
27
33
|
def augment_globals
|
28
34
|
augment_ruby(Facter::ConfigReader.global)
|
29
35
|
|
36
|
+
augment_structured_facts(Facter::ConfigReader.global)
|
30
37
|
augment_custom(Facter::ConfigReader.global)
|
31
38
|
augment_external(Facter::ConfigReader.global)
|
32
39
|
augment_show_legacy(Facter::ConfigReader.global)
|
@@ -35,6 +35,7 @@ module Facter
|
|
35
35
|
@custom_dir = []
|
36
36
|
@hocon = false
|
37
37
|
@allow_external_loggers = true
|
38
|
+
@force_dot_resolution = false
|
38
39
|
|
39
40
|
class << self
|
40
41
|
attr_reader :debug, :verbose, :log_level, :show_legacy,
|
@@ -42,7 +43,7 @@ module Facter
|
|
42
43
|
|
43
44
|
attr_accessor :config, :strict, :json,
|
44
45
|
:cache, :yaml, :puppet, :ttls, :block, :cli, :config_file_custom_dir,
|
45
|
-
:config_file_external_dir, :default_external_dir, :fact_groups,
|
46
|
+
:config_file_external_dir, :default_external_dir, :fact_groups, :force_dot_resolution,
|
46
47
|
:block_list, :color, :trace, :sequential, :timing, :hocon, :allow_external_loggers
|
47
48
|
|
48
49
|
attr_writer :external_dir
|
@@ -202,6 +203,7 @@ module Facter
|
|
202
203
|
|
203
204
|
def reset_facts
|
204
205
|
@custom_facts = true
|
206
|
+
@force_dot_resolution = false
|
205
207
|
@external_dir = []
|
206
208
|
@custom_dir = []
|
207
209
|
end
|
@@ -4,12 +4,11 @@ module Facter
|
|
4
4
|
class FormatterHelper
|
5
5
|
class << self
|
6
6
|
def retrieve_facts_to_display_for_user_query(user_queries, resolved_facts)
|
7
|
-
facts_to_display =
|
7
|
+
facts_to_display = FactCollection.new
|
8
8
|
user_queries.each do |user_query|
|
9
9
|
fact_collection = build_fact_collection_for_user_query(user_query, resolved_facts)
|
10
10
|
|
11
|
-
|
12
|
-
printable_value = fact_collection.dig(*splitted_user_query)
|
11
|
+
printable_value = fact_collection.dig_fact(user_query)
|
13
12
|
facts_to_display.merge!(user_query => printable_value)
|
14
13
|
end
|
15
14
|
|
@@ -24,8 +23,7 @@ module Facter
|
|
24
23
|
def retrieve_fact_value_for_single_query(user_query, resolved_facts)
|
25
24
|
fact_collection = build_fact_collection_for_user_query(user_query, resolved_facts)
|
26
25
|
fact_collection = Utils.sort_hash_by_key(fact_collection)
|
27
|
-
|
28
|
-
fact_collection.dig(*splitted_user_query)
|
26
|
+
fact_collection.dig_fact(user_query)
|
29
27
|
end
|
30
28
|
|
31
29
|
private
|
@@ -41,7 +41,7 @@ module Facter
|
|
41
41
|
def no_user_query(loaded_facts)
|
42
42
|
searched_facts = []
|
43
43
|
loaded_facts.each do |loaded_fact|
|
44
|
-
searched_facts << SearchedFact.new(loaded_fact.name, loaded_fact.klass,
|
44
|
+
searched_facts << SearchedFact.new(loaded_fact.name, loaded_fact.klass, '', loaded_fact.type)
|
45
45
|
end
|
46
46
|
searched_facts
|
47
47
|
end
|
@@ -59,7 +59,7 @@ module Facter
|
|
59
59
|
return resolvable_fact_list if resolvable_fact_list.any?
|
60
60
|
end
|
61
61
|
|
62
|
-
resolvable_fact_list << SearchedFact.new(query, nil,
|
62
|
+
resolvable_fact_list << SearchedFact.new(query, nil, query, :nil) if resolvable_fact_list.empty?
|
63
63
|
|
64
64
|
resolvable_fact_list
|
65
65
|
end
|
@@ -69,19 +69,12 @@ module Facter
|
|
69
69
|
resolvable_fact_list = []
|
70
70
|
|
71
71
|
loaded_fact_hash.each do |loaded_fact|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
query_fact = query_tokens[query_token_range].join('.')
|
79
|
-
|
80
|
-
next unless found_fact?(loaded_fact.name, query_fact)
|
81
|
-
|
82
|
-
searched_fact = construct_loaded_fact(query_tokens, query_token_range, loaded_fact)
|
83
|
-
resolvable_fact_list << searched_fact
|
84
|
-
end
|
72
|
+
query_fact = query_tokens[query_token_range].join('.')
|
73
|
+
|
74
|
+
next unless found_fact?(loaded_fact.name, query_fact)
|
75
|
+
|
76
|
+
searched_fact = construct_loaded_fact(query_tokens, loaded_fact)
|
77
|
+
resolvable_fact_list << searched_fact
|
85
78
|
end
|
86
79
|
|
87
80
|
@log.debug "List of resolvable facts: #{resolvable_fact_list.inspect}"
|
@@ -100,23 +93,16 @@ module Facter
|
|
100
93
|
true
|
101
94
|
end
|
102
95
|
|
103
|
-
def construct_loaded_fact(query_tokens,
|
104
|
-
filter_tokens = construct_filter_tokens(query_tokens, query_token_range)
|
96
|
+
def construct_loaded_fact(query_tokens, loaded_fact)
|
105
97
|
user_query = @query_list.any? ? query_tokens.join('.') : ''
|
106
98
|
fact_name = loaded_fact.name.to_s
|
107
99
|
klass_name = loaded_fact.klass
|
108
100
|
type = loaded_fact.type
|
109
|
-
sf = SearchedFact.new(fact_name, klass_name,
|
101
|
+
sf = SearchedFact.new(fact_name, klass_name, user_query, type)
|
110
102
|
sf.file = loaded_fact.file
|
111
103
|
|
112
104
|
sf
|
113
105
|
end
|
114
|
-
|
115
|
-
def construct_filter_tokens(query_tokens, query_token_range)
|
116
|
-
(query_tokens - query_tokens[query_token_range]).map do |token|
|
117
|
-
token =~ /^[0-9]+$/ ? token.to_i : token
|
118
|
-
end
|
119
|
-
end
|
120
106
|
end
|
121
107
|
end
|
122
108
|
end
|
@@ -7,6 +7,16 @@ module Facter
|
|
7
7
|
@log = Log.new(self)
|
8
8
|
end
|
9
9
|
|
10
|
+
def to_yaml
|
11
|
+
deep_to_h.to_yaml
|
12
|
+
end
|
13
|
+
|
14
|
+
# Transorms a list of {Facter::ResolvedFact} into a nested collection.
|
15
|
+
# @param facts [Array<Facter::ResolvedFact>]
|
16
|
+
#
|
17
|
+
# @return [FactCollection]
|
18
|
+
#
|
19
|
+
# @api private
|
10
20
|
def build_fact_collection!(facts)
|
11
21
|
facts.each do |fact|
|
12
22
|
next if %i[core legacy].include?(fact.type) && fact.value.nil?
|
@@ -17,9 +27,29 @@ module Facter
|
|
17
27
|
self
|
18
28
|
end
|
19
29
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
30
|
+
def dig_fact(user_query)
|
31
|
+
value(user_query)
|
32
|
+
rescue KeyError, TypeError
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
36
|
+
# Collection#fetch implementation for nested collections.
|
37
|
+
# @param user_query [String] the search terms, separated by "."
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
#
|
41
|
+
# @example for fact_collection = { "os": { "name": "Darwin" } }
|
42
|
+
# fact_collection.fetch("os.name") #=> "Darwin"
|
43
|
+
#
|
44
|
+
# @api private
|
45
|
+
def value(user_query)
|
46
|
+
fetch(user_query) do
|
47
|
+
split_user_query = Facter::Utils.split_user_query(user_query)
|
48
|
+
split_user_query.reduce(self) do |memo, key|
|
49
|
+
raise KeyError unless memo.respond_to?(:fetch)
|
50
|
+
|
51
|
+
memo.fetch(key) { memo.fetch(key.to_s) }
|
52
|
+
end
|
23
53
|
end
|
24
54
|
end
|
25
55
|
|
@@ -39,9 +69,15 @@ module Facter
|
|
39
69
|
|
40
70
|
private
|
41
71
|
|
72
|
+
def deep_to_h(collection = self)
|
73
|
+
collection.each_pair.with_object({}) do |(key, value), hash|
|
74
|
+
hash[key] = value.is_a?(FactCollection) ? deep_to_h(value) : value
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
42
78
|
def bury_fact(fact)
|
43
79
|
split_fact_name = extract_fact_name(fact)
|
44
|
-
bury(*split_fact_name
|
80
|
+
bury(*split_fact_name << fact.value)
|
45
81
|
rescue NoMethodError
|
46
82
|
@log.error("#{fact.type.to_s.capitalize} fact `#{fact.name}` cannot be added to collection."\
|
47
83
|
' The format of this fact is incompatible with other'\
|
@@ -49,7 +85,14 @@ module Facter
|
|
49
85
|
end
|
50
86
|
|
51
87
|
def extract_fact_name(fact)
|
52
|
-
fact.type
|
88
|
+
case fact.type
|
89
|
+
when :legacy
|
90
|
+
[fact.name]
|
91
|
+
when :custom, :external
|
92
|
+
Options[:force_dot_resolution] == true ? fact.name.split('.') : [fact.name]
|
93
|
+
else
|
94
|
+
fact.name.split('.')
|
95
|
+
end
|
53
96
|
end
|
54
97
|
end
|
55
98
|
end
|
@@ -3,14 +3,13 @@
|
|
3
3
|
module Facter
|
4
4
|
class ResolvedFact
|
5
5
|
attr_reader :name, :type
|
6
|
-
attr_accessor :user_query, :
|
6
|
+
attr_accessor :user_query, :value, :file
|
7
7
|
|
8
|
-
def initialize(name, value = '', type = :core, user_query = nil
|
8
|
+
def initialize(name, value = '', type = :core, user_query = nil)
|
9
9
|
@name = name
|
10
10
|
@value = Utils.deep_stringify_keys(value)
|
11
11
|
@type = type
|
12
12
|
@user_query = user_query
|
13
|
-
@filter_tokens = filter_tokens
|
14
13
|
end
|
15
14
|
|
16
15
|
def legacy?
|
@@ -2,13 +2,12 @@
|
|
2
2
|
|
3
3
|
module Facter
|
4
4
|
class SearchedFact
|
5
|
-
attr_reader :name, :fact_class, :
|
5
|
+
attr_reader :name, :fact_class, :user_query, :type
|
6
6
|
attr_accessor :file
|
7
7
|
|
8
|
-
def initialize(fact_name, fact_class,
|
8
|
+
def initialize(fact_name, fact_class, user_query, type)
|
9
9
|
@name = fact_name
|
10
10
|
@fact_class = fact_class
|
11
|
-
@filter_tokens = filter_tokens
|
12
11
|
@user_query = user_query
|
13
12
|
@type = type
|
14
13
|
end
|
@@ -33,7 +33,7 @@ module Facter
|
|
33
33
|
|
34
34
|
return if Libc.getkerninfo(KINFO_READ | KINFO_GET_AVENRUN, averages, averages_size, 0).negative?
|
35
35
|
|
36
|
-
averages.read_array_of_long_long(3).map { |x| (x / 65_536.0)
|
36
|
+
averages.read_array_of_long_long(3).map { |x| (x / 65_536.0) }
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.read_interfaces
|
@@ -16,6 +16,8 @@ module Facter
|
|
16
16
|
def query_pddv(fact_name)
|
17
17
|
@fact_list[:models] = []
|
18
18
|
@fact_list[:logical_count] = 0
|
19
|
+
@fact_list[:cores_per_socket] = 0
|
20
|
+
@fact_list[:threads_per_core] = 0
|
19
21
|
|
20
22
|
odmquery = Facter::Util::Aix::ODMQuery.new
|
21
23
|
odmquery.equals('class', 'processor')
|
@@ -59,6 +61,8 @@ module Facter
|
|
59
61
|
threads = smt_enabled ? smt_threads : 1
|
60
62
|
|
61
63
|
@fact_list[:logical_count] += threads
|
64
|
+
@fact_list[:cores_per_socket] += 1
|
65
|
+
@fact_list[:threads_per_core] = threads
|
62
66
|
@fact_list[:models].concat([type] * threads)
|
63
67
|
end
|
64
68
|
|
@@ -28,10 +28,10 @@ module Facter
|
|
28
28
|
cache_nil_for_unresolved_facts(fact_name)
|
29
29
|
end
|
30
30
|
rescue NoMethodError => e
|
31
|
-
log.debug("Could not resolve #{fact_name}, got #{e}")
|
31
|
+
log.debug("Could not resolve #{fact_name}, got #{e} at #{e.backtrace[0]}")
|
32
32
|
@fact_list[fact_name] = nil
|
33
33
|
rescue LoadError, NameError => e
|
34
|
-
log.debug("
|
34
|
+
log.debug("Resolving fact #{fact_name}, but got #{e} at #{e.backtrace[0]}")
|
35
35
|
@fact_list[fact_name] = nil
|
36
36
|
end
|
37
37
|
|
@@ -37,7 +37,6 @@ module Facter
|
|
37
37
|
@fact_list[:virtualbox_version] = output.match(/vboxVer_(\S+)/)&.captures&.first
|
38
38
|
@fact_list[:virtualbox_revision] = output.match(/vboxRev_(\S+)/)&.captures&.first
|
39
39
|
@fact_list[:vmware_version] = extract_vmware_version(output)
|
40
|
-
@fact_list[:vendor] = output.match(/Vendor: (\S+)/)&.captures&.first
|
41
40
|
|
42
41
|
@fact_list[fact_name]
|
43
42
|
end
|