facter 1.7.6 → 2.0.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/COMMITTERS.md +194 -0
- data/CONTRIBUTING.md +63 -235
- data/Gemfile +12 -8
- data/README.md +1 -2
- data/Rakefile +1 -1
- data/bin/facter +0 -4
- data/ext/build_defaults.yaml +2 -2
- data/ext/project_data.yaml +18 -0
- data/install.rb +1 -16
- data/lib/facter.rb +171 -171
- data/lib/facter/application.rb +65 -54
- data/lib/facter/core/aggregate.rb +220 -0
- data/lib/facter/core/directed_graph.rb +46 -0
- data/lib/facter/core/execution.rb +100 -0
- data/lib/facter/core/execution/base.rb +73 -0
- data/lib/facter/core/execution/posix.rb +50 -0
- data/lib/facter/core/execution/windows.rb +57 -0
- data/lib/facter/core/logging.rb +169 -0
- data/lib/facter/core/resolvable.rb +94 -0
- data/lib/facter/core/suitable.rb +117 -0
- data/lib/facter/domain.rb +15 -9
- data/lib/facter/filesystems.rb +1 -1
- data/lib/facter/hardwaremodel.rb +1 -1
- data/lib/facter/hostname.rb +3 -3
- data/lib/facter/interfaces.rb +6 -1
- data/lib/facter/ipaddress.rb +2 -2
- data/lib/facter/kernel.rb +1 -1
- data/lib/facter/kernelrelease.rb +1 -1
- data/lib/facter/ldom.rb +1 -1
- data/lib/facter/lsbdistcodename.rb +1 -1
- data/lib/facter/lsbdistdescription.rb +1 -1
- data/lib/facter/lsbdistid.rb +1 -1
- data/lib/facter/lsbdistrelease.rb +1 -1
- data/lib/facter/lsbrelease.rb +1 -1
- data/lib/facter/macaddress.rb +1 -14
- data/lib/facter/macosx.rb +2 -2
- data/lib/facter/memory.rb +8 -19
- data/lib/facter/operatingsystem.rb +1 -1
- data/lib/facter/operatingsystemrelease.rb +34 -1
- data/lib/facter/physicalprocessorcount.rb +6 -6
- data/lib/facter/processor.rb +11 -10
- data/lib/facter/selinux.rb +4 -15
- data/lib/facter/ssh.rb +5 -2
- data/lib/facter/util/architecture.rb +2 -2
- data/lib/facter/util/collection.rb +42 -38
- data/lib/facter/util/config.rb +19 -9
- data/lib/facter/util/confine.rb +34 -4
- data/lib/facter/util/ec2.rb +1 -1
- data/lib/facter/util/fact.rb +108 -36
- data/lib/facter/util/file_read.rb +7 -6
- data/lib/facter/util/formatter.rb +38 -0
- data/lib/facter/util/ip.rb +3 -3
- data/lib/facter/util/loader.rb +62 -42
- data/lib/facter/util/macosx.rb +7 -8
- data/lib/facter/util/manufacturer.rb +3 -3
- data/lib/facter/util/memory.rb +13 -13
- data/lib/facter/util/monkey_patches.rb +0 -31
- data/lib/facter/util/netmask.rb +3 -3
- data/lib/facter/util/normalization.rb +94 -0
- data/lib/facter/util/nothing_loader.rb +3 -6
- data/lib/facter/util/parser.rb +3 -5
- data/lib/facter/util/plist/generator.rb +1 -1
- data/lib/facter/util/processor.rb +15 -15
- data/lib/facter/util/resolution.rb +112 -289
- data/lib/facter/util/solaris_zones.rb +4 -4
- data/lib/facter/util/uptime.rb +8 -3
- data/lib/facter/util/values.rb +67 -1
- data/lib/facter/util/virtual.rb +10 -10
- data/lib/facter/util/xendomains.rb +1 -1
- data/lib/facter/version.rb +42 -39
- data/lib/facter/virtual.rb +6 -7
- data/lib/facter/zfs_version.rb +3 -3
- data/lib/facter/zpool_version.rb +3 -3
- data/spec/fixtures/unit/netmask/darwin_10_8_5.txt +30 -0
- data/spec/unit/application_spec.rb +46 -1
- data/spec/unit/core/aggregate_spec.rb +125 -0
- data/spec/unit/core/directed_graph_spec.rb +79 -0
- data/spec/unit/core/execution/base_spec.rb +119 -0
- data/spec/unit/core/execution/posix_spec.rb +86 -0
- data/spec/unit/core/execution/windows_spec.rb +106 -0
- data/spec/unit/core/execution_spec.rb +37 -0
- data/spec/unit/core/logging_spec.rb +104 -0
- data/spec/unit/core/resolvable_spec.rb +81 -0
- data/spec/unit/core/suitable_spec.rb +96 -0
- data/spec/unit/domain_spec.rb +5 -5
- data/spec/unit/facter_spec.rb +61 -222
- data/spec/unit/filesystems_spec.rb +2 -2
- data/spec/unit/hardwareisa_spec.rb +5 -5
- data/spec/unit/hardwaremodel_spec.rb +1 -1
- data/spec/unit/hostname_spec.rb +4 -4
- data/spec/unit/id_spec.rb +3 -3
- data/spec/unit/interfaces_spec.rb +10 -0
- data/spec/unit/ipaddress6_spec.rb +4 -4
- data/spec/unit/ipaddress_spec.rb +1 -1
- data/spec/unit/kernel_spec.rb +2 -2
- data/spec/unit/kernelmajversion_spec.rb +1 -1
- data/spec/unit/kernelrelease_spec.rb +4 -4
- data/spec/unit/kernelversion_spec.rb +2 -2
- data/spec/unit/ldom_spec.rb +2 -2
- data/spec/unit/lsbdistcodename_spec.rb +2 -2
- data/spec/unit/lsbdistdescription_spec.rb +2 -2
- data/spec/unit/lsbdistid_spec.rb +2 -2
- data/spec/unit/lsbdistrelease_spec.rb +2 -2
- data/spec/unit/lsbrelease_spec.rb +2 -2
- data/spec/unit/manufacturer_spec.rb +1 -1
- data/spec/unit/memory_spec.rb +24 -31
- data/spec/unit/netmask_spec.rb +9 -0
- data/spec/unit/operatingsystem_spec.rb +1 -1
- data/spec/unit/operatingsystemrelease_spec.rb +62 -4
- data/spec/unit/physicalprocessorcount_spec.rb +10 -10
- data/spec/unit/processor_spec.rb +11 -11
- data/spec/unit/selinux_spec.rb +2 -8
- data/spec/unit/ssh_spec.rb +3 -2
- data/spec/unit/uniqueid_spec.rb +3 -3
- data/spec/unit/util/collection_spec.rb +37 -35
- data/spec/unit/util/config_spec.rb +20 -0
- data/spec/unit/util/confine_spec.rb +21 -0
- data/spec/unit/util/directory_loader_spec.rb +1 -0
- data/spec/unit/util/ec2_spec.rb +6 -6
- data/spec/unit/util/fact_spec.rb +92 -90
- data/spec/unit/util/ip_spec.rb +2 -2
- data/spec/unit/util/loader_spec.rb +127 -186
- data/spec/unit/util/macaddress_spec.rb +2 -2
- data/spec/unit/util/macosx_spec.rb +8 -8
- data/spec/unit/util/manufacturer_spec.rb +3 -3
- data/spec/unit/util/normalization_spec.rb +113 -0
- data/spec/unit/util/parser_spec.rb +25 -3
- data/spec/unit/util/processor_spec.rb +2 -2
- data/spec/unit/util/resolution_spec.rb +60 -631
- data/spec/unit/util/solaris_zones_spec.rb +5 -5
- data/spec/unit/util/uptime_spec.rb +1 -1
- data/spec/unit/util/values_spec.rb +131 -0
- data/spec/unit/util/virtual_spec.rb +16 -16
- data/spec/unit/util/xendomains_spec.rb +2 -2
- data/spec/unit/virtual_spec.rb +39 -39
- data/spec/unit/zfs_version_spec.rb +11 -11
- data/spec/unit/zonename_spec.rb +2 -2
- data/spec/unit/zones_spec.rb +1 -1
- data/spec/unit/zpool_version_spec.rb +11 -11
- metadata +466 -447
- data/lib/facter/util/cfpropertylist.rb +0 -6
- data/lib/facter/util/cfpropertylist/LICENSE +0 -19
- data/lib/facter/util/cfpropertylist/README +0 -44
- data/lib/facter/util/cfpropertylist/Rakefile +0 -44
- data/lib/facter/util/cfpropertylist/THANKS +0 -7
- data/lib/facter/util/cfpropertylist/lib/cfpropertylist.rb +0 -6
- data/lib/facter/util/cfpropertylist/lib/rbBinaryCFPropertyList.rb +0 -562
- data/lib/facter/util/cfpropertylist/lib/rbCFPlistError.rb +0 -26
- data/lib/facter/util/cfpropertylist/lib/rbCFPropertyList.rb +0 -407
- data/lib/facter/util/cfpropertylist/lib/rbCFTypes.rb +0 -244
- data/lib/facter/util/cfpropertylist/lib/rbLibXMLParser.rb +0 -135
- data/lib/facter/util/cfpropertylist/lib/rbNokogiriParser.rb +0 -140
- data/lib/facter/util/cfpropertylist/lib/rbREXMLParser.rb +0 -136
- data/spec/unit/util/monkey_patches_spec.rb +0 -42
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
3
|
+
# The resolvable mixin defines behavior for evaluating and returning fact
|
4
|
+
# resolutions.
|
5
|
+
#
|
6
|
+
# Classes including this mixin should implement at #name method describing
|
7
|
+
# the value being resolved and a #resolve_value that actually executes the code
|
8
|
+
# to resolve the value.
|
9
|
+
module Facter::Core::Resolvable
|
10
|
+
|
11
|
+
# The timeout, in seconds, for evaluating this resolution.
|
12
|
+
# @return [Integer]
|
13
|
+
# @api public
|
14
|
+
attr_accessor :timeout
|
15
|
+
|
16
|
+
# Return the timeout period for resolving a value.
|
17
|
+
# (see #timeout)
|
18
|
+
# @return [Numeric]
|
19
|
+
# @comment requiring 'timeout' stdlib class causes Object#timeout to be
|
20
|
+
# defined which delegates to Timeout.timeout. This method may potentially
|
21
|
+
# overwrite the #timeout attr_reader on this class, so we define #limit to
|
22
|
+
# avoid conflicts.
|
23
|
+
def limit
|
24
|
+
@timeout || 0
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# on_flush accepts a block and executes the block when the resolution's value
|
29
|
+
# is flushed. This makes it possible to model a single, expensive system
|
30
|
+
# call inside of a Ruby object and then define multiple dynamic facts which
|
31
|
+
# resolve by sending messages to the model instance. If one of the dynamic
|
32
|
+
# facts is flushed then it can, in turn, flush the data stored in the model
|
33
|
+
# instance to keep all of the dynamic facts in sync without making multiple,
|
34
|
+
# expensive, system calls.
|
35
|
+
#
|
36
|
+
# Please see the Solaris zones fact for an example of how this feature may be
|
37
|
+
# used.
|
38
|
+
#
|
39
|
+
# @see Facter::Util::Fact#flush
|
40
|
+
# @see Facter::Util::Resolution#flush
|
41
|
+
#
|
42
|
+
# @api public
|
43
|
+
def on_flush(&block)
|
44
|
+
@on_flush_block = block
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# flush executes the block, if any, stored by the {on_flush} method
|
49
|
+
#
|
50
|
+
# @see Facter::Util::Fact#flush
|
51
|
+
# @see Facter::Util::Resolution#on_flush
|
52
|
+
#
|
53
|
+
# @api private
|
54
|
+
def flush
|
55
|
+
@on_flush_block.call if @on_flush_block
|
56
|
+
end
|
57
|
+
|
58
|
+
def value
|
59
|
+
result = nil
|
60
|
+
|
61
|
+
with_timing do
|
62
|
+
Timeout.timeout(limit) do
|
63
|
+
result = resolve_value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
Facter::Util::Normalization.normalize(result)
|
68
|
+
rescue Timeout::Error => detail
|
69
|
+
Facter.log_exception(detail, "Timed out after #{limit} seconds while resolving #{qualified_name}")
|
70
|
+
return nil
|
71
|
+
rescue Facter::Util::Normalization::NormalizationError => detail
|
72
|
+
Facter.log_exception(detail, "Fact resolution #{qualified_name} resolved to an invalid value: #{detail.message}")
|
73
|
+
return nil
|
74
|
+
rescue => detail
|
75
|
+
Facter.log_exception(detail, "Could not retrieve #{qualified_name}: #{detail.message}")
|
76
|
+
return nil
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def with_timing
|
82
|
+
starttime = Time.now.to_f
|
83
|
+
|
84
|
+
yield
|
85
|
+
|
86
|
+
finishtime = Time.now.to_f
|
87
|
+
ms = (finishtime - starttime) * 1000
|
88
|
+
Facter.show_time "#{qualified_name}: #{"%.2f" % ms}ms"
|
89
|
+
end
|
90
|
+
|
91
|
+
def qualified_name
|
92
|
+
"fact='#{@fact.name.to_s}', resolution='#{@name || '<anonymous>'}'"
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'facter'
|
2
|
+
|
3
|
+
# The Suitable mixin provides mechanisms for confining objects to run on
|
4
|
+
# certain platforms and determining the run precedence of these objects.
|
5
|
+
#
|
6
|
+
# Classes that include the Suitable mixin should define a `#confines` method
|
7
|
+
# that returns an Array of zero or more Facter::Util::Confine objects.
|
8
|
+
module Facter::Core::Suitable
|
9
|
+
|
10
|
+
attr_writer :weight
|
11
|
+
|
12
|
+
# Sets the weight of this resolution. If multiple suitable resolutions
|
13
|
+
# are found, the one with the highest weight will be used. If weight
|
14
|
+
# is not given, the number of confines set on a resolution will be
|
15
|
+
# used as its weight (so that the most specific resolution is used).
|
16
|
+
#
|
17
|
+
# @param weight [Integer] the weight of this resolution
|
18
|
+
#
|
19
|
+
# @return [void]
|
20
|
+
#
|
21
|
+
# @api public
|
22
|
+
def has_weight(weight)
|
23
|
+
@weight = weight
|
24
|
+
end
|
25
|
+
|
26
|
+
# Sets the conditions for this resolution to be used. This method accepts
|
27
|
+
# multiple forms of arguments to determine suitability.
|
28
|
+
#
|
29
|
+
# @return [void]
|
30
|
+
#
|
31
|
+
# @api public
|
32
|
+
#
|
33
|
+
# @overload confine(confines)
|
34
|
+
# Confine a fact to a specific fact value or values. This form takes a
|
35
|
+
# hash of fact names and values. Every fact must match the values given for
|
36
|
+
# that fact, otherwise this resolution will not be considered suitable. The
|
37
|
+
# values given for a fact can be an array, in which case the value of the
|
38
|
+
# fact must be in the array for it to match.
|
39
|
+
# @param [Hash{String,Symbol=>String,Array<String>}] confines set of facts identified by the hash keys whose
|
40
|
+
# fact value must match the argument value.
|
41
|
+
# @example Confining to Linux
|
42
|
+
# Facter.add(:powerstates) do
|
43
|
+
# # This resolution only makes sense on linux systems
|
44
|
+
# confine :kernel => "Linux"
|
45
|
+
# setcode do
|
46
|
+
# File.read('/sys/power/states')
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# @overload confine(confines, &block)
|
51
|
+
# Confine a fact to a block with the value of a specified fact yielded to
|
52
|
+
# the block.
|
53
|
+
# @param [String,Symbol] confines the fact name whose value should be
|
54
|
+
# yielded to the block
|
55
|
+
# @param [Proc] block determines the suitability of the fact. If the block
|
56
|
+
# evaluates to `false` or `nil` then the confined fact will not be
|
57
|
+
# evaluated.
|
58
|
+
# @yield [value] the value of the fact identified by {confines}
|
59
|
+
# @example Confine the fact to a host with an ipaddress in a specific
|
60
|
+
# subnet
|
61
|
+
# confine :ipaddress do |addr|
|
62
|
+
# require 'ipaddr'
|
63
|
+
# IPAddr.new('192.168.0.0/16').include? addr
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# @overload confine(&block)
|
67
|
+
# Confine a fact to a block. The fact will be evaluated only if the block
|
68
|
+
# evaluates to something other than `false` or `nil`.
|
69
|
+
# @param [Proc] block determines the suitability of the fact. If the block
|
70
|
+
# evaluates to `false` or `nil` then the confined fact will not be
|
71
|
+
# evaluated.
|
72
|
+
# @example Confine the fact to systems with a specific file.
|
73
|
+
# confine { File.exist? '/bin/foo' }
|
74
|
+
def confine(confines = nil, &block)
|
75
|
+
case confines
|
76
|
+
when Hash
|
77
|
+
confines.each do |fact, values|
|
78
|
+
@confines.push Facter::Util::Confine.new(fact, *values)
|
79
|
+
end
|
80
|
+
else
|
81
|
+
if block
|
82
|
+
if confines
|
83
|
+
@confines.push Facter::Util::Confine.new(confines, &block)
|
84
|
+
else
|
85
|
+
@confines.push Facter::Util::Confine.new(&block)
|
86
|
+
end
|
87
|
+
else
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Returns the importance of this resolution. If the weight was not
|
93
|
+
# given, the number of confines is used instead (so that a more
|
94
|
+
# specific resolution wins over a less specific one).
|
95
|
+
#
|
96
|
+
# @return [Integer] the weight of this resolution
|
97
|
+
#
|
98
|
+
# @api private
|
99
|
+
def weight
|
100
|
+
if @weight
|
101
|
+
@weight
|
102
|
+
else
|
103
|
+
@confines.length
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Is this resolution mechanism suitable on the system in question?
|
108
|
+
#
|
109
|
+
# @api private
|
110
|
+
def suitable?
|
111
|
+
unless defined? @suitable
|
112
|
+
@suitable = ! @confines.detect { |confine| ! confine.true? }
|
113
|
+
end
|
114
|
+
|
115
|
+
return @suitable
|
116
|
+
end
|
117
|
+
end
|
data/lib/facter/domain.rb
CHANGED
@@ -41,11 +41,11 @@ Facter.add(:domain) do
|
|
41
41
|
basic_hostname
|
42
42
|
end
|
43
43
|
|
44
|
-
if name = Facter::
|
44
|
+
if name = Facter::Core::Execution.exec(hostname_command) \
|
45
45
|
and name =~ /.*?\.(.+$)/
|
46
46
|
|
47
47
|
return_value = $1
|
48
|
-
elsif Facter.value(:kernel) != "windows" and domain = Facter::
|
48
|
+
elsif Facter.value(:kernel) != "windows" and domain = Facter::Core::Execution.exec('dnsdomainname 2> /dev/null') \
|
49
49
|
and domain =~ /.+/
|
50
50
|
|
51
51
|
return_value = domain
|
@@ -64,8 +64,10 @@ Facter.add(:domain) do
|
|
64
64
|
return_value ||= domain
|
65
65
|
return_value ||= search
|
66
66
|
end
|
67
|
-
|
68
|
-
return_value
|
67
|
+
|
68
|
+
if return_value
|
69
|
+
return_value.gsub(/\.$/, '')
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
@@ -73,10 +75,13 @@ Facter.add(:domain) do
|
|
73
75
|
confine :kernel => :windows
|
74
76
|
setcode do
|
75
77
|
require 'facter/util/registry'
|
76
|
-
|
78
|
+
|
79
|
+
domain = nil
|
77
80
|
regvalue = Facter::Util::Registry.hklm_read('SYSTEM\CurrentControlSet\Services\Tcpip\Parameters', 'Domain')
|
78
|
-
|
79
|
-
if
|
81
|
+
|
82
|
+
if regvalue and not regvalue.empty?
|
83
|
+
domain = regvalue
|
84
|
+
else
|
80
85
|
require 'facter/util/wmi'
|
81
86
|
Facter::Util::WMI.execquery("select DNSDomain from Win32_NetworkAdapterConfiguration where IPEnabled = True").each { |nic|
|
82
87
|
if nic.DNSDomain && nic.DNSDomain.length > 0
|
@@ -86,8 +91,9 @@ Facter.add(:domain) do
|
|
86
91
|
}
|
87
92
|
end
|
88
93
|
|
89
|
-
domain ||= ''
|
90
94
|
|
91
|
-
domain
|
95
|
+
if domain
|
96
|
+
domain.gsub(/\.$/, '')
|
97
|
+
end
|
92
98
|
end
|
93
99
|
end
|
data/lib/facter/filesystems.rb
CHANGED
@@ -18,7 +18,7 @@ Facter.add('filesystems') do
|
|
18
18
|
# This is due to some problems with IO#read in Ruby and reading content of
|
19
19
|
# the "proc" file system that was reported more than once in the past ...
|
20
20
|
file_systems = []
|
21
|
-
Facter::
|
21
|
+
Facter::Core::Execution.exec('cat /proc/filesystems 2> /dev/null').each_line do |line|
|
22
22
|
# Remove bloat ...
|
23
23
|
line.strip!
|
24
24
|
|
data/lib/facter/hardwaremodel.rb
CHANGED
@@ -18,7 +18,7 @@ end
|
|
18
18
|
Facter.add(:hardwaremodel) do
|
19
19
|
confine :operatingsystem => :aix
|
20
20
|
setcode do
|
21
|
-
model = Facter::
|
21
|
+
model = Facter::Core::Execution.exec('lsattr -El sys0 -a modelname')
|
22
22
|
if model =~ /modelname\s(\S+)\s/
|
23
23
|
$1
|
24
24
|
end
|
data/lib/facter/hostname.rb
CHANGED
@@ -11,10 +11,10 @@
|
|
11
11
|
# Caveats:
|
12
12
|
#
|
13
13
|
|
14
|
-
Facter.add(:hostname
|
14
|
+
Facter.add(:hostname) do
|
15
15
|
setcode do
|
16
16
|
hostname = nil
|
17
|
-
if name = Facter::
|
17
|
+
if name = Facter::Core::Execution.exec('hostname')
|
18
18
|
if name =~ /(.*?)\./
|
19
19
|
hostname = $1
|
20
20
|
else
|
@@ -28,6 +28,6 @@ end
|
|
28
28
|
Facter.add(:hostname) do
|
29
29
|
confine :kernel => :darwin, :kernelrelease => "R7"
|
30
30
|
setcode do
|
31
|
-
Facter::
|
31
|
+
Facter::Core::Execution.exec('/usr/sbin/scutil --get LocalHostName')
|
32
32
|
end
|
33
33
|
end
|
data/lib/facter/interfaces.rb
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
#
|
16
16
|
|
17
17
|
require 'facter/util/ip'
|
18
|
+
require 'facter/util/macaddress'
|
18
19
|
|
19
20
|
# Note that most of this only works on a fixed list of platforms; notably, Darwin
|
20
21
|
# is missing.
|
@@ -34,7 +35,11 @@ Facter::Util::IP.get_interfaces.each do |interface|
|
|
34
35
|
%w{ipaddress ipaddress6 macaddress netmask mtu}.each do |label|
|
35
36
|
Facter.add(label + "_" + Facter::Util::IP.alphafy(interface)) do
|
36
37
|
setcode do
|
37
|
-
Facter::Util::IP.get_interface_value(interface, label)
|
38
|
+
value = Facter::Util::IP.get_interface_value(interface, label)
|
39
|
+
if label == "macaddress"
|
40
|
+
value = Facter::Util::Macaddress.standardize(value)
|
41
|
+
end
|
42
|
+
value
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|
data/lib/facter/ipaddress.rb
CHANGED
@@ -121,7 +121,7 @@ Facter.add(:ipaddress) do
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
Facter.add(:ipaddress, :
|
124
|
+
Facter.add(:ipaddress, :timeout => 2) do
|
125
125
|
setcode do
|
126
126
|
if Facter.value(:kernel) == 'windows'
|
127
127
|
require 'win32/resolv'
|
@@ -155,7 +155,7 @@ Facter.add(:ipaddress, :timeout => 2) do
|
|
155
155
|
if hostname = Facter.value(:hostname)
|
156
156
|
# we need Hostname to exist for this to work
|
157
157
|
host = nil
|
158
|
-
if host = Facter::
|
158
|
+
if host = Facter::Core::Execution.exec("host #{hostname}")
|
159
159
|
list = host.chomp.split(/\s/)
|
160
160
|
if defined? list[-1] and
|
161
161
|
list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/
|
data/lib/facter/kernel.rb
CHANGED
data/lib/facter/kernelrelease.rb
CHANGED
data/lib/facter/ldom.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
if Facter.value(:kernel) == 'SunOS'
|
2
|
-
virtinfo = Facter::
|
2
|
+
virtinfo = Facter::Core::Execution.exec('virtinfo -ap')
|
3
3
|
|
4
4
|
# Convert virtinfo parseable output format to array of arrays.
|
5
5
|
# DOMAINROLE|impl=LDoms|control=true|io=true|service=true|root=true
|
@@ -13,7 +13,7 @@
|
|
13
13
|
Facter.add(:lsbdistdescription) do
|
14
14
|
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
|
15
15
|
setcode do
|
16
|
-
if output = Facter::
|
16
|
+
if output = Facter::Core::Execution.exec('lsb_release -d -s 2>/dev/null')
|
17
17
|
# the output may be quoted (at least it is on gentoo)
|
18
18
|
output.sub(/^"(.*)"$/,'\1')
|
19
19
|
end
|
data/lib/facter/lsbdistid.rb
CHANGED
data/lib/facter/lsbrelease.rb
CHANGED
data/lib/facter/macaddress.rb
CHANGED
@@ -10,19 +10,6 @@
|
|
10
10
|
require 'facter/util/macaddress'
|
11
11
|
require 'facter/util/ip'
|
12
12
|
|
13
|
-
Facter.add(:macaddress) do
|
14
|
-
confine :kernel => 'Linux'
|
15
|
-
has_weight 10 # about an order of magnitude faster
|
16
|
-
setcode do
|
17
|
-
begin
|
18
|
-
Dir.glob('/sys/class/net/*').reject {|x| x[-3..-1] == '/lo' }.first
|
19
|
-
path and File.read(path + '/address')
|
20
|
-
rescue Exception
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
13
|
Facter.add(:macaddress) do
|
27
14
|
confine :kernel => 'Linux'
|
28
15
|
setcode do
|
@@ -52,7 +39,7 @@ Facter.add(:macaddress) do
|
|
52
39
|
confine :osfamily => "Solaris"
|
53
40
|
setcode do
|
54
41
|
ether = []
|
55
|
-
output = Facter::
|
42
|
+
output = Facter::Core::Execution.exec("/usr/bin/netstat -np")
|
56
43
|
output.each_line do |s|
|
57
44
|
ether.push($1) if s =~ /(?:SPLA)\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/
|
58
45
|
end
|