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.

Files changed (96) hide show
  1. data/CHANGELOG +33 -1
  2. data/conf/redhat/facter.spec +2 -1
  3. data/install.rb +25 -23
  4. data/lib/facter.rb +2 -1
  5. data/lib/facter/domain.rb +4 -4
  6. data/lib/facter/ec2.rb +6 -28
  7. data/lib/facter/hardwareisa.rb +0 -1
  8. data/lib/facter/hardwaremodel.rb +1 -1
  9. data/lib/facter/lsbmajdistrelease.rb +1 -1
  10. data/lib/facter/macaddress.rb +1 -1
  11. data/lib/facter/memory.rb +15 -4
  12. data/lib/facter/operatingsystem.rb +8 -4
  13. data/lib/facter/osfamily.rb +1 -1
  14. data/lib/facter/uniqueid.rb +1 -1
  15. data/lib/facter/util/collection.rb +2 -3
  16. data/lib/facter/util/config.rb +3 -3
  17. data/lib/facter/util/ec2.rb +49 -0
  18. data/lib/facter/util/fact.rb +12 -7
  19. data/lib/facter/util/monkey_patches.rb +7 -0
  20. data/lib/facter/util/uptime.rb +2 -2
  21. data/lib/facter/util/virtual.rb +1 -1
  22. data/lib/facter/virtual.rb +11 -1
  23. data/spec/{unit/data → fixtures/unit/selinux}/selinux_sestatus +0 -0
  24. data/spec/fixtures/unit/util/ec2/linux-arp-ec2.out +1 -0
  25. data/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out +5 -0
  26. data/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out +6 -0
  27. data/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out +10 -0
  28. data/spec/{unit/data → fixtures/unit/util/ip}/6.0-STABLE_FreeBSD_ifconfig +0 -0
  29. data/spec/{unit/data → fixtures/unit/util/ip}/Mac_OS_X_10.5.5_ifconfig +0 -0
  30. data/spec/{unit/data → fixtures/unit/util/ip}/darwin_ifconfig_all_with_multiple_interfaces +0 -0
  31. data/spec/{unit/data → fixtures/unit/util/ip}/darwin_ifconfig_single_interface +0 -0
  32. data/spec/{unit/data → fixtures/unit/util/ip}/debian_kfreebsd_ifconfig +0 -0
  33. data/spec/{unit/data → fixtures/unit/util/ip}/hpux_ifconfig_single_interface +0 -0
  34. data/spec/{unit/data → fixtures/unit/util/ip}/hpux_netstat_all_interfaces +0 -0
  35. data/spec/{unit/data → fixtures/unit/util/ip}/linux_ifconfig_all_with_single_interface +0 -0
  36. data/spec/{unit/data → fixtures/unit/util/ip}/solaris_ifconfig_all_with_multiple_interfaces +0 -0
  37. data/spec/{unit/data → fixtures/unit/util/ip}/solaris_ifconfig_single_interface +0 -0
  38. data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_all_interfaces +0 -0
  39. data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_single_interface +0 -0
  40. data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_single_interface6 +0 -0
  41. data/spec/{unit/data → fixtures/unit/util/manufacturer}/freebsd_dmidecode +0 -0
  42. data/spec/{unit/data → fixtures/unit/util/manufacturer}/linux_dmidecode_with_spaces +0 -0
  43. data/spec/{unit/data → fixtures/unit/util/manufacturer}/opensolaris_smbios +0 -0
  44. data/spec/fixtures/{uptime → unit/util/uptime}/kstat_boot_time +0 -0
  45. data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin +1 -0
  46. data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd +1 -0
  47. data/spec/fixtures/{uptime → unit/util/uptime}/ubuntu_proc_uptime +0 -0
  48. data/spec/fixtures/{uptime → unit/util/uptime}/who_b_boottime +0 -0
  49. data/spec/{unit/data → fixtures/unit/util/vlans}/linux_vlan_config +0 -0
  50. data/spec/{unit/data → fixtures/unit/util/xendomains}/xendomains +0 -0
  51. data/spec/integration/facter_spec.rb +2 -2
  52. data/spec/puppetlabs_spec/files.rb +57 -0
  53. data/spec/puppetlabs_spec/fixtures.rb +49 -0
  54. data/spec/puppetlabs_spec/matchers.rb +87 -0
  55. data/spec/puppetlabs_spec_helper.rb +25 -0
  56. data/spec/spec_helper.rb +9 -12
  57. data/spec/unit/architecture_spec.rb +2 -4
  58. data/spec/unit/domain_spec.rb +3 -1
  59. data/spec/unit/ec2_spec.rb +140 -0
  60. data/spec/unit/facter_spec.rb +2 -2
  61. data/spec/unit/hardwareisa_spec.rb +34 -0
  62. data/spec/unit/hostname_spec.rb +3 -1
  63. data/spec/unit/id_spec.rb +2 -2
  64. data/spec/unit/interfaces_spec.rb +2 -4
  65. data/spec/unit/ipaddress6_spec.rb +4 -7
  66. data/spec/unit/lsbmajdistrelease_spec.rb +13 -0
  67. data/spec/unit/macaddress_spec.rb +4 -7
  68. data/spec/unit/memory_spec.rb +11 -6
  69. data/spec/unit/operatingsystem_spec.rb +101 -69
  70. data/spec/unit/operatingsystemrelease_spec.rb +2 -4
  71. data/spec/unit/physicalprocessorcount_spec.rb +1 -1
  72. data/spec/unit/processor_spec.rb +32 -35
  73. data/spec/unit/selinux_spec.rb +5 -10
  74. data/spec/unit/uniqueid_spec.rb +27 -0
  75. data/spec/unit/uptime_spec.rb +2 -4
  76. data/spec/unit/util/collection_spec.rb +12 -3
  77. data/spec/unit/util/config_spec.rb +24 -0
  78. data/spec/unit/util/confine_spec.rb +2 -3
  79. data/spec/unit/util/ec2_spec.rb +112 -0
  80. data/spec/unit/util/fact_spec.rb +2 -3
  81. data/spec/unit/util/ip_spec.rb +27 -55
  82. data/spec/unit/util/loader_spec.rb +2 -4
  83. data/spec/unit/util/macaddress_spec.rb +4 -5
  84. data/spec/unit/util/macosx_spec.rb +2 -3
  85. data/spec/unit/util/manufacturer_spec.rb +8 -9
  86. data/spec/unit/util/processor_spec.rb +8 -10
  87. data/spec/unit/util/resolution_spec.rb +2 -3
  88. data/spec/unit/util/uptime_spec.rb +15 -14
  89. data/spec/unit/util/virtual_spec.rb +10 -2
  90. data/spec/unit/util/vlans_spec.rb +3 -5
  91. data/spec/unit/util/wmi_spec.rb +2 -3
  92. data/spec/unit/util/xendomains_spec.rb +3 -5
  93. data/spec/unit/virtual_spec.rb +48 -18
  94. metadata +44 -28
  95. data/spec/fixtures/uptime/sysctl_kern_boottime_big_endian +0 -0
  96. 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 (##11041) Add dmidecode as a requirement for rpm
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
@@ -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 Config::CONFIG["bindir"]') do |bindir|
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 Config::CONFIG["sbindir"]') do |sbindir|
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 Config::CONFIG["sitelibdir"]') do |sitelibdir|
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 Config::CONFIG["mandir"]') do |mandir|
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 = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
217
- libdir = File.join(Config::CONFIG["libdir"], "ruby", version)
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
- Config::CONFIG['bindir'] = "/usr/bin"
226
- Config::CONFIG['sbindir'] = "/usr/sbin"
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 = Config::CONFIG['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 = Config::CONFIG['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 = Config::CONFIG["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 = Config::CONFIG['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 Config::CONFIG['bindir']. Patch it on the way
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(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
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(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
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
- if "%OS%"=="Windows_NT" goto WinNT
424
- #{ruby} -x "#{cwn}" %1 %2 %3 %4 %5 %6 %7 %8 %9
425
- goto done
426
- :WinNT
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)
@@ -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.4'
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.
@@ -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') and
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') and
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")
@@ -1,20 +1,5 @@
1
- # Original fact Tim Dysinger
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
- value = OpenURI.open_uri("http://169.254.169.254/2008-02-01/user-data/").read.split
38
- Facter.add(:ec2_userdata) { setcode { value } }
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
- def has_euca_mac?
44
- !!(Facter.value(:macaddress) =~ %r{^[dD]0:0[dD]:})
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
@@ -12,5 +12,4 @@
12
12
 
13
13
  Facter.add(:hardwareisa) do
14
14
  setcode 'uname -p'
15
- confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD DragonFly OEL OracleLinux OVS GNU/kFreeBSD}
16
15
  end
@@ -29,6 +29,6 @@ Facter.add(:hardwaremodel) do
29
29
  confine :operatingsystem => :windows
30
30
  setcode do
31
31
  require 'rbconfig'
32
- Config::CONFIG['host_cpu']
32
+ RbConfig::CONFIG['host_cpu']
33
33
  end
34
34
  end
@@ -15,7 +15,7 @@
15
15
  require 'facter'
16
16
 
17
17
  Facter.add("lsbmajdistrelease") do
18
- confine :operatingsystem => %w{Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Ubuntu Gentoo OEL OracleLinux OVS GNU/kFreeBSD}
18
+ confine :kernel => %w{Linux GNU/kFreeBSD}
19
19
  setcode do
20
20
  if /(\d*)\./i =~ Facter.value(:lsbdistrelease)
21
21
  result=$1
@@ -10,7 +10,7 @@
10
10
  require 'facter/util/macaddress'
11
11
 
12
12
  Facter.add(:macaddress) do
13
- confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Gentoo Ubuntu OEL OracleLinux OVS GNU/kFreeBSD}
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")
@@ -116,7 +116,7 @@ if Facter.value(:kernel) == "OpenBSD"
116
116
 
117
117
  Facter::Memory.vmstat_find_free_memory()
118
118
 
119
- Facter.add("MemoryTotal") do
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("MemoryTotal") do
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("MemoryTotal") do
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("MemoryTotal") do
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 "Solaris" end
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 Facter.value(:lsbdistdescription) =~ /Amazon Linux/
91
+ elsif FileTest.exists?("/etc/system-release")
88
92
  "Amazon"
89
93
  end
90
94
  end
@@ -22,7 +22,7 @@ Facter.add(:osfamily) do
22
22
  "Debian"
23
23
  when "SLES", "SLED", "OpenSuSE", "SuSE"
24
24
  "Suse"
25
- when "Solaris"
25
+ when "Solaris", "Nexenta"
26
26
  "Solaris"
27
27
  else
28
28
  Facter.value("kernel")
@@ -1,4 +1,4 @@
1
1
  Facter.add(:uniqueid) do
2
2
  setcode 'hostid'
3
- confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Ubuntu Gentoo AIX OEL OracleLinux OVS GNU/kFreeBSD}
3
+ confine :kernel => %w{SunOS Linux AIX GNU/kFreeBSD}
4
4
  end
@@ -31,9 +31,8 @@ class Facter::Util::Collection
31
31
  end
32
32
  end
33
33
 
34
- if block
35
- resolve = fact.add(&block)
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)
@@ -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
- Config::CONFIG['host_os'] =~ /mswin|win32|dos|mingw|cygwin/i
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