facter 4.1.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/facter/facts/aix/processors/cores.rb +16 -0
- data/lib/facter/facts/aix/processors/threads.rb +16 -0
- data/lib/facter/facts/linux/processors/cores.rb +16 -0
- data/lib/facter/facts/linux/processors/threads.rb +16 -0
- data/lib/facter/facts/macosx/os/macosx/version.rb +10 -2
- 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/processors/cores.rb +16 -0
- data/lib/facter/facts/solaris/processors/threads.rb +16 -0
- data/lib/facter/facts/windows/processors/cores.rb +17 -0
- data/lib/facter/facts/windows/processors/threads.rb +17 -0
- data/lib/facter/framework/core/fact_loaders/fact_loader.rb +4 -4
- data/lib/facter/framework/core/fact_manager.rb +13 -16
- data/lib/facter/models/fact_collection.rb +9 -10
- data/lib/facter/resolvers/aix/processors.rb +4 -0
- data/lib/facter/resolvers/macosx/processor.rb +16 -1
- data/lib/facter/resolvers/networking.rb +2 -1
- data/lib/facter/resolvers/processors_lscpu.rb +44 -0
- data/lib/facter/resolvers/solaris/processors.rb +7 -0
- data/lib/facter/resolvers/windows/processors.rb +41 -4
- data/lib/facter/util/linux/socket_parser.rb +1 -1
- data/lib/facter/version.rb +1 -1
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6ca2540a7ccad083604f2a0a1142cd0e870714dae635dc2fd8d60baa1b1bcbf
|
4
|
+
data.tar.gz: 25cec4e7c98a145d3950dd8c345ae04ee2bdc1b04ae78b08acb1674678c24d64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e43bf9233eca175b442b0cbda693efcae3f3b0f1e370b9b9ef5bca1c81a9450e4bfc3000d957463cbf49900abc6bf9769ba9664cc6750c17f58ad8abd4cf9730
|
7
|
+
data.tar.gz: 47c5a45dd7dfc505cda3d71634258ed7c7ca13e24ee6858219d89480f9b260e278cd8b602a59501a24ec61a7fcb62f1b929330cc5c4b54d34b13718b818280d5
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Processors
|
6
|
+
class Cores
|
7
|
+
FACT_NAME = 'processors.cores'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Aix::Processors.resolve(:cores_per_socket)
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Processors
|
6
|
+
class Threads
|
7
|
+
FACT_NAME = 'processors.threads'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Aix::Processors.resolve(:threads_per_core)
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Linux
|
5
|
+
module Processors
|
6
|
+
class Cores
|
7
|
+
FACT_NAME = 'processors.cores'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Linux::Lscpu.resolve(:cores_per_socket)
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Linux
|
5
|
+
module Processors
|
6
|
+
class Threads
|
7
|
+
FACT_NAME = 'processors.threads'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Linux::Lscpu.resolve(:threads_per_core)
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -10,14 +10,22 @@ module Facts
|
|
10
10
|
|
11
11
|
def call_the_resolver
|
12
12
|
fact_value = Facter::Resolvers::SwVers.resolve(:productversion)
|
13
|
-
|
14
|
-
ver = { 'full' => fact_value, 'major' => "#{versions[0]}.#{versions[1]}", 'minor' => versions[-1] }
|
13
|
+
ver = version_hash(fact_value)
|
15
14
|
|
16
15
|
[Facter::ResolvedFact.new(FACT_NAME, ver),
|
17
16
|
Facter::ResolvedFact.new(ALIASES[0], fact_value, :legacy),
|
18
17
|
Facter::ResolvedFact.new(ALIASES[1], ver['major'], :legacy),
|
19
18
|
Facter::ResolvedFact.new(ALIASES[2], ver['minor'], :legacy)]
|
20
19
|
end
|
20
|
+
|
21
|
+
def version_hash(fact_value)
|
22
|
+
versions = fact_value.split('.')
|
23
|
+
if versions[0] == '10'
|
24
|
+
{ 'full' => fact_value, 'major' => "#{versions[0]}.#{versions[1]}", 'minor' => versions[-1] }
|
25
|
+
else
|
26
|
+
{ 'full' => fact_value, 'major' => versions[0], 'minor' => "#{versions[1]}.#{versions[-1]}" }
|
27
|
+
end
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Macosx
|
5
|
+
module Processors
|
6
|
+
class Cores
|
7
|
+
FACT_NAME = 'processors.cores'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Macosx::Processors.resolve(:cores_per_socket)
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Macosx
|
5
|
+
module Processors
|
6
|
+
class Threads
|
7
|
+
FACT_NAME = 'processors.threads'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Macosx::Processors.resolve(:threads_per_core)
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Solaris
|
5
|
+
module Processors
|
6
|
+
class Cores
|
7
|
+
FACT_NAME = 'processors.cores'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Solaris::Processors.resolve(:cores_per_socket)
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Solaris
|
5
|
+
module Processors
|
6
|
+
class Threads
|
7
|
+
FACT_NAME = 'processors.threads'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Solaris::Processors.resolve(:threads_per_core)
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Windows
|
5
|
+
module Processors
|
6
|
+
class Cores
|
7
|
+
FACT_NAME = 'processors.cores'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Processors.resolve(:cores_per_socket)
|
11
|
+
|
12
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Windows
|
5
|
+
module Processors
|
6
|
+
class Threads
|
7
|
+
FACT_NAME = 'processors.threads'
|
8
|
+
|
9
|
+
def call_the_resolver
|
10
|
+
fact_value = Facter::Resolvers::Processors.resolve(:threads_per_core)
|
11
|
+
|
12
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -18,8 +18,8 @@ module Facter
|
|
18
18
|
@external_fact_loader ||= ExternalFactLoader.new
|
19
19
|
end
|
20
20
|
|
21
|
-
def load(options)
|
22
|
-
@internal_facts = load_internal_facts(options)
|
21
|
+
def load(user_query, options)
|
22
|
+
@internal_facts = load_internal_facts(user_query, options)
|
23
23
|
@custom_facts = load_custom_facts(options)
|
24
24
|
@external_facts = load_external_facts(options)
|
25
25
|
|
@@ -28,10 +28,10 @@ module Facter
|
|
28
28
|
@facts = @internal_facts + @external_facts + @custom_facts
|
29
29
|
end
|
30
30
|
|
31
|
-
def load_internal_facts(options)
|
31
|
+
def load_internal_facts(user_query, options)
|
32
32
|
@log.debug('Loading internal facts')
|
33
33
|
internal_facts = []
|
34
|
-
if
|
34
|
+
if user_query || options[:show_legacy]
|
35
35
|
# if we have a user query, then we must search in core facts and legacy facts
|
36
36
|
@log.debug('Loading all internal facts')
|
37
37
|
internal_facts = @internal_loader.facts
|
@@ -16,7 +16,7 @@ module Facter
|
|
16
16
|
@options[:user_query] = user_query
|
17
17
|
cache_manager = Facter::CacheManager.new
|
18
18
|
|
19
|
-
searched_facts = QueryParser.parse(user_query, @fact_loader.load(@options))
|
19
|
+
searched_facts = QueryParser.parse(user_query, @fact_loader.load(user_query, @options))
|
20
20
|
|
21
21
|
searched_facts, cached_facts = cache_manager.resolve_facts(searched_facts)
|
22
22
|
internal_facts = @internal_fact_mgr.resolve_facts(searched_facts)
|
@@ -45,11 +45,11 @@ module Facter
|
|
45
45
|
|
46
46
|
@cache_manager = Facter::CacheManager.new
|
47
47
|
|
48
|
-
custom_facts = custom_fact_by_filename || []
|
49
|
-
core_and_external_facts = core_or_external_fact || []
|
48
|
+
custom_facts = custom_fact_by_filename(user_query) || []
|
49
|
+
core_and_external_facts = core_or_external_fact(user_query) || []
|
50
50
|
resolved_facts = core_and_external_facts + custom_facts
|
51
51
|
|
52
|
-
resolved_facts = all_custom_facts if resolved_facts.empty?
|
52
|
+
resolved_facts = all_custom_facts(user_query) if resolved_facts.empty?
|
53
53
|
|
54
54
|
@cache_manager.cache_facts(resolved_facts)
|
55
55
|
|
@@ -65,7 +65,7 @@ module Facter
|
|
65
65
|
private
|
66
66
|
|
67
67
|
def core_fact(user_query, options)
|
68
|
-
loaded_facts_hash = @fact_loader.load_internal_facts(options)
|
68
|
+
loaded_facts_hash = @fact_loader.load_internal_facts(user_query, options)
|
69
69
|
|
70
70
|
searched_facts = QueryParser.parse(user_query, loaded_facts_hash)
|
71
71
|
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
@@ -78,14 +78,13 @@ module Facter
|
|
78
78
|
resolved_facts
|
79
79
|
end
|
80
80
|
|
81
|
-
def custom_fact_by_filename
|
82
|
-
user_query = @options[:user_query]
|
81
|
+
def custom_fact_by_filename(user_query)
|
83
82
|
@log.debug("Searching fact: #{user_query} in file: #{user_query}.rb")
|
84
83
|
|
85
84
|
custom_fact = @fact_loader.load_custom_fact(@options, user_query)
|
86
85
|
return unless custom_fact.any?
|
87
86
|
|
88
|
-
searched_facts = parse_user_query(custom_fact,
|
87
|
+
searched_facts = parse_user_query(custom_fact, user_query)
|
89
88
|
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
90
89
|
|
91
90
|
resolved_facts = @external_fact_mgr.resolve_facts(searched_facts)
|
@@ -93,13 +92,12 @@ module Facter
|
|
93
92
|
resolved_facts if resolved_facts.any?
|
94
93
|
end
|
95
94
|
|
96
|
-
def core_or_external_fact
|
97
|
-
user_query = @options[:user_query]
|
95
|
+
def core_or_external_fact(user_query)
|
98
96
|
@log.debug("Searching fact: #{user_query} in core facts and external facts")
|
99
97
|
|
100
98
|
core_facts = core_fact([user_query], @options)
|
101
99
|
external_facts = @fact_loader.load_external_facts(@options)
|
102
|
-
searched_facts = parse_user_query(external_facts,
|
100
|
+
searched_facts = parse_user_query(external_facts, user_query)
|
103
101
|
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
104
102
|
|
105
103
|
resolved_facts = @external_fact_mgr.resolve_facts(searched_facts)
|
@@ -109,20 +107,19 @@ module Facter
|
|
109
107
|
resolved_facts unless resolved_facts.map(&:value).compact.empty?
|
110
108
|
end
|
111
109
|
|
112
|
-
def all_custom_facts
|
113
|
-
user_query = @options[:user_query]
|
110
|
+
def all_custom_facts(user_query)
|
114
111
|
@log.debug("Searching fact: #{user_query} in all custom facts")
|
115
112
|
|
116
113
|
custom_facts = @fact_loader.load_custom_facts(@options)
|
117
|
-
searched_facts = parse_user_query(custom_facts,
|
114
|
+
searched_facts = parse_user_query(custom_facts, user_query)
|
118
115
|
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
119
116
|
|
120
117
|
resolved_facts = @external_fact_mgr.resolve_facts(searched_facts)
|
121
118
|
resolved_facts.concat(cached_facts)
|
122
119
|
end
|
123
120
|
|
124
|
-
def parse_user_query(loaded_facts,
|
125
|
-
user_query = Array(
|
121
|
+
def parse_user_query(loaded_facts, user_query)
|
122
|
+
user_query = Array(user_query)
|
126
123
|
QueryParser.parse(user_query, loaded_facts)
|
127
124
|
end
|
128
125
|
|
@@ -22,19 +22,18 @@ module Facter
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def dig_fact(user_query)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# An incorrect user query (e.g. mountpoints./.available.asd) can cause
|
29
|
-
# Facter to call dig on a string, which raises a type error.
|
30
|
-
# If this happens, we assume the query is wrong and silently continue.
|
31
|
-
ensure
|
32
|
-
@log.debug("Fact \"#{user_query}\" does not exist") unless fact
|
33
|
-
fact
|
25
|
+
value(user_query)
|
26
|
+
rescue KeyError
|
27
|
+
nil
|
34
28
|
end
|
35
29
|
|
36
30
|
def value(user_query)
|
37
|
-
|
31
|
+
fetch(user_query) do
|
32
|
+
split_user_query = Facter::Utils.split_user_query(user_query)
|
33
|
+
split_user_query.reduce(self) do |memo, key|
|
34
|
+
memo.fetch(key) { memo.fetch(key.to_s) } if memo.is_a?(Hash) || memo.is_a?(Array)
|
35
|
+
end
|
36
|
+
end
|
38
37
|
end
|
39
38
|
|
40
39
|
def bury(*args)
|
@@ -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
|
|
@@ -9,12 +9,17 @@ module Facter
|
|
9
9
|
ITEMS = { logical_count: 'hw.logicalcpu_max',
|
10
10
|
physical_count: 'hw.physicalcpu_max',
|
11
11
|
brand: 'machdep.cpu.brand_string',
|
12
|
-
speed: 'hw.cpufrequency_max'
|
12
|
+
speed: 'hw.cpufrequency_max',
|
13
|
+
cores_per_socket: 'machdep.cpu.core_count',
|
14
|
+
threads_per_core: 'machdep.cpu.thread_count' }.freeze
|
15
|
+
|
13
16
|
class << self
|
14
17
|
# :logicalcount
|
15
18
|
# :models
|
16
19
|
# :physicalcount
|
17
20
|
# :speed
|
21
|
+
# :cores_per_socket
|
22
|
+
# :threads_per_core
|
18
23
|
|
19
24
|
private
|
20
25
|
|
@@ -33,6 +38,8 @@ module Facter
|
|
33
38
|
build_physical_count(processors_data[1])
|
34
39
|
build_models(processors_data[2])
|
35
40
|
build_speed(processors_data[3])
|
41
|
+
build_cores_per_socket(processors_data[4])
|
42
|
+
build_threads_per_core(processors_data[5], processors_data[4])
|
36
43
|
end
|
37
44
|
|
38
45
|
def build_logical_count(count)
|
@@ -51,6 +58,14 @@ module Facter
|
|
51
58
|
def build_speed(value)
|
52
59
|
@fact_list[:speed] = value.split(': ')[1].to_i
|
53
60
|
end
|
61
|
+
|
62
|
+
def build_cores_per_socket(count)
|
63
|
+
@fact_list[:cores_per_socket] = count.split(': ')[1].to_i
|
64
|
+
end
|
65
|
+
|
66
|
+
def build_threads_per_core(number_of_threads, number_of_cores)
|
67
|
+
@fact_list[:threads_per_core] = number_of_threads.split(': ')[1].to_i / number_of_cores.split(': ')[1].to_i
|
68
|
+
end
|
54
69
|
end
|
55
70
|
end
|
56
71
|
end
|
@@ -63,7 +63,8 @@ module Facter
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def extract_mac(raw_data, parsed_interface_data)
|
66
|
-
mac = raw_data.match(/(?:ether|lladdr)\s+(
|
66
|
+
mac = raw_data.match(/(?:ether|lladdr)\s+((?:\w?\w:){5}\w?\w)|(?:infiniband)\s+((?:\w?\w:){19}\w?\w)/)
|
67
|
+
&.captures&.compact&.first
|
67
68
|
parsed_interface_data[:mac] = mac unless mac.nil?
|
68
69
|
end
|
69
70
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facter
|
4
|
+
module Resolvers
|
5
|
+
module Linux
|
6
|
+
class Lscpu < BaseResolver
|
7
|
+
init_resolver
|
8
|
+
|
9
|
+
ITEMS = { threads_per_core: "-e 'Thread(s)'",
|
10
|
+
cores_per_socket: "-e 'Core(s)'" }.freeze
|
11
|
+
|
12
|
+
class << self
|
13
|
+
#:cores_per_socket
|
14
|
+
#:threads_per_core
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def post_resolve(fact_name, _options)
|
19
|
+
@fact_list.fetch(fact_name) { read_cpuinfo(fact_name) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def read_cpuinfo(fact_name)
|
23
|
+
lscpu_output = Facter::Core::Execution.execute("lscpu | grep #{ITEMS.values.join(' ')}", logger: log)
|
24
|
+
build_fact_list(lscpu_output.split("\n"))
|
25
|
+
@fact_list[fact_name]
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_fact_list(processors_data)
|
29
|
+
build_threads_per_core(processors_data[0])
|
30
|
+
build_cores_per_socket(processors_data[1])
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_threads_per_core(index)
|
34
|
+
@fact_list[:threads_per_core] = index.split(': ')[1].to_i
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_cores_per_socket(index)
|
38
|
+
@fact_list[:cores_per_socket] = index.split(': ')[1].to_i
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -28,6 +28,13 @@ module Facter
|
|
28
28
|
@fact_list[:physical_count] = output.scan(/chip_id .*/).uniq.size
|
29
29
|
@fact_list[:speed] = output.scan(/current_clock_Hz .*/).first.gsub(/[a-zA-z\s]+/, '').to_i
|
30
30
|
@fact_list[:models] = output.scan(/brand .*/).map { |elem| elem.gsub(/brand(\s+)/, '') }
|
31
|
+
calculate_threads_cores(output)
|
32
|
+
end
|
33
|
+
|
34
|
+
def calculate_threads_cores(output)
|
35
|
+
@fact_list[:core_count] = output.scan(/\score_id .*/).uniq.size
|
36
|
+
@fact_list[:threads_per_core] = @fact_list[:logical_count] / @fact_list[:core_count]
|
37
|
+
@fact_list[:cores_per_socket] = @fact_list[:core_count] / @fact_list[:physical_count]
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
@@ -19,14 +19,19 @@ module Facter
|
|
19
19
|
|
20
20
|
def read_fact_from_win32_processor(fact_name)
|
21
21
|
win = Facter::Util::Windows::Win32Ole.new
|
22
|
-
|
22
|
+
query_string = 'SELECT Name,'\
|
23
|
+
'Architecture,'\
|
24
|
+
'NumberOfLogicalProcessors,'\
|
25
|
+
'NumberOfCores FROM Win32_Processor'
|
26
|
+
proc = win.exec_query(query_string)
|
23
27
|
unless proc
|
24
28
|
log.debug 'WMI query returned no results'\
|
25
29
|
'for Win32_Processor with values Name, Architecture and NumberOfLogicalProcessors.'
|
26
30
|
return
|
27
31
|
end
|
28
32
|
result = iterate_proc(proc)
|
29
|
-
|
33
|
+
cores_threads = calculate_cores_threads(proc, result)
|
34
|
+
build_fact_list(result, cores_threads)
|
30
35
|
@fact_list[fact_name]
|
31
36
|
end
|
32
37
|
|
@@ -40,7 +45,29 @@ module Facter
|
|
40
45
|
isa ||= find_isa(proc.Architecture)
|
41
46
|
end
|
42
47
|
|
43
|
-
{ models: models,
|
48
|
+
{ models: models,
|
49
|
+
isa: isa,
|
50
|
+
logical_count: logical_processors_count(logical_count, models.count) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def calculate_cores_threads(result_proc, data_proc)
|
54
|
+
cores = 0
|
55
|
+
threads_per_core = 0
|
56
|
+
result_proc.each do |proc|
|
57
|
+
cores = proc.NumberOfCores
|
58
|
+
threads_per_core = if check_hyperthreading(data_proc[:logical_count], cores) ||
|
59
|
+
cores > data_proc[:logical_count]
|
60
|
+
1
|
61
|
+
else
|
62
|
+
data_proc[:logical_count] / (cores * data_proc[:models].size)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
{ cores_per_socket: cores,
|
66
|
+
threads_per_core: threads_per_core }
|
67
|
+
end
|
68
|
+
|
69
|
+
def check_hyperthreading(cores, logical_processors)
|
70
|
+
cores == logical_processors
|
44
71
|
end
|
45
72
|
|
46
73
|
def find_isa(arch)
|
@@ -52,11 +79,21 @@ module Facter
|
|
52
79
|
log.debug 'Unable to determine processor type: unknown architecture'
|
53
80
|
end
|
54
81
|
|
55
|
-
def
|
82
|
+
def logical_processors_count(logical_count, models_count)
|
83
|
+
if logical_count.zero?
|
84
|
+
models_count
|
85
|
+
else
|
86
|
+
logical_count
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def build_fact_list(result, cores_threads)
|
56
91
|
@fact_list[:count] = result[:logical_count]
|
57
92
|
@fact_list[:isa] = result[:isa]
|
58
93
|
@fact_list[:models] = result[:models]
|
59
94
|
@fact_list[:physicalcount] = result[:models].size
|
95
|
+
@fact_list[:cores_per_socket] = cores_threads[:cores_per_socket]
|
96
|
+
@fact_list[:threads_per_core] = cores_threads[:threads_per_core]
|
60
97
|
end
|
61
98
|
end
|
62
99
|
end
|
@@ -36,7 +36,7 @@ module Facter
|
|
36
36
|
def search_for_mac(ifaddr)
|
37
37
|
mac = mac_from_bonded_interface(ifaddr.name)
|
38
38
|
mac ||= mac_from(ifaddr)
|
39
|
-
mac if !mac.nil? && mac != '00:00:00:00:00:00' && mac =~ /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/
|
39
|
+
mac if !mac.nil? && mac != '00:00:00:00:00:00' && mac =~ /^([0-9A-Fa-f]{2}[:-]){5,19}([0-9A-Fa-f]{2})$/
|
40
40
|
end
|
41
41
|
|
42
42
|
def mac_from_bonded_interface(interface_name)
|
data/lib/facter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -260,10 +260,12 @@ files:
|
|
260
260
|
- lib/facter/facts/aix/partitions.rb
|
261
261
|
- lib/facter/facts/aix/path.rb
|
262
262
|
- lib/facter/facts/aix/processor.rb
|
263
|
+
- lib/facter/facts/aix/processors/cores.rb
|
263
264
|
- lib/facter/facts/aix/processors/count.rb
|
264
265
|
- lib/facter/facts/aix/processors/isa.rb
|
265
266
|
- lib/facter/facts/aix/processors/models.rb
|
266
267
|
- lib/facter/facts/aix/processors/speed.rb
|
268
|
+
- lib/facter/facts/aix/processors/threads.rb
|
267
269
|
- lib/facter/facts/aix/ruby/platform.rb
|
268
270
|
- lib/facter/facts/aix/ruby/sitedir.rb
|
269
271
|
- lib/facter/facts/aix/ruby/version.rb
|
@@ -489,11 +491,13 @@ files:
|
|
489
491
|
- lib/facter/facts/linux/partitions.rb
|
490
492
|
- lib/facter/facts/linux/path.rb
|
491
493
|
- lib/facter/facts/linux/processor.rb
|
494
|
+
- lib/facter/facts/linux/processors/cores.rb
|
492
495
|
- lib/facter/facts/linux/processors/count.rb
|
493
496
|
- lib/facter/facts/linux/processors/isa.rb
|
494
497
|
- lib/facter/facts/linux/processors/models.rb
|
495
498
|
- lib/facter/facts/linux/processors/physicalcount.rb
|
496
499
|
- lib/facter/facts/linux/processors/speed.rb
|
500
|
+
- lib/facter/facts/linux/processors/threads.rb
|
497
501
|
- lib/facter/facts/linux/ruby/platform.rb
|
498
502
|
- lib/facter/facts/linux/ruby/sitedir.rb
|
499
503
|
- lib/facter/facts/linux/ruby/version.rb
|
@@ -576,11 +580,13 @@ files:
|
|
576
580
|
- lib/facter/facts/macosx/os/name.rb
|
577
581
|
- lib/facter/facts/macosx/os/release.rb
|
578
582
|
- lib/facter/facts/macosx/path.rb
|
583
|
+
- lib/facter/facts/macosx/processors/cores.rb
|
579
584
|
- lib/facter/facts/macosx/processors/count.rb
|
580
585
|
- lib/facter/facts/macosx/processors/isa.rb
|
581
586
|
- lib/facter/facts/macosx/processors/models.rb
|
582
587
|
- lib/facter/facts/macosx/processors/physicalcount.rb
|
583
588
|
- lib/facter/facts/macosx/processors/speed.rb
|
589
|
+
- lib/facter/facts/macosx/processors/threads.rb
|
584
590
|
- lib/facter/facts/macosx/ruby/platform.rb
|
585
591
|
- lib/facter/facts/macosx/ruby/sitedir.rb
|
586
592
|
- lib/facter/facts/macosx/ruby/version.rb
|
@@ -716,11 +722,13 @@ files:
|
|
716
722
|
- lib/facter/facts/solaris/os/name.rb
|
717
723
|
- lib/facter/facts/solaris/os/release.rb
|
718
724
|
- lib/facter/facts/solaris/path.rb
|
725
|
+
- lib/facter/facts/solaris/processors/cores.rb
|
719
726
|
- lib/facter/facts/solaris/processors/count.rb
|
720
727
|
- lib/facter/facts/solaris/processors/isa.rb
|
721
728
|
- lib/facter/facts/solaris/processors/models.rb
|
722
729
|
- lib/facter/facts/solaris/processors/physicalcount.rb
|
723
730
|
- lib/facter/facts/solaris/processors/speed.rb
|
731
|
+
- lib/facter/facts/solaris/processors/threads.rb
|
724
732
|
- lib/facter/facts/solaris/ruby/platform.rb
|
725
733
|
- lib/facter/facts/solaris/ruby/sitedir.rb
|
726
734
|
- lib/facter/facts/solaris/ruby/version.rb
|
@@ -810,10 +818,12 @@ files:
|
|
810
818
|
- lib/facter/facts/windows/os/windows/system32.rb
|
811
819
|
- lib/facter/facts/windows/path.rb
|
812
820
|
- lib/facter/facts/windows/processor.rb
|
821
|
+
- lib/facter/facts/windows/processors/cores.rb
|
813
822
|
- lib/facter/facts/windows/processors/count.rb
|
814
823
|
- lib/facter/facts/windows/processors/isa.rb
|
815
824
|
- lib/facter/facts/windows/processors/models.rb
|
816
825
|
- lib/facter/facts/windows/processors/physicalcount.rb
|
826
|
+
- lib/facter/facts/windows/processors/threads.rb
|
817
827
|
- lib/facter/facts/windows/ruby/platform.rb
|
818
828
|
- lib/facter/facts/windows/ruby/sitedir.rb
|
819
829
|
- lib/facter/facts/windows/ruby/version.rb
|
@@ -933,6 +943,7 @@ files:
|
|
933
943
|
- lib/facter/resolvers/partitions.rb
|
934
944
|
- lib/facter/resolvers/path.rb
|
935
945
|
- lib/facter/resolvers/processors.rb
|
946
|
+
- lib/facter/resolvers/processors_lscpu.rb
|
936
947
|
- lib/facter/resolvers/redhat_release.rb
|
937
948
|
- lib/facter/resolvers/release_from_first_line.rb
|
938
949
|
- lib/facter/resolvers/ruby.rb
|