facter 4.0.30 → 4.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/facter.rb +3 -4
- data/lib/facter/custom_facts/util/parser.rb +3 -3
- data/lib/facter/facts/aix/disks.rb +17 -0
- data/lib/facter/facts/aix/memory/swap/available.rb +22 -0
- data/lib/facter/facts/aix/memory/swap/available_bytes.rb +22 -0
- data/lib/facter/facts/aix/memory/swap/capacity.rb +20 -0
- data/lib/facter/facts/aix/memory/swap/total.rb +22 -0
- data/lib/facter/facts/aix/memory/swap/total_bytes.rb +22 -0
- data/lib/facter/facts/aix/memory/swap/used.rb +21 -0
- data/lib/facter/facts/aix/memory/swap/used_bytes.rb +19 -0
- data/lib/facter/facts/aix/memory/system/available.rb +22 -0
- data/lib/facter/facts/aix/memory/system/available_bytes.rb +22 -0
- data/lib/facter/facts/aix/memory/system/capacity.rb +20 -0
- data/lib/facter/facts/aix/memory/system/total.rb +22 -0
- data/lib/facter/facts/aix/memory/system/total_bytes.rb +22 -0
- data/lib/facter/facts/aix/memory/system/used.rb +21 -0
- data/lib/facter/facts/aix/memory/system/used_bytes.rb +19 -0
- data/lib/facter/facts/linux/hypervisors/vmware.rb +2 -1
- data/lib/facter/facts/macosx/system_profiler/hardware_uuid.rb +1 -1
- data/lib/facter/facts/macosx/system_profiler/l2_cache_per_core.rb +1 -1
- data/lib/facter/facts/macosx/system_profiler/memory.rb +1 -1
- data/lib/facter/facts/macosx/system_profiler/processor_name.rb +1 -1
- data/lib/facter/facts/macosx/system_profiler/processors.rb +1 -1
- data/lib/facter/framework/cli/cli.rb +19 -2
- data/lib/facter/framework/core/fact/internal/internal_fact_manager.rb +1 -1
- data/lib/facter/framework/core/fact_loaders/fact_loader.rb +2 -0
- data/lib/facter/framework/core/options.rb +1 -0
- data/lib/facter/framework/core/options/option_store.rb +3 -6
- data/lib/facter/framework/logging/logger.rb +13 -5
- data/lib/facter/resolvers/aix/disks.rb +63 -0
- data/lib/facter/resolvers/aix/memory.rb +65 -0
- data/lib/facter/resolvers/aix/partitions.rb +9 -20
- data/lib/facter/resolvers/aix/utils/info_extractor.rb +20 -0
- data/lib/facter/templates/man.erb +122 -0
- data/lib/facter/version.rb +1 -1
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58032c19dc544418cdd5bdc8598a48d6d8cc2b9c67f3ef3ac081fe98cf03ac6a
|
4
|
+
data.tar.gz: db8bd43f5f28c4c7ea30d67c2ecb02367d398b70c2096fa5ee5f0319c2473640
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52a387b13db0d8064f5cfc7e968b1b8c65843098071e04b662ee76a5c57bbdf5cbcbc669230a30544007fecc648645553496e4ccf000eba81cf7dbb0e6103d90
|
7
|
+
data.tar.gz: 61e0b00e59b79820c2ec91118c8bba3b3d692bc620807a29341e0cc2530565d574fd80648167547e55d556db145176ca78d126f2e8ff7f4093155c95534fe5a5
|
data/lib/facter.rb
CHANGED
@@ -13,7 +13,6 @@ module Facter
|
|
13
13
|
Options.init
|
14
14
|
Log.output(STDOUT)
|
15
15
|
@already_searched = {}
|
16
|
-
@trace = false
|
17
16
|
|
18
17
|
class << self
|
19
18
|
def clear_messages
|
@@ -196,7 +195,7 @@ module Facter
|
|
196
195
|
#
|
197
196
|
# @api public
|
198
197
|
def trace?
|
199
|
-
|
198
|
+
Options[:trace]
|
200
199
|
end
|
201
200
|
|
202
201
|
# Enable or disable trace
|
@@ -206,7 +205,7 @@ module Facter
|
|
206
205
|
#
|
207
206
|
# @api public
|
208
207
|
def trace(bool)
|
209
|
-
|
208
|
+
Options[:trace] = bool
|
210
209
|
end
|
211
210
|
|
212
211
|
# Gets the value for a fact. Returns `nil` if no such fact exists.
|
@@ -255,7 +254,7 @@ module Facter
|
|
255
254
|
elsif message
|
256
255
|
arr << message
|
257
256
|
end
|
258
|
-
if
|
257
|
+
if Options[:trace]
|
259
258
|
arr << 'backtrace:'
|
260
259
|
arr.concat(exception.backtrace)
|
261
260
|
end
|
@@ -56,7 +56,7 @@ module LegacyFacter
|
|
56
56
|
# wrapper.
|
57
57
|
def results
|
58
58
|
parse_results
|
59
|
-
rescue
|
59
|
+
rescue StandardError => e
|
60
60
|
Facter.log_exception(e, "Failed to handle #{filename} as #{self.class} facts: #{e.message}")
|
61
61
|
nil
|
62
62
|
end
|
@@ -68,8 +68,8 @@ module LegacyFacter
|
|
68
68
|
def parse_executable_output(output)
|
69
69
|
res = nil
|
70
70
|
begin
|
71
|
-
res = YAML.safe_load
|
72
|
-
rescue
|
71
|
+
res = YAML.safe_load(output, [Symbol, Time])
|
72
|
+
rescue StandardError => e
|
73
73
|
Facter.debug("Could not parse executable fact output as YAML or JSON (#{e.message})")
|
74
74
|
end
|
75
75
|
res = KeyValuePairOutputFormat.parse output unless res.is_a?(Hash)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
class Disks
|
6
|
+
FACT_NAME = 'disks'
|
7
|
+
|
8
|
+
def call_the_resolver
|
9
|
+
disks = Facter::Resolvers::Aix::Disks.resolve(:disks)
|
10
|
+
|
11
|
+
disks = disks&.empty? ? nil : disks
|
12
|
+
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, disks)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module Swap
|
7
|
+
class Available
|
8
|
+
FACT_NAME = 'memory.swap.available'
|
9
|
+
ALIASES = 'swapfree'
|
10
|
+
|
11
|
+
def call_the_resolver
|
12
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:swap)
|
13
|
+
if fact_value
|
14
|
+
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:available_bytes])
|
15
|
+
end
|
16
|
+
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module Swap
|
7
|
+
class AvailableBytes
|
8
|
+
FACT_NAME = 'memory.swap.available_bytes'
|
9
|
+
ALIASES = 'swapfree_mb'
|
10
|
+
|
11
|
+
def call_the_resolver
|
12
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:swap)
|
13
|
+
fact_value = fact_value[:available_bytes] if fact_value
|
14
|
+
|
15
|
+
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
|
16
|
+
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module Swap
|
7
|
+
class Capacity
|
8
|
+
FACT_NAME = 'memory.swap.capacity'
|
9
|
+
|
10
|
+
def call_the_resolver
|
11
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:swap)
|
12
|
+
fact_value = fact_value[:capacity] if fact_value
|
13
|
+
|
14
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module Swap
|
7
|
+
class Total
|
8
|
+
FACT_NAME = 'memory.swap.total'
|
9
|
+
ALIASES = 'swapsize'
|
10
|
+
|
11
|
+
def call_the_resolver
|
12
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:swap)
|
13
|
+
if fact_value
|
14
|
+
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:total_bytes])
|
15
|
+
end
|
16
|
+
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module Swap
|
7
|
+
class TotalBytes
|
8
|
+
FACT_NAME = 'memory.swap.total_bytes'
|
9
|
+
ALIASES = 'swapsize_mb'
|
10
|
+
|
11
|
+
def call_the_resolver
|
12
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:swap)
|
13
|
+
fact_value = fact_value[:total_bytes] if fact_value
|
14
|
+
|
15
|
+
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
|
16
|
+
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module Swap
|
7
|
+
class Used
|
8
|
+
FACT_NAME = 'memory.swap.used'
|
9
|
+
|
10
|
+
def call_the_resolver
|
11
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:swap)
|
12
|
+
if fact_value
|
13
|
+
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:used_bytes])
|
14
|
+
end
|
15
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module Swap
|
7
|
+
class UsedBytes
|
8
|
+
FACT_NAME = 'memory.swap.used_bytes'
|
9
|
+
|
10
|
+
def call_the_resolver
|
11
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:swap)
|
12
|
+
fact_value = fact_value[:used_bytes] if fact_value
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module System
|
7
|
+
class Available
|
8
|
+
FACT_NAME = 'memory.system.available'
|
9
|
+
ALIASES = 'memoryfree'
|
10
|
+
|
11
|
+
def call_the_resolver
|
12
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:system)
|
13
|
+
if fact_value
|
14
|
+
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:available_bytes])
|
15
|
+
end
|
16
|
+
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module System
|
7
|
+
class AvailableBytes
|
8
|
+
FACT_NAME = 'memory.system.available_bytes'
|
9
|
+
ALIASES = 'memoryfree_mb'
|
10
|
+
|
11
|
+
def call_the_resolver
|
12
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:system)
|
13
|
+
fact_value = fact_value[:available_bytes] if fact_value
|
14
|
+
|
15
|
+
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
|
16
|
+
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module System
|
7
|
+
class Capacity
|
8
|
+
FACT_NAME = 'memory.system.capacity'
|
9
|
+
|
10
|
+
def call_the_resolver
|
11
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:system)
|
12
|
+
fact_value = fact_value[:capacity] if fact_value
|
13
|
+
|
14
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module System
|
7
|
+
class Total
|
8
|
+
FACT_NAME = 'memory.system.total'
|
9
|
+
ALIASES = 'memorysize'
|
10
|
+
|
11
|
+
def call_the_resolver
|
12
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:system)
|
13
|
+
if fact_value
|
14
|
+
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:total_bytes])
|
15
|
+
end
|
16
|
+
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module System
|
7
|
+
class TotalBytes
|
8
|
+
FACT_NAME = 'memory.system.total_bytes'
|
9
|
+
ALIASES = 'memorysize_mb'
|
10
|
+
|
11
|
+
def call_the_resolver
|
12
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:system)
|
13
|
+
fact_value = fact_value[:total_bytes] if fact_value
|
14
|
+
|
15
|
+
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
|
16
|
+
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module System
|
7
|
+
class Used
|
8
|
+
FACT_NAME = 'memory.system.used'
|
9
|
+
|
10
|
+
def call_the_resolver
|
11
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:system)
|
12
|
+
if fact_value
|
13
|
+
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:used_bytes])
|
14
|
+
end
|
15
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
module Memory
|
6
|
+
module System
|
7
|
+
class UsedBytes
|
8
|
+
FACT_NAME = 'memory.system.used_bytes'
|
9
|
+
|
10
|
+
def call_the_resolver
|
11
|
+
fact_value = Facter::Resolvers::Aix::Memory.resolve(:system)
|
12
|
+
fact_value = fact_value[:used_bytes] if fact_value
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -15,7 +15,8 @@ module Facts
|
|
15
15
|
@log.debug('Vmware hypervisor detected')
|
16
16
|
fact_value = {}
|
17
17
|
|
18
|
-
|
18
|
+
version = Facter::Resolvers::DmiDecode.resolve(:vmware_version)
|
19
|
+
fact_value[:version] = version if version && !version.empty?
|
19
20
|
|
20
21
|
return Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
21
22
|
end
|
@@ -5,7 +5,7 @@ module Facts
|
|
5
5
|
module SystemProfiler
|
6
6
|
class HardwareUuid
|
7
7
|
FACT_NAME = 'system_profiler.hardware_uuid'
|
8
|
-
ALIASES = '
|
8
|
+
ALIASES = 'sp_platform_uuid'
|
9
9
|
|
10
10
|
def call_the_resolver
|
11
11
|
fact_value = Facter::Resolvers::Macosx::SystemProfiler.resolve(:hardware_uuid)
|
@@ -5,7 +5,7 @@ module Facts
|
|
5
5
|
module SystemProfiler
|
6
6
|
class L2CachePerCore
|
7
7
|
FACT_NAME = 'system_profiler.l2_cache_per_core'
|
8
|
-
ALIASES = '
|
8
|
+
ALIASES = 'sp_l2_cache_core'
|
9
9
|
|
10
10
|
def call_the_resolver
|
11
11
|
fact_value = Facter::Resolvers::Macosx::SystemProfiler.resolve(:l2_cache_per_core)
|
@@ -5,7 +5,7 @@ module Facts
|
|
5
5
|
module SystemProfiler
|
6
6
|
class ProcessorName
|
7
7
|
FACT_NAME = 'system_profiler.processor_name'
|
8
|
-
ALIASES = '
|
8
|
+
ALIASES = 'sp_cpu_type'
|
9
9
|
|
10
10
|
def call_the_resolver
|
11
11
|
fact_value = Facter::Resolvers::Macosx::SystemProfiler.resolve(:processor_name)
|
@@ -5,7 +5,7 @@ module Facts
|
|
5
5
|
module SystemProfiler
|
6
6
|
class Processors
|
7
7
|
FACT_NAME = 'system_profiler.processors'
|
8
|
-
ALIASES = '
|
8
|
+
ALIASES = 'sp_packages'
|
9
9
|
|
10
10
|
def call_the_resolver
|
11
11
|
fact_value = Facter::Resolvers::Macosx::SystemProfiler.resolve(:number_of_processors)
|
@@ -35,6 +35,11 @@ module Facter
|
|
35
35
|
type: :boolean,
|
36
36
|
desc: 'Print this help message.'
|
37
37
|
|
38
|
+
class_option :man,
|
39
|
+
hide: true,
|
40
|
+
type: :boolean,
|
41
|
+
desc: 'Display manual.'
|
42
|
+
|
38
43
|
class_option :hocon,
|
39
44
|
type: :boolean,
|
40
45
|
desc: 'Output in Hocon format.'
|
@@ -103,6 +108,18 @@ module Facter
|
|
103
108
|
aliases: '-p',
|
104
109
|
desc: 'Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts.'
|
105
110
|
|
111
|
+
desc '--man', 'Manual', hide: true
|
112
|
+
map ['--man'] => :man
|
113
|
+
def man(*args)
|
114
|
+
require 'erb'
|
115
|
+
negate_options = %w[block cache custom_facts external_facts]
|
116
|
+
|
117
|
+
template = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'man.erb')
|
118
|
+
erb = ERB.new(File.read(template), nil, '-')
|
119
|
+
erb.filename = template
|
120
|
+
puts erb.result(binding)
|
121
|
+
end
|
122
|
+
|
106
123
|
desc 'query', 'Default method', hide: true
|
107
124
|
desc '[options] [query] [query] [...]', ''
|
108
125
|
def query(*args)
|
@@ -119,13 +136,13 @@ module Facter
|
|
119
136
|
puts Facter::VERSION
|
120
137
|
end
|
121
138
|
|
122
|
-
desc '--list-block-groups', 'List block groups'
|
139
|
+
desc '--list-block-groups', 'List block groups', hide: true
|
123
140
|
map ['--list-block-groups'] => :list_block_groups
|
124
141
|
def list_block_groups(*_args)
|
125
142
|
puts Facter::FactGroups.new.groups.to_yaml.lines[1..-1].join
|
126
143
|
end
|
127
144
|
|
128
|
-
desc '--list-cache-groups', 'List cache groups'
|
145
|
+
desc '--list-cache-groups', 'List cache groups', hide: true
|
129
146
|
map ['--list-cache-groups'] => :list_cache_groups
|
130
147
|
def list_cache_groups(*_args)
|
131
148
|
puts Facter::FactGroups.new.groups.to_yaml.lines[1..-1].join
|
@@ -51,6 +51,8 @@ module Facter
|
|
51
51
|
@external_facts.concat(@external_fact_loader.custom_facts)
|
52
52
|
end
|
53
53
|
|
54
|
+
@external_facts = block_facts(@external_facts, options)
|
55
|
+
|
54
56
|
if options[:external_facts]
|
55
57
|
@log.debug('Loading external facts')
|
56
58
|
@external_facts.concat(@external_fact_loader.external_facts)
|
@@ -45,6 +45,7 @@ module Facter
|
|
45
45
|
Facter::OptionStore.cli = true
|
46
46
|
Facter::OptionStore.show_legacy = false
|
47
47
|
Facter::OptionStore.user_query = user_query
|
48
|
+
Facter::OptionStore.trace = cli_options[:trace]
|
48
49
|
OptionStore.set(:config, cli_options[:config])
|
49
50
|
ConfigFileOptions.init(cli_options[:config])
|
50
51
|
store(ConfigFileOptions.get)
|
@@ -25,13 +25,13 @@ module Facter
|
|
25
25
|
@color = false
|
26
26
|
|
27
27
|
class << self
|
28
|
-
attr_reader :debug, :verbose, :log_level, :show_legacy, :
|
28
|
+
attr_reader :debug, :verbose, :log_level, :show_legacy, :ruby,
|
29
29
|
:custom_facts, :blocked_facts
|
30
30
|
|
31
31
|
attr_accessor :config, :user_query, :strict, :json, :haml, :external_facts,
|
32
32
|
:cache, :yaml, :puppet, :ttls, :block, :cli, :config_file_custom_dir,
|
33
33
|
:config_file_external_dir, :default_external_dir, :fact_groups,
|
34
|
-
:block_list, :color
|
34
|
+
:block_list, :color, :trace
|
35
35
|
|
36
36
|
attr_writer :external_dir
|
37
37
|
|
@@ -131,10 +131,6 @@ module Facter
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
def trace=(bool)
|
135
|
-
Facter.trace(bool)
|
136
|
-
end
|
137
|
-
|
138
134
|
def set(key, value)
|
139
135
|
send("#{key}=".to_sym, value)
|
140
136
|
end
|
@@ -150,6 +146,7 @@ module Facter
|
|
150
146
|
@user_query = []
|
151
147
|
@cli = nil
|
152
148
|
@cache = true
|
149
|
+
@trace = false
|
153
150
|
reset_config
|
154
151
|
end
|
155
152
|
|
@@ -3,10 +3,11 @@
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
5
|
module Facter
|
6
|
-
RED
|
7
|
-
GREEN
|
8
|
-
YELLOW
|
9
|
-
CYAN
|
6
|
+
RED = "\e[31m"
|
7
|
+
GREEN = "\e[32m"
|
8
|
+
YELLOW = "\e[33m"
|
9
|
+
CYAN = "\e[36m"
|
10
|
+
RESET = "\e[0m"
|
10
11
|
|
11
12
|
DEFAULT_LOG_LEVEL = :warn
|
12
13
|
|
@@ -104,12 +105,19 @@ module Facter
|
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
108
|
+
def log_exception(exception)
|
109
|
+
msg = colorize(exception.message, RED) + "\n"
|
110
|
+
msg += exception.backtrace.join("\n") if Options[:trace]
|
111
|
+
|
112
|
+
@@logger.error(@class_name + ' - ' + msg)
|
113
|
+
end
|
114
|
+
|
107
115
|
private
|
108
116
|
|
109
117
|
def colorize(msg, color)
|
110
118
|
return msg if OsDetector.instance.identifier.eql?(:windows)
|
111
119
|
|
112
|
-
"
|
120
|
+
"#{color}#{msg}#{RESET}"
|
113
121
|
end
|
114
122
|
|
115
123
|
def debugging_active?
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facter
|
4
|
+
module Resolvers
|
5
|
+
module Aix
|
6
|
+
class Disks < BaseResolver
|
7
|
+
@semaphore = Mutex.new
|
8
|
+
@fact_list ||= {}
|
9
|
+
class << self
|
10
|
+
private
|
11
|
+
|
12
|
+
def post_resolve(fact_name)
|
13
|
+
@fact_list.fetch(fact_name) { execute_lspv(fact_name) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute_lspv(fact_name)
|
17
|
+
@fact_list[:disks] = {}
|
18
|
+
|
19
|
+
result = Facter::Core::Execution.execute('lspv', logger: log)
|
20
|
+
|
21
|
+
return if result.empty?
|
22
|
+
|
23
|
+
result.each_line do |line|
|
24
|
+
disk_name = line.split(' ')[0].strip
|
25
|
+
size = find_size(disk_name)
|
26
|
+
@fact_list[:disks][disk_name] = size if size
|
27
|
+
end
|
28
|
+
|
29
|
+
@fact_list[fact_name]
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_size(name)
|
33
|
+
stdout = Facter::Core::Execution.execute("lspv #{name}", logger: log)
|
34
|
+
|
35
|
+
return if stdout.empty?
|
36
|
+
|
37
|
+
info_size = InfoExtractor.extract(stdout, /PP SIZE:|TOTAL PPs:|FREE PPs:|PV STATE:/)
|
38
|
+
|
39
|
+
return unless info_size['PV STATE']
|
40
|
+
|
41
|
+
size_bytes = compute_size(info_size)
|
42
|
+
|
43
|
+
{
|
44
|
+
size_bytes: size_bytes,
|
45
|
+
size: Facter::FactsUtils::UnitConverter.bytes_to_human_readable(size_bytes)
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def compute_size(size_hash)
|
50
|
+
physical_partitions = size_hash['TOTAL PPs'].to_i + size_hash['FREE PPs'].to_i
|
51
|
+
size_physical_partition = size_hash['PP SIZE']
|
52
|
+
exp = if size_physical_partition[/mega/]
|
53
|
+
InfoExtractor::MEGABYTES_EXPONENT
|
54
|
+
else
|
55
|
+
InfoExtractor::GIGABYTES_EXPONENT
|
56
|
+
end
|
57
|
+
size_physical_partition.to_i * physical_partitions * exp
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facter
|
4
|
+
module Resolvers
|
5
|
+
module Aix
|
6
|
+
class Memory < BaseResolver
|
7
|
+
# :hardware
|
8
|
+
@semaphore = Mutex.new
|
9
|
+
@fact_list ||= {}
|
10
|
+
class << self
|
11
|
+
private
|
12
|
+
|
13
|
+
def post_resolve(fact_name)
|
14
|
+
@fact_list.fetch(fact_name) { execute_svmon(fact_name) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute_svmon(fact_name)
|
18
|
+
result = Facter::Core::Execution.execute('svmon', logger: log)
|
19
|
+
return if result.empty?
|
20
|
+
|
21
|
+
@fact_list[:system] = @fact_list[:swap] = {}
|
22
|
+
|
23
|
+
pagesize = call_pagesize.to_i
|
24
|
+
return if pagesize.zero?
|
25
|
+
|
26
|
+
result.each_line do |line|
|
27
|
+
@fact_list[:system] = populate_system(line, pagesize) if line.include?('memory')
|
28
|
+
@fact_list[:swap] = populate_swap(line, pagesize) if line =~ /pg\sspace/
|
29
|
+
end
|
30
|
+
|
31
|
+
@fact_list[fact_name]
|
32
|
+
end
|
33
|
+
|
34
|
+
def call_pagesize
|
35
|
+
Facter::Core::Execution.execute('pagesize', logger: log).strip
|
36
|
+
end
|
37
|
+
|
38
|
+
def populate_system(content, pagesize)
|
39
|
+
content = content.split(' ')
|
40
|
+
|
41
|
+
total = content[1].to_i * pagesize
|
42
|
+
used = content[2].to_i * pagesize
|
43
|
+
|
44
|
+
{ available_bytes: content[3].to_i * pagesize,
|
45
|
+
total_bytes: total,
|
46
|
+
used_bytes: used,
|
47
|
+
capacity: FilesystemHelper.compute_capacity(used, total) }
|
48
|
+
end
|
49
|
+
|
50
|
+
def populate_swap(content, pagesize)
|
51
|
+
content = content.split(' ')
|
52
|
+
|
53
|
+
total = content[2].to_i * pagesize
|
54
|
+
used = content[3].to_i * pagesize
|
55
|
+
|
56
|
+
{ available_bytes: total - used,
|
57
|
+
total_bytes: total,
|
58
|
+
used_bytes: used,
|
59
|
+
capacity: FilesystemHelper.compute_capacity(used, total) }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -9,9 +9,6 @@ module Facter
|
|
9
9
|
class << self
|
10
10
|
private
|
11
11
|
|
12
|
-
MEGABYTES_EXPONENT = 1024**2
|
13
|
-
GIGABYTES_EXPONENT = 1024**3
|
14
|
-
|
15
12
|
def post_resolve(fact_name)
|
16
13
|
@fact_list.fetch(fact_name) { query_cudv(fact_name) }
|
17
14
|
end
|
@@ -43,7 +40,7 @@ module Facter
|
|
43
40
|
|
44
41
|
return if stdout.empty?
|
45
42
|
|
46
|
-
info_hash =
|
43
|
+
info_hash = InfoExtractor.extract(stdout, /PPs:|PP SIZE|TYPE:|LABEL:|MOUNT/)
|
47
44
|
size_bytes = compute_size(info_hash)
|
48
45
|
|
49
46
|
part_info = {
|
@@ -51,29 +48,21 @@ module Facter
|
|
51
48
|
size_bytes: size_bytes,
|
52
49
|
size: Facter::FactsUtils::UnitConverter.bytes_to_human_readable(size_bytes)
|
53
50
|
}
|
54
|
-
mount = info_hash['
|
51
|
+
mount = info_hash['MOUNT POINT']
|
55
52
|
label = info_hash['LABEL']
|
56
53
|
part_info[:mount] = mount unless %r{N/A} =~ mount
|
57
|
-
part_info[:label] = label unless /None/ =~ label
|
54
|
+
part_info[:label] = label.strip unless /None/ =~ label
|
58
55
|
part_info
|
59
56
|
end
|
60
57
|
|
61
|
-
def extract_info(lsl_content)
|
62
|
-
lsl_content = lsl_content.strip.split("\n").map do |line|
|
63
|
-
next unless /PPs:|PP SIZE|TYPE:|LABEL:|MOUNT/ =~ line
|
64
|
-
|
65
|
-
line.split(/:|\s\s/).reject(&:empty?)
|
66
|
-
end
|
67
|
-
|
68
|
-
lsl_content.flatten!.select! { |elem| elem }.map! { |elem| elem.delete("\s") }
|
69
|
-
|
70
|
-
Hash[*lsl_content]
|
71
|
-
end
|
72
|
-
|
73
58
|
def compute_size(info_hash)
|
74
59
|
physical_partitions = info_hash['PPs'].to_i
|
75
|
-
size_physical_partition = info_hash['
|
76
|
-
exp = size_physical_partition[/mega/]
|
60
|
+
size_physical_partition = info_hash['PP SIZE']
|
61
|
+
exp = if size_physical_partition[/mega/]
|
62
|
+
InfoExtractor::MEGABYTES_EXPONENT
|
63
|
+
else
|
64
|
+
InfoExtractor::GIGABYTES_EXPONENT
|
65
|
+
end
|
77
66
|
size_physical_partition.to_i * physical_partitions * exp
|
78
67
|
end
|
79
68
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facter
|
4
|
+
module InfoExtractor
|
5
|
+
MEGABYTES_EXPONENT = 1024**2
|
6
|
+
GIGABYTES_EXPONENT = 1024**3
|
7
|
+
|
8
|
+
def self.extract(content, regex)
|
9
|
+
content = content.each_line.map do |line|
|
10
|
+
next unless regex =~ line
|
11
|
+
|
12
|
+
line.split(/:\s*|\s{2,}/)
|
13
|
+
end
|
14
|
+
|
15
|
+
content.flatten!.reject!(&:nil?)
|
16
|
+
|
17
|
+
Hash[*content]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
<%# encoding: UTF-8%>
|
2
|
+
SYNOPSIS
|
3
|
+
--------
|
4
|
+
facter [options] [query] [query] [...]
|
5
|
+
|
6
|
+
DESCRIPTION
|
7
|
+
-----------
|
8
|
+
Collect and display facts about the current system. The library behind Facter is easy to extend, making Facter an easy way to collect information about a system.
|
9
|
+
|
10
|
+
If no queries are given, then all facts will be returned.
|
11
|
+
|
12
|
+
Many of the command line options can also be set via the HOCON config file. This file can also be used to block or cache certain fact groups.
|
13
|
+
|
14
|
+
OPTIONS
|
15
|
+
-------
|
16
|
+
<% @Facter::Cli.class_options.each do |name, option| -%><% next if option.hide%>
|
17
|
+
* `<%= option.aliases[0] + '`, `' if option.aliases.any? %>--<%= 'no-' if negate_options.include?(name.to_s)%><%= name.to_s.gsub('_','-') %>`:
|
18
|
+
|
19
|
+
<%= option.description %>
|
20
|
+
|
21
|
+
<% end -%>
|
22
|
+
|
23
|
+
FILES
|
24
|
+
-----
|
25
|
+
<em>/etc/puppetlabs/facter/facter.conf</em>
|
26
|
+
|
27
|
+
A HOCON config file that can be used to specify directories for custom and external facts, set various command line options, and specify facts to block. See example below for details, or visit the GitHub README.
|
28
|
+
|
29
|
+
EXAMPLES
|
30
|
+
--------
|
31
|
+
Display all facts:
|
32
|
+
|
33
|
+
```
|
34
|
+
$ facter
|
35
|
+
disks => {
|
36
|
+
sda => {
|
37
|
+
model => "Virtual disk",
|
38
|
+
size => "8.00 GiB",
|
39
|
+
size_bytes => 8589934592,
|
40
|
+
vendor => "ExampleVendor"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
dmi => {
|
44
|
+
bios => {
|
45
|
+
release_date => "06/23/2013",
|
46
|
+
vendor => "Example Vendor",
|
47
|
+
version => "6.00"
|
48
|
+
}
|
49
|
+
}
|
50
|
+
[\.\.\.]
|
51
|
+
```
|
52
|
+
|
53
|
+
Display a single structured fact:
|
54
|
+
|
55
|
+
```
|
56
|
+
$ facter processors
|
57
|
+
{
|
58
|
+
count => 2,
|
59
|
+
isa => "x86_64",
|
60
|
+
models => [
|
61
|
+
"Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz",
|
62
|
+
"Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz"
|
63
|
+
],
|
64
|
+
physicalcount => 2
|
65
|
+
}
|
66
|
+
```
|
67
|
+
|
68
|
+
Display a single fact nested within a structured fact:
|
69
|
+
|
70
|
+
```
|
71
|
+
$ facter processors.isa
|
72
|
+
x86_64
|
73
|
+
```
|
74
|
+
|
75
|
+
Display a single legacy fact. Note that non-structured facts existing in previous versions of Facter are still available,
|
76
|
+
but are not displayed by default due to redundancy with newer structured facts:
|
77
|
+
|
78
|
+
```
|
79
|
+
$ facter processorcount
|
80
|
+
2
|
81
|
+
```
|
82
|
+
|
83
|
+
Format facts as JSON:
|
84
|
+
|
85
|
+
```
|
86
|
+
$ facter \-\-json os.name os.release.major processors.isa
|
87
|
+
{
|
88
|
+
"os.name": "Ubuntu",
|
89
|
+
"os.release.major": "14.04",
|
90
|
+
"processors.isa": "x86_64"
|
91
|
+
}
|
92
|
+
```
|
93
|
+
|
94
|
+
An example config file.
|
95
|
+
|
96
|
+
```
|
97
|
+
# always loaded (CLI and as Ruby module)
|
98
|
+
global : {
|
99
|
+
external-dir : "~/external/facts",
|
100
|
+
custom-dir : [
|
101
|
+
"~/custom/facts",
|
102
|
+
"~/custom/facts/more-facts"
|
103
|
+
],
|
104
|
+
no-external-facts : false,
|
105
|
+
no-custom-facts : false,
|
106
|
+
no-ruby : false
|
107
|
+
}
|
108
|
+
# loaded when running from the command line
|
109
|
+
cli : {
|
110
|
+
debug : false,
|
111
|
+
trace : true,
|
112
|
+
verbose : false,
|
113
|
+
log-level : "info"
|
114
|
+
}
|
115
|
+
# always loaded, fact-sepcific configuration
|
116
|
+
facts : {
|
117
|
+
# for valid blocklist entries, use --list-block-groups
|
118
|
+
blocklist : [ "file system", "EC2" ],
|
119
|
+
# for valid time-to-live entries, use --list-cache-groups
|
120
|
+
ttls : [ { "timezone" : 30 days } ]
|
121
|
+
}
|
122
|
+
```
|
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.0.
|
4
|
+
version: 4.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- lib/facter/fact_groups.conf
|
209
209
|
- lib/facter/facts/aix/aio_agent_version.rb
|
210
210
|
- lib/facter/facts/aix/augeas/version.rb
|
211
|
+
- lib/facter/facts/aix/disks.rb
|
211
212
|
- lib/facter/facts/aix/facterversion.rb
|
212
213
|
- lib/facter/facts/aix/filesystems.rb
|
213
214
|
- lib/facter/facts/aix/hypervisors/lpar.rb
|
@@ -226,6 +227,20 @@ files:
|
|
226
227
|
- lib/facter/facts/aix/kernelversion.rb
|
227
228
|
- lib/facter/facts/aix/load_averages.rb
|
228
229
|
- lib/facter/facts/aix/macaddress_interfaces.rb
|
230
|
+
- lib/facter/facts/aix/memory/swap/available.rb
|
231
|
+
- lib/facter/facts/aix/memory/swap/available_bytes.rb
|
232
|
+
- lib/facter/facts/aix/memory/swap/capacity.rb
|
233
|
+
- lib/facter/facts/aix/memory/swap/total.rb
|
234
|
+
- lib/facter/facts/aix/memory/swap/total_bytes.rb
|
235
|
+
- lib/facter/facts/aix/memory/swap/used.rb
|
236
|
+
- lib/facter/facts/aix/memory/swap/used_bytes.rb
|
237
|
+
- lib/facter/facts/aix/memory/system/available.rb
|
238
|
+
- lib/facter/facts/aix/memory/system/available_bytes.rb
|
239
|
+
- lib/facter/facts/aix/memory/system/capacity.rb
|
240
|
+
- lib/facter/facts/aix/memory/system/total.rb
|
241
|
+
- lib/facter/facts/aix/memory/system/total_bytes.rb
|
242
|
+
- lib/facter/facts/aix/memory/system/used.rb
|
243
|
+
- lib/facter/facts/aix/memory/system/used_bytes.rb
|
229
244
|
- lib/facter/facts/aix/mountpoints.rb
|
230
245
|
- lib/facter/facts/aix/mtu_interfaces.rb
|
231
246
|
- lib/facter/facts/aix/netmask6_interfaces.rb
|
@@ -726,16 +741,19 @@ files:
|
|
726
741
|
- lib/facter/os_hierarchy.json
|
727
742
|
- lib/facter/resolvers/aio_agent_version.rb
|
728
743
|
- lib/facter/resolvers/aix/architecture_resolver.rb
|
744
|
+
- lib/facter/resolvers/aix/disks.rb
|
729
745
|
- lib/facter/resolvers/aix/ffi/ffi_helper.rb
|
730
746
|
- lib/facter/resolvers/aix/filesystem_resolver.rb
|
731
747
|
- lib/facter/resolvers/aix/hardware_resolver.rb
|
732
748
|
- lib/facter/resolvers/aix/load_averages_resolver.rb
|
749
|
+
- lib/facter/resolvers/aix/memory.rb
|
733
750
|
- lib/facter/resolvers/aix/mountpoints.rb
|
734
751
|
- lib/facter/resolvers/aix/networking_resolver.rb
|
735
752
|
- lib/facter/resolvers/aix/nim.rb
|
736
753
|
- lib/facter/resolvers/aix/os_level_resolver.rb
|
737
754
|
- lib/facter/resolvers/aix/partitions.rb
|
738
755
|
- lib/facter/resolvers/aix/processors.rb
|
756
|
+
- lib/facter/resolvers/aix/utils/info_extractor.rb
|
739
757
|
- lib/facter/resolvers/aix/utils/odm_query.rb
|
740
758
|
- lib/facter/resolvers/augeas_resolver.rb
|
741
759
|
- lib/facter/resolvers/base_resolver.rb
|
@@ -842,6 +860,7 @@ files:
|
|
842
860
|
- lib/facter/resolvers/windows/win_os_description_resolver.rb
|
843
861
|
- lib/facter/resolvers/wpar_resolver.rb
|
844
862
|
- lib/facter/resolvers/xen.rb
|
863
|
+
- lib/facter/templates/man.erb
|
845
864
|
- lib/facter/util/api_debugger.rb
|
846
865
|
- lib/facter/util/file_helper.rb
|
847
866
|
- lib/facter/version.rb
|