facter 4.2.3 → 4.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 353d24b45ac4083ff9a2f7de05702a93e8701487cc6020de93ed974d527e7f53
4
- data.tar.gz: c02329462e40922777fac34fab775ea1d68b884b7d4d8f8e99544bdb737f57e8
3
+ metadata.gz: ee51134133739cd64ee9fb160993ddd8ec683af8a2893aa98744709398d7ffce
4
+ data.tar.gz: d5bf29fc2338094cc267949431222af0cfa186f25998413dc6d50d14af5aafaa
5
5
  SHA512:
6
- metadata.gz: 1ccd6eb8e93836cf558c7ed12c943d8c30d14bad521f2de821b014ceb30b3d1f4fc92cc3c54690ff853b5d62dd4c3521293127f87d08fe6525d5ff2f317e3637
7
- data.tar.gz: d4a75033160dac87a2244855c7a2ff8d34fb733b527cc8ffd45279c3e2821b0860f3b1982ab1e0e4182c9c75cf45129ebe0c68738eeb605b9e435b5d460da309
6
+ metadata.gz: 71a0943be14cca0cfc2a1cde31f10deae26fad0c2cc845dec8ba981e86c33b97278adc424a92b301b868fddb6213024431fec51a44f090913de58937865906ed
7
+ data.tar.gz: 13fbe6fc74dccb348d67c274861bf89fce18d4e792801546b63c4b1f260c270afc338fddf355166b27e1bef5c5484541655c70e4c8e7bfcc39468d94ae247d8e
@@ -141,13 +141,13 @@ module LegacyFacter
141
141
  # Skip anything that doesn't match our regex.
142
142
  next unless name =~ /^facter_?(\w+)$/i
143
143
 
144
- env_name = Regexp.last_match(1)
144
+ env_name = Regexp.last_match(1).downcase
145
145
 
146
146
  # If a fact name was specified, skip anything that doesn't
147
147
  # match it.
148
148
  next if fact && (env_name != fact)
149
149
 
150
- LegacyFacter.add(Regexp.last_match(1), fact_type: :external, is_env: true) do
150
+ LegacyFacter.add(env_name, fact_type: :external, is_env: true) do
151
151
  has_weight 1_000_000
152
152
  setcode { value }
153
153
  end
@@ -34,7 +34,7 @@ module Facter
34
34
 
35
35
  return if stdout.empty?
36
36
 
37
- info_size = Facter::Util::Aix::InfoExtractor.extract(stdout, /PP SIZE:|TOTAL PPs:|FREE PPs:|PV STATE:/)
37
+ info_size = Facter::Util::Aix::InfoExtractor.extract(stdout, :lspv)
38
38
 
39
39
  return unless info_size['PV STATE']
40
40
 
@@ -19,7 +19,7 @@ module Facter
19
19
  @fact_list[:mountpoints] = {}
20
20
  output = Facter::Core::Execution.execute('mount', logger: log)
21
21
  output.split("\n").map do |line|
22
- next if line =~ /node|---|procfs|ahafs/
22
+ next if line =~ /\s+node\s+|---|procfs|ahafs/
23
23
 
24
24
  elem = line.split("\s")
25
25
 
@@ -40,7 +40,7 @@ module Facter
40
40
 
41
41
  return if stdout.empty?
42
42
 
43
- info_hash = Facter::Util::Aix::InfoExtractor.extract(stdout, /PPs:|PP SIZE|TYPE:|LABEL:|MOUNT/)
43
+ info_hash = Facter::Util::Aix::InfoExtractor.extract(stdout, :lslv)
44
44
  size_bytes = compute_size(info_hash)
45
45
 
46
46
  part_info = {
@@ -29,42 +29,42 @@ module Facter
29
29
 
30
30
  def read_processor_data(fact_name)
31
31
  output = Facter::Core::Execution.execute("sysctl #{ITEMS.values.join(' ')}", logger: log)
32
- build_fact_list(output.split("\n"))
32
+ processors_hash = Hash[*output.split("\n").collect { |v| [v.split(': ')[0], v.split(': ')[1]] }.flatten]
33
+ build_fact_list(processors_hash)
33
34
  @fact_list[fact_name]
34
35
  end
35
36
 
36
- def build_fact_list(processors_data)
37
- build_logical_count(processors_data[0])
38
- build_physical_count(processors_data[1])
39
- build_models(processors_data[2])
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])
37
+ def build_fact_list(hash)
38
+ build_logical_count(hash)
39
+ build_physical_count(hash)
40
+ build_models(hash)
41
+ build_speed(hash)
42
+ build_cores_per_socket(hash)
43
+ build_threads_per_core(hash)
43
44
  end
44
45
 
45
- def build_logical_count(count)
46
- @fact_list[:logicalcount] = count.split(': ')[1].to_i
46
+ def build_logical_count(hash)
47
+ @fact_list[:logicalcount] = hash[ITEMS[:logical_count]].to_i
47
48
  end
48
49
 
49
- def build_physical_count(count)
50
- @fact_list[:physicalcount] = count.split(': ')[1].to_i
50
+ def build_physical_count(hash)
51
+ @fact_list[:physicalcount] = hash[ITEMS[:physical_count]].to_i
51
52
  end
52
53
 
53
- def build_models(model)
54
- brand = model.split(': ').fetch(1)
55
- @fact_list[:models] = Array.new(@fact_list[:logicalcount].to_i, brand)
54
+ def build_models(hash)
55
+ @fact_list[:models] = Array.new(@fact_list[:logicalcount].to_i, hash[ITEMS[:brand]])
56
56
  end
57
57
 
58
- def build_speed(value)
59
- @fact_list[:speed] = value.split(': ')[1].to_i
58
+ def build_speed(hash)
59
+ @fact_list[:speed] = hash[ITEMS[:speed]].to_i
60
60
  end
61
61
 
62
- def build_cores_per_socket(count)
63
- @fact_list[:cores_per_socket] = count.split(': ')[1].to_i
62
+ def build_cores_per_socket(hash)
63
+ @fact_list[:cores_per_socket] = hash[ITEMS[:cores_per_socket]].to_i
64
64
  end
65
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
66
+ def build_threads_per_core(hash)
67
+ @fact_list[:threads_per_core] = hash[ITEMS[:threads_per_core]].to_i / hash[ITEMS[:cores_per_socket]].to_i
68
68
  end
69
69
  end
70
70
  end
@@ -6,17 +6,68 @@ module Facter
6
6
  module InfoExtractor
7
7
  MEGABYTES_EXPONENT = 1024**2
8
8
  GIGABYTES_EXPONENT = 1024**3
9
+ PROPERTIES = {
10
+ lslv: [
11
+ 'LOGICAL VOLUME:',
12
+ 'VOLUME GROUP:',
13
+ 'LV IDENTIFIER:',
14
+ 'PERMISSION:',
15
+ 'VG STATE:',
16
+ 'LV STATE:',
17
+ 'TYPE:',
18
+ 'WRITE VERIFY:',
19
+ 'MAX LPs:',
20
+ 'PP SIZE:',
21
+ 'COPIES:',
22
+ 'SCHED POLICY:',
23
+ 'LPs:',
24
+ 'PPs:',
25
+ 'STALE PPs:',
26
+ 'BB POLICY:',
27
+ 'INTER-POLICY:',
28
+ 'RELOCATABLE:',
29
+ 'INTRA-POLICY:',
30
+ 'UPPER BOUND:',
31
+ 'MOUNT POINT:',
32
+ 'LABEL:',
33
+ 'MIRROR WRITE CONSISTENCY:',
34
+ 'EACH LP COPY ON A SEPARATE PV ?:',
35
+ 'Serialize IO ?:'
36
+ ],
37
+ lspv: [
38
+ 'PHYSICAL VOLUME:',
39
+ 'VOLUME GROUP:',
40
+ 'PV IDENTIFIER:',
41
+ 'VG IDENTIFIER',
42
+ 'PV STATE:',
43
+ 'STALE PARTITIONS:',
44
+ 'ALLOCATABLE:',
45
+ 'PP SIZE:',
46
+ 'LOGICAL VOLUMES:',
47
+ 'TOTAL PPs:',
48
+ 'VG DESCRIPTORS:',
49
+ 'FREE PPs:',
50
+ 'HOT SPARE:',
51
+ 'USED PPs:',
52
+ 'MAX REQUEST:',
53
+ 'FREE DISTRIBUTION:',
54
+ 'USED DISTRIBUTION:',
55
+ 'MIRROR POOL:'
56
+ ]
57
+ }.freeze
9
58
 
10
- def self.extract(content, regex)
11
- content = content.each_line.map do |line|
12
- next unless regex =~ line
13
-
14
- line.split(/:\s*|\s{2,}/)
59
+ def self.extract(content, cmd)
60
+ property_hash = {}
61
+ properties = PROPERTIES[cmd]
62
+ properties.each do |property|
63
+ str = (properties - [property]).join('|')
64
+ matcher = content.match(/#{Regexp.escape(property)}([^\n]*?)(#{str}|\n|$)/s)
65
+ if matcher
66
+ value = matcher[1].strip
67
+ property_hash[property.split(':').first] = value
68
+ end
15
69
  end
16
-
17
- content.flatten!.reject!(&:nil?)
18
-
19
- Hash[*content]
70
+ property_hash
20
71
  end
21
72
  end
22
73
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Facter
4
- VERSION = '4.2.3' unless defined?(VERSION)
4
+ VERSION = '4.2.4' unless defined?(VERSION)
5
5
  end
data/lib/facter.rb CHANGED
@@ -390,7 +390,7 @@ module Facter
390
390
  #
391
391
  # @api public
392
392
  def value(user_query)
393
- user_query = user_query.to_s
393
+ user_query = user_query.to_s.downcase
394
394
  resolve_fact(user_query)
395
395
 
396
396
  @already_searched[user_query]&.value
@@ -407,7 +407,7 @@ module Facter
407
407
  #
408
408
  # @api public
409
409
  def fact(user_query)
410
- user_query = user_query.to_s
410
+ user_query = user_query.to_s.downcase
411
411
  resolve_fact(user_query)
412
412
 
413
413
  @already_searched[user_query]
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.2.3
4
+ version: 4.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -964,7 +964,7 @@ files:
964
964
  - lib/facter/resolvers/macosx/filesystems.rb
965
965
  - lib/facter/resolvers/macosx/load_averages.rb
966
966
  - lib/facter/resolvers/macosx/mountpoints.rb
967
- - lib/facter/resolvers/macosx/processor.rb
967
+ - lib/facter/resolvers/macosx/processors.rb
968
968
  - lib/facter/resolvers/macosx/swap_memory.rb
969
969
  - lib/facter/resolvers/macosx/system_memory.rb
970
970
  - lib/facter/resolvers/macosx/system_profiler.rb