facter 1.6.4 → 1.6.5
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.
- data/CHANGELOG +33 -1
- data/conf/redhat/facter.spec +2 -1
- data/install.rb +25 -23
- data/lib/facter.rb +2 -1
- data/lib/facter/domain.rb +4 -4
- data/lib/facter/ec2.rb +6 -28
- data/lib/facter/hardwareisa.rb +0 -1
- data/lib/facter/hardwaremodel.rb +1 -1
- data/lib/facter/lsbmajdistrelease.rb +1 -1
- data/lib/facter/macaddress.rb +1 -1
- data/lib/facter/memory.rb +15 -4
- data/lib/facter/operatingsystem.rb +8 -4
- data/lib/facter/osfamily.rb +1 -1
- data/lib/facter/uniqueid.rb +1 -1
- data/lib/facter/util/collection.rb +2 -3
- data/lib/facter/util/config.rb +3 -3
- data/lib/facter/util/ec2.rb +49 -0
- data/lib/facter/util/fact.rb +12 -7
- data/lib/facter/util/monkey_patches.rb +7 -0
- data/lib/facter/util/uptime.rb +2 -2
- data/lib/facter/util/virtual.rb +1 -1
- data/lib/facter/virtual.rb +11 -1
- data/spec/{unit/data → fixtures/unit/selinux}/selinux_sestatus +0 -0
- data/spec/fixtures/unit/util/ec2/linux-arp-ec2.out +1 -0
- data/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out +5 -0
- data/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out +6 -0
- data/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out +10 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/6.0-STABLE_FreeBSD_ifconfig +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/Mac_OS_X_10.5.5_ifconfig +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/darwin_ifconfig_all_with_multiple_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/darwin_ifconfig_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/debian_kfreebsd_ifconfig +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/hpux_ifconfig_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/hpux_netstat_all_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/linux_ifconfig_all_with_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/solaris_ifconfig_all_with_multiple_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/solaris_ifconfig_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_all_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_single_interface6 +0 -0
- data/spec/{unit/data → fixtures/unit/util/manufacturer}/freebsd_dmidecode +0 -0
- data/spec/{unit/data → fixtures/unit/util/manufacturer}/linux_dmidecode_with_spaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/manufacturer}/opensolaris_smbios +0 -0
- data/spec/fixtures/{uptime → unit/util/uptime}/kstat_boot_time +0 -0
- data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin +1 -0
- data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd +1 -0
- data/spec/fixtures/{uptime → unit/util/uptime}/ubuntu_proc_uptime +0 -0
- data/spec/fixtures/{uptime → unit/util/uptime}/who_b_boottime +0 -0
- data/spec/{unit/data → fixtures/unit/util/vlans}/linux_vlan_config +0 -0
- data/spec/{unit/data → fixtures/unit/util/xendomains}/xendomains +0 -0
- data/spec/integration/facter_spec.rb +2 -2
- data/spec/puppetlabs_spec/files.rb +57 -0
- data/spec/puppetlabs_spec/fixtures.rb +49 -0
- data/spec/puppetlabs_spec/matchers.rb +87 -0
- data/spec/puppetlabs_spec_helper.rb +25 -0
- data/spec/spec_helper.rb +9 -12
- data/spec/unit/architecture_spec.rb +2 -4
- data/spec/unit/domain_spec.rb +3 -1
- data/spec/unit/ec2_spec.rb +140 -0
- data/spec/unit/facter_spec.rb +2 -2
- data/spec/unit/hardwareisa_spec.rb +34 -0
- data/spec/unit/hostname_spec.rb +3 -1
- data/spec/unit/id_spec.rb +2 -2
- data/spec/unit/interfaces_spec.rb +2 -4
- data/spec/unit/ipaddress6_spec.rb +4 -7
- data/spec/unit/lsbmajdistrelease_spec.rb +13 -0
- data/spec/unit/macaddress_spec.rb +4 -7
- data/spec/unit/memory_spec.rb +11 -6
- data/spec/unit/operatingsystem_spec.rb +101 -69
- data/spec/unit/operatingsystemrelease_spec.rb +2 -4
- data/spec/unit/physicalprocessorcount_spec.rb +1 -1
- data/spec/unit/processor_spec.rb +32 -35
- data/spec/unit/selinux_spec.rb +5 -10
- data/spec/unit/uniqueid_spec.rb +27 -0
- data/spec/unit/uptime_spec.rb +2 -4
- data/spec/unit/util/collection_spec.rb +12 -3
- data/spec/unit/util/config_spec.rb +24 -0
- data/spec/unit/util/confine_spec.rb +2 -3
- data/spec/unit/util/ec2_spec.rb +112 -0
- data/spec/unit/util/fact_spec.rb +2 -3
- data/spec/unit/util/ip_spec.rb +27 -55
- data/spec/unit/util/loader_spec.rb +2 -4
- data/spec/unit/util/macaddress_spec.rb +4 -5
- data/spec/unit/util/macosx_spec.rb +2 -3
- data/spec/unit/util/manufacturer_spec.rb +8 -9
- data/spec/unit/util/processor_spec.rb +8 -10
- data/spec/unit/util/resolution_spec.rb +2 -3
- data/spec/unit/util/uptime_spec.rb +15 -14
- data/spec/unit/util/virtual_spec.rb +10 -2
- data/spec/unit/util/vlans_spec.rb +3 -5
- data/spec/unit/util/wmi_spec.rb +2 -3
- data/spec/unit/util/xendomains_spec.rb +3 -5
- data/spec/unit/virtual_spec.rb +48 -18
- metadata +44 -28
- data/spec/fixtures/uptime/sysctl_kern_boottime_big_endian +0 -0
- data/spec/fixtures/uptime/sysctl_kern_boottime_little_endian +0 -0
data/CHANGELOG
CHANGED
@@ -1,6 +1,38 @@
|
|
1
|
+
1.6.5
|
2
|
+
===
|
3
|
+
71d3d3d (#12077) Add pciutils RPM dependency
|
4
|
+
1df5b46 (#11566) Add windows support for ec2 facts
|
5
|
+
d1a33e5 (#11848) Don't hard code ruby install paths in Windows batch files
|
6
|
+
14cad7e Build a Rake task for building Apple Packages
|
7
|
+
5a60ca6 (#11559) Switch to RbConfig & Provide alias for RbConfig for pre-1.8.5
|
8
|
+
88c9429 (#10271) Identifying 'Amazon' using '/etc/system-release'
|
9
|
+
2de7b84 (#11661) EC2 rspec tests were using throw not raise to simulate a timeout
|
10
|
+
b51ccf0 (#11583) Add basic coverage to the ec2 fact
|
11
|
+
82692ba (#9599) Generalize zone detection
|
12
|
+
e6cebd3 (#9599) Add nexenta facts
|
13
|
+
9401b78 (#11583) Switch request method to open-uri monkey patch 'open'
|
14
|
+
3ccac87 (#9708) Amend requires in specs to use simple requires
|
15
|
+
b0b5282 (#9708) Confine facts by kernel not operating system and remove confine for hardwareisa
|
16
|
+
c473e3f (#10309) Remove the with_verbose_disabled method
|
17
|
+
a99d87c (#10309) Rename tmpfile to tmpfilename to make function clear
|
18
|
+
d50fc48 (#10309) Move all fixture data in spec/unit/data to spec/fixtures
|
19
|
+
d6e8523 (#10309) Integrate new PuppetlabsSpec helpers into our existing facter spec code and general spec cleanup
|
20
|
+
c1604c7 (#10309) Add puppetlabs_spec helper library based on Puppets own puppet_spec helpers
|
21
|
+
d141e7e (maint) Fix requirement for FileUtils as operatingsystem_spec needs it now
|
22
|
+
9c224d3 (#11436) Unify memorysize and memorytotal facts
|
23
|
+
5c6322a (maint) Joined conditional statements for domain
|
24
|
+
a1dba38 (#11196) Scan all arp entries for an ec2 mac
|
25
|
+
5cd30eb (#8279) Join ec2 fact output with commas
|
26
|
+
4633996 (#9789) Extend coverage of operatingsystem specs
|
27
|
+
6d21f90 Move Linux specific virtual tests to correct block.
|
28
|
+
cb4e294 (#7753) Added error checking when adding resolves
|
29
|
+
6201820 (maint) remove redundant arch detection
|
30
|
+
4f9da1c (#11328) Fix uptime detection on OpenBSD
|
31
|
+
3f99f16 (#11328) Add virtualisation detection for OpenBSD
|
32
|
+
|
1
33
|
1.6.4
|
2
34
|
===
|
3
|
-
6406c8f (
|
35
|
+
6406c8f (#11041) Add dmidecode as a requirement for rpm
|
4
36
|
ed81492 (#10444) Add identification of system boards to Facter
|
5
37
|
bdbb2da (#10885) Malformed facter.bat when ruby dir contains backreferences
|
6
38
|
0bad18b (#10490) Handle case where no macaddress can be found
|
data/conf/redhat/facter.spec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
%{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]'
|
1
|
+
%{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Object.const_get(defined?(RbConfig) ? :RbConfig : :Config)::CONFIG["sitelibdir"]'
|
2
2
|
|
3
3
|
%define has_ruby_abi 0%{?fedora} || 0%{?rhel} >= 5
|
4
4
|
%define has_ruby_noarch %has_ruby_abi
|
@@ -22,6 +22,7 @@ BuildArch: noarch
|
|
22
22
|
Requires: ruby >= 1.8.1
|
23
23
|
Requires: which
|
24
24
|
Requires: dmidecode
|
25
|
+
Requires: pciutils
|
25
26
|
%if %has_ruby_abi
|
26
27
|
Requires: ruby(abi) = 1.8
|
27
28
|
%endif
|
data/install.rb
CHANGED
@@ -46,6 +46,12 @@ rescue LoadError
|
|
46
46
|
$haverdoc = false
|
47
47
|
end
|
48
48
|
|
49
|
+
# Monkey patch RbConfig->Config for Rubies older then 1.8.5.
|
50
|
+
unless defined? ::RbConfig
|
51
|
+
require 'rbconfig'
|
52
|
+
::RbConfig = ::Config
|
53
|
+
end
|
54
|
+
|
49
55
|
begin
|
50
56
|
if $haverdoc
|
51
57
|
rst2man = %x{which rst2man.py}
|
@@ -180,16 +186,16 @@ def prepare_installation
|
|
180
186
|
opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
|
181
187
|
InstallOptions.destdir = destdir
|
182
188
|
end
|
183
|
-
opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides
|
189
|
+
opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides RbConfig::CONFIG["bindir"]') do |bindir|
|
184
190
|
InstallOptions.bindir = bindir
|
185
191
|
end
|
186
|
-
opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides
|
192
|
+
opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides RbConfig::CONFIG["sbindir"]') do |sbindir|
|
187
193
|
InstallOptions.sbindir = sbindir
|
188
194
|
end
|
189
|
-
opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides
|
195
|
+
opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides RbConfig::CONFIG["sitelibdir"]') do |sitelibdir|
|
190
196
|
InstallOptions.sitelibdir = sitelibdir
|
191
197
|
end
|
192
|
-
opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides
|
198
|
+
opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides RbConfig::CONFIG["mandir"]') do |mandir|
|
193
199
|
InstallOptions.mandir = mandir
|
194
200
|
end
|
195
201
|
opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
|
@@ -213,8 +219,8 @@ def prepare_installation
|
|
213
219
|
|
214
220
|
tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."]
|
215
221
|
|
216
|
-
version = [
|
217
|
-
libdir = File.join(
|
222
|
+
version = [RbConfig::CONFIG["MAJOR"], RbConfig::CONFIG["MINOR"]].join(".")
|
223
|
+
libdir = File.join(RbConfig::CONFIG["libdir"], "ruby", version)
|
218
224
|
|
219
225
|
# Mac OS X 10.5 and higher declare bindir and sbindir as
|
220
226
|
# /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
|
@@ -222,26 +228,26 @@ def prepare_installation
|
|
222
228
|
# which is not generally where people expect executables to be installed
|
223
229
|
# These settings are appropriate defaults for all OS X versions.
|
224
230
|
if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/
|
225
|
-
|
226
|
-
|
231
|
+
RbConfig::CONFIG['bindir'] = "/usr/bin"
|
232
|
+
RbConfig::CONFIG['sbindir'] = "/usr/sbin"
|
227
233
|
end
|
228
234
|
|
229
235
|
if not InstallOptions.bindir.nil?
|
230
236
|
bindir = InstallOptions.bindir
|
231
237
|
else
|
232
|
-
bindir =
|
238
|
+
bindir = RbConfig::CONFIG['bindir']
|
233
239
|
end
|
234
240
|
|
235
241
|
if not InstallOptions.sbindir.nil?
|
236
242
|
sbindir = InstallOptions.sbindir
|
237
243
|
else
|
238
|
-
sbindir =
|
244
|
+
sbindir = RbConfig::CONFIG['sbindir']
|
239
245
|
end
|
240
246
|
|
241
247
|
if not InstallOptions.sitelibdir.nil?
|
242
248
|
sitelibdir = InstallOptions.sitelibdir
|
243
249
|
else
|
244
|
-
sitelibdir =
|
250
|
+
sitelibdir = RbConfig::CONFIG["sitelibdir"]
|
245
251
|
if sitelibdir.nil?
|
246
252
|
sitelibdir = $:.find { |x| x =~ /site_ruby/ }
|
247
253
|
if sitelibdir.nil?
|
@@ -255,7 +261,7 @@ def prepare_installation
|
|
255
261
|
if not InstallOptions.mandir.nil?
|
256
262
|
mandir = InstallOptions.mandir
|
257
263
|
else
|
258
|
-
mandir =
|
264
|
+
mandir = RbConfig::CONFIG['mandir']
|
259
265
|
end
|
260
266
|
|
261
267
|
# To be deprecated once people move over to using --destdir option
|
@@ -373,7 +379,7 @@ def run_tests(test_list)
|
|
373
379
|
end
|
374
380
|
|
375
381
|
##
|
376
|
-
# Install file(s) from ./bin to
|
382
|
+
# Install file(s) from ./bin to RbConfig::CONFIG['bindir']. Patch it on the way
|
377
383
|
# to insert a #! line; on a Unix install, the command is named as expected
|
378
384
|
# (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under
|
379
385
|
# windows, we add an '.rb' extension and let file associations do their stuff.
|
@@ -388,11 +394,11 @@ def install_binfile(from, op_file, target)
|
|
388
394
|
|
389
395
|
fail "Cannot find a temporary directory" unless tmp_dir
|
390
396
|
tmp_file = File.join(tmp_dir, '_tmp')
|
391
|
-
ruby = File.join(
|
397
|
+
ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
392
398
|
|
393
399
|
File.open(from) do |ip|
|
394
400
|
File.open(tmp_file, "w") do |op|
|
395
|
-
ruby = File.join(
|
401
|
+
ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
396
402
|
op.puts "#!#{ruby}"
|
397
403
|
contents = ip.readlines
|
398
404
|
if contents[0] =~ /^#!/
|
@@ -417,16 +423,12 @@ def install_binfile(from, op_file, target)
|
|
417
423
|
|
418
424
|
if not installed_wrapper
|
419
425
|
tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
|
420
|
-
cwn = File.join(Config::CONFIG['bindir'], op_file)
|
421
426
|
cwv = <<-EOS
|
422
427
|
@echo off
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
#{ruby} -x "#{cwn}" %*
|
428
|
-
goto done
|
429
|
-
:done
|
428
|
+
setlocal
|
429
|
+
set RUBY_BIN=%~dp0
|
430
|
+
set RUBY_BIN=%RUBY_BIN:\\=/%
|
431
|
+
"%RUBY_BIN%ruby.exe" -x "%RUBY_BIN%facter" %*
|
430
432
|
EOS
|
431
433
|
File.open(tmp_file2, "w") { |cw| cw.puts cwv }
|
432
434
|
FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
|
data/lib/facter.rb
CHANGED
@@ -20,11 +20,12 @@ module Facter
|
|
20
20
|
|
21
21
|
require 'facter/util/fact'
|
22
22
|
require 'facter/util/collection'
|
23
|
+
require 'facter/util/monkey_patches'
|
23
24
|
|
24
25
|
include Comparable
|
25
26
|
include Enumerable
|
26
27
|
|
27
|
-
FACTERVERSION = '1.6.
|
28
|
+
FACTERVERSION = '1.6.5'
|
28
29
|
# = Facter
|
29
30
|
# Functions as a hash of 'facts' you might care about about your
|
30
31
|
# system, such as mac address, IP address, Video card, etc.
|
data/lib/facter/domain.rb
CHANGED
@@ -23,12 +23,12 @@ Facter.add(:domain) do
|
|
23
23
|
# Get the domain from various sources; the order of these
|
24
24
|
# steps is important
|
25
25
|
|
26
|
-
if name = Facter::Util::Resolution.exec('hostname')
|
27
|
-
name =~ /.*?\.(.+$)/
|
26
|
+
if name = Facter::Util::Resolution.exec('hostname') \
|
27
|
+
and name =~ /.*?\.(.+$)/
|
28
28
|
|
29
29
|
$1
|
30
|
-
elsif domain = Facter::Util::Resolution.exec('dnsdomainname')
|
31
|
-
domain =~ /.+\..+/
|
30
|
+
elsif domain = Facter::Util::Resolution.exec('dnsdomainname') \
|
31
|
+
and domain =~ /.+\..+/
|
32
32
|
|
33
33
|
domain
|
34
34
|
elsif FileTest.exists?("/etc/resolv.conf")
|
data/lib/facter/ec2.rb
CHANGED
@@ -1,20 +1,5 @@
|
|
1
|
-
|
2
|
-
# Additional work from KurtBe
|
3
|
-
# Additional work for Paul Nasrat
|
4
|
-
# Additional work modelled on Ohai EC2 fact
|
5
|
-
|
1
|
+
require 'facter/util/ec2'
|
6
2
|
require 'open-uri'
|
7
|
-
require 'timeout'
|
8
|
-
|
9
|
-
def can_connect?(wait_sec=2)
|
10
|
-
url = "http://169.254.169.254:80/"
|
11
|
-
Timeout::timeout(wait_sec) {open(url)}
|
12
|
-
return true
|
13
|
-
rescue Timeout::Error
|
14
|
-
return false
|
15
|
-
rescue
|
16
|
-
return false
|
17
|
-
end
|
18
3
|
|
19
4
|
def metadata(id = "")
|
20
5
|
open("http://169.254.169.254/2008-02-01/meta-data/#{id||=''}").read.
|
@@ -23,9 +8,8 @@ def metadata(id = "")
|
|
23
8
|
if key[-1..-1] != '/'
|
24
9
|
value = open("http://169.254.169.254/2008-02-01/meta-data/#{key}").read.
|
25
10
|
split("\n")
|
26
|
-
value = value.size>1 ? value : value.first
|
27
11
|
symbol = "ec2_#{key.gsub(/\-|\//, '_')}".to_sym
|
28
|
-
Facter.add(symbol) { setcode { value } }
|
12
|
+
Facter.add(symbol) { setcode { value.join(',') } }
|
29
13
|
else
|
30
14
|
metadata(key)
|
31
15
|
end
|
@@ -34,21 +18,15 @@ end
|
|
34
18
|
|
35
19
|
def userdata()
|
36
20
|
begin
|
37
|
-
|
38
|
-
|
21
|
+
value = open("http://169.254.169.254/2008-02-01/user-data/").read.split
|
22
|
+
Facter.add(:ec2_userdata) { setcode { value } }
|
39
23
|
rescue OpenURI::HTTPError
|
40
24
|
end
|
41
25
|
end
|
42
26
|
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def has_ec2_arp?
|
48
|
-
!!(Facter.value(:arp) == "fe:ff:ff:ff:ff:ff")
|
49
|
-
end
|
27
|
+
if (Facter::Util::EC2.has_euca_mac? || Facter::Util::EC2.has_ec2_arp?) &&
|
28
|
+
Facter::Util::EC2.can_connect?
|
50
29
|
|
51
|
-
if (has_euca_mac? || has_ec2_arp?) && can_connect?
|
52
30
|
metadata
|
53
31
|
userdata
|
54
32
|
else
|
data/lib/facter/hardwareisa.rb
CHANGED
data/lib/facter/hardwaremodel.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
require 'facter'
|
16
16
|
|
17
17
|
Facter.add("lsbmajdistrelease") do
|
18
|
-
confine :
|
18
|
+
confine :kernel => %w{Linux GNU/kFreeBSD}
|
19
19
|
setcode do
|
20
20
|
if /(\d*)\./i =~ Facter.value(:lsbdistrelease)
|
21
21
|
result=$1
|
data/lib/facter/macaddress.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
require 'facter/util/macaddress'
|
11
11
|
|
12
12
|
Facter.add(:macaddress) do
|
13
|
-
confine :
|
13
|
+
confine :kernel => %w{SunOS Linux GNU/kFreeBSD}
|
14
14
|
setcode do
|
15
15
|
ether = []
|
16
16
|
output = Facter::Util::Resolution.exec("/sbin/ifconfig -a")
|
data/lib/facter/memory.rb
CHANGED
@@ -116,7 +116,7 @@ if Facter.value(:kernel) == "OpenBSD"
|
|
116
116
|
|
117
117
|
Facter::Memory.vmstat_find_free_memory()
|
118
118
|
|
119
|
-
Facter.add("
|
119
|
+
Facter.add("memorysize") do
|
120
120
|
confine :kernel => :openbsd
|
121
121
|
memtotal = Facter::Util::Resolution.exec("sysctl hw.physmem | cut -d'=' -f2")
|
122
122
|
setcode do
|
@@ -153,7 +153,7 @@ if Facter.value(:kernel) == "Darwin"
|
|
153
153
|
|
154
154
|
Facter::Memory.vmstat_darwin_find_free_memory()
|
155
155
|
|
156
|
-
Facter.add("
|
156
|
+
Facter.add("memorysize") do
|
157
157
|
confine :kernel => :Darwin
|
158
158
|
memtotal = Facter::Util::Resolution.exec("sysctl hw.memsize | cut -d':' -f2")
|
159
159
|
setcode do
|
@@ -220,7 +220,7 @@ if Facter.value(:kernel) == "windows"
|
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
-
Facter.add("
|
223
|
+
Facter.add("memorysize") do
|
224
224
|
confine :kernel => :windows
|
225
225
|
setcode do
|
226
226
|
mem = 0
|
@@ -254,7 +254,7 @@ Facter.add("SwapFree") do
|
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
|
-
Facter.add("
|
257
|
+
Facter.add("memorysize") do
|
258
258
|
confine :kernel => :dragonfly
|
259
259
|
setcode do
|
260
260
|
Facter::Memory.vmstat_find_free_memory()
|
@@ -262,3 +262,14 @@ Facter.add("MemoryTotal") do
|
|
262
262
|
Facter::Memory.scale_number(memtotal.to_f,"")
|
263
263
|
end
|
264
264
|
end
|
265
|
+
|
266
|
+
# http://projects.puppetlabs.com/issues/11436
|
267
|
+
#
|
268
|
+
# Unifying naming for the amount of physical memory in a given host.
|
269
|
+
# This fact is DEPRECATED and will be removed in Facter 2.0 per
|
270
|
+
# http://projects.puppetlabs.com/issues/11466
|
271
|
+
Facter.add("MemoryTotal") do
|
272
|
+
setcode do
|
273
|
+
Facter.value("memorysize")
|
274
|
+
end
|
275
|
+
end
|
@@ -14,7 +14,13 @@ require 'facter/lsb'
|
|
14
14
|
|
15
15
|
Facter.add(:operatingsystem) do
|
16
16
|
confine :kernel => :sunos
|
17
|
-
setcode do
|
17
|
+
setcode do
|
18
|
+
if FileTest.exists?("/etc/debian_version")
|
19
|
+
"Nexenta"
|
20
|
+
else
|
21
|
+
"Solaris"
|
22
|
+
end
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
Facter.add(:operatingsystem) do
|
@@ -44,8 +50,6 @@ Facter.add(:operatingsystem) do
|
|
44
50
|
else
|
45
51
|
"OEL"
|
46
52
|
end
|
47
|
-
elsif FileTest.exists?("/etc/arch-release")
|
48
|
-
"Arch"
|
49
53
|
elsif FileTest.exists?("/etc/vmware-release")
|
50
54
|
"VMWareESX"
|
51
55
|
elsif FileTest.exists?("/etc/redhat-release")
|
@@ -84,7 +88,7 @@ Facter.add(:operatingsystem) do
|
|
84
88
|
"Slackware"
|
85
89
|
elsif FileTest.exists?("/etc/alpine-release")
|
86
90
|
"Alpine"
|
87
|
-
elsif
|
91
|
+
elsif FileTest.exists?("/etc/system-release")
|
88
92
|
"Amazon"
|
89
93
|
end
|
90
94
|
end
|
data/lib/facter/osfamily.rb
CHANGED
data/lib/facter/uniqueid.rb
CHANGED
@@ -31,9 +31,8 @@ class Facter::Util::Collection
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
if block
|
35
|
-
resolve
|
36
|
-
# Set any resolve-appropriate options
|
34
|
+
if block_given? and resolve = fact.add(&block)
|
35
|
+
# If the resolve was actually added, set any resolve-appropriate options
|
37
36
|
options.each do |opt, value|
|
38
37
|
method = opt.to_s + "="
|
39
38
|
if resolve.respond_to?(method)
|
data/lib/facter/util/config.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
1
3
|
# A module to return config related data
|
2
4
|
#
|
3
5
|
module Facter::Util::Config
|
4
|
-
require 'rbconfig'
|
5
|
-
|
6
6
|
def self.is_windows?
|
7
|
-
|
7
|
+
RbConfig::CONFIG['host_os'] =~ /mswin|win32|dos|mingw|cygwin/i
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
# Provide a set of utility static methods that help with resolving the EC2
|
5
|
+
# fact.
|
6
|
+
module Facter::Util::EC2
|
7
|
+
class << self
|
8
|
+
# Test if we can connect to the EC2 api. Return true if able to connect.
|
9
|
+
# On failure this function fails silently and returns false.
|
10
|
+
#
|
11
|
+
# The +wait_sec+ parameter provides you with an adjustable timeout.
|
12
|
+
#
|
13
|
+
def can_connect?(wait_sec=2)
|
14
|
+
url = "http://169.254.169.254:80/"
|
15
|
+
Timeout::timeout(wait_sec) {open(url)}
|
16
|
+
return true
|
17
|
+
rescue Timeout::Error
|
18
|
+
return false
|
19
|
+
rescue
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
|
23
|
+
# Test if this host has a mac address used by Eucalyptus clouds, which
|
24
|
+
# normally is +d0:0d+.
|
25
|
+
def has_euca_mac?
|
26
|
+
!!(Facter.value(:macaddress) =~ %r{^[dD]0:0[dD]:})
|
27
|
+
end
|
28
|
+
|
29
|
+
# Test if the host has an arp entry in its cache that matches the EC2 arp,
|
30
|
+
# which is normally +fe:ff:ff:ff:ff:ff+.
|
31
|
+
def has_ec2_arp?
|
32
|
+
mac_address = "fe:ff:ff:ff:ff:ff"
|
33
|
+
if Facter.value(:kernel) == 'windows'
|
34
|
+
arp_command = "arp -a"
|
35
|
+
mac_address.gsub!(":","-")
|
36
|
+
else
|
37
|
+
arp_command = "arp -an"
|
38
|
+
end
|
39
|
+
|
40
|
+
arp_table = Facter::Util::Resolution.exec(arp_command)
|
41
|
+
if not arp_table.nil?
|
42
|
+
arp_table.each_line do |line|
|
43
|
+
return true if line.include?(mac_address)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|