facter 1.6.18 → 1.7.0.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.

Files changed (126) hide show
  1. data/Gemfile +23 -8
  2. data/bin/facter +4 -1
  3. data/ext/build_defaults.yaml +1 -1
  4. data/ext/debian/changelog.erb +4 -22
  5. data/ext/debian/control +2 -2
  6. data/ext/project_data.yaml +1 -1
  7. data/ext/redhat/facter.spec.erb +10 -9
  8. data/install.rb +27 -53
  9. data/lib/facter.rb +23 -5
  10. data/lib/facter/application.rb +21 -0
  11. data/lib/facter/blockdevices.rb +105 -0
  12. data/lib/facter/domain.rb +19 -7
  13. data/lib/facter/filesystems.rb +38 -0
  14. data/lib/facter/hardwaremodel.rb +3 -2
  15. data/lib/facter/ipaddress6.rb +1 -2
  16. data/lib/facter/kernelrelease.rb +10 -2
  17. data/lib/facter/ldom.rb +47 -0
  18. data/lib/facter/macaddress.rb +1 -1
  19. data/lib/facter/manufacturer.rb +7 -1
  20. data/lib/facter/memory.rb +58 -160
  21. data/lib/facter/operatingsystem.rb +17 -2
  22. data/lib/facter/operatingsystemmajrelease.rb +33 -0
  23. data/lib/facter/operatingsystemrelease.rb +88 -37
  24. data/lib/facter/osfamily.rb +6 -2
  25. data/lib/facter/processor.rb +2 -2
  26. data/lib/facter/ps.rb +5 -0
  27. data/lib/facter/ssh.rb +50 -12
  28. data/lib/facter/util/cfpropertylist.rb +6 -0
  29. data/lib/facter/util/cfpropertylist/LICENSE +19 -0
  30. data/lib/facter/util/cfpropertylist/README +44 -0
  31. data/lib/facter/util/cfpropertylist/Rakefile +44 -0
  32. data/lib/facter/util/cfpropertylist/THANKS +7 -0
  33. data/lib/facter/util/cfpropertylist/lib/cfpropertylist.rb +6 -0
  34. data/lib/facter/util/cfpropertylist/lib/rbBinaryCFPropertyList.rb +562 -0
  35. data/lib/facter/util/cfpropertylist/lib/rbCFPlistError.rb +26 -0
  36. data/lib/facter/util/cfpropertylist/lib/rbCFPropertyList.rb +402 -0
  37. data/lib/facter/util/cfpropertylist/lib/rbCFTypes.rb +244 -0
  38. data/lib/facter/util/cfpropertylist/lib/rbLibXMLParser.rb +135 -0
  39. data/lib/facter/util/cfpropertylist/lib/rbNokogiriParser.rb +140 -0
  40. data/lib/facter/util/cfpropertylist/lib/rbREXMLParser.rb +136 -0
  41. data/lib/facter/util/collection.rb +36 -14
  42. data/lib/facter/util/composite_loader.rb +12 -0
  43. data/lib/facter/util/config.rb +36 -0
  44. data/lib/facter/util/confine.rb +1 -6
  45. data/lib/facter/util/directory_loader.rb +83 -0
  46. data/lib/facter/util/fact.rb +49 -42
  47. data/lib/facter/util/file_read.rb +32 -0
  48. data/lib/facter/util/ip.rb +2 -9
  49. data/lib/facter/util/loader.rb +16 -2
  50. data/lib/facter/util/macosx.rb +15 -2
  51. data/lib/facter/util/memory.rb +154 -27
  52. data/lib/facter/util/nothing_loader.rb +15 -0
  53. data/lib/facter/util/parser.rb +141 -0
  54. data/lib/facter/util/processor.rb +27 -35
  55. data/lib/facter/util/resolution.rb +97 -26
  56. data/lib/facter/util/solaris_zones.rb +153 -0
  57. data/lib/facter/util/virtual.rb +32 -3
  58. data/lib/facter/version.rb +72 -2
  59. data/lib/facter/virtual.rb +56 -3
  60. data/lib/facter/zfs_version.rb +10 -0
  61. data/lib/facter/zonename.rb +6 -0
  62. data/lib/facter/zones.rb +17 -0
  63. data/lib/facter/zpool_version.rb +10 -0
  64. data/spec/fixtures/ifconfig/ifconfig_net_tools_1.60.txt +19 -0
  65. data/spec/fixtures/ifconfig/ifconfig_ubuntu_1204.txt +16 -0
  66. data/spec/fixtures/ldom/ldom_v1 +6 -0
  67. data/spec/fixtures/unit/filesystems/linux +28 -0
  68. data/spec/fixtures/unit/util/manufacturer/intel_linux_dmidecode +549 -0
  69. data/spec/fixtures/unit/virtual/sysfs_dmi_entries_raw.txt +0 -0
  70. data/spec/fixtures/unit/zfs_version/freebsd_8.2 +14 -0
  71. data/spec/fixtures/unit/zfs_version/freebsd_9.0 +13 -0
  72. data/spec/fixtures/unit/zfs_version/linux-fuse_0.6.9 +14 -0
  73. data/spec/fixtures/unit/zfs_version/solaris_10 +10 -0
  74. data/spec/fixtures/unit/zfs_version/solaris_11 +12 -0
  75. data/spec/fixtures/unit/zpool_version/freebsd_8.2 +26 -0
  76. data/spec/fixtures/unit/zpool_version/freebsd_9.0 +38 -0
  77. data/spec/fixtures/unit/zpool_version/linux-fuse_0.6.9 +35 -0
  78. data/spec/fixtures/unit/zpool_version/solaris_10 +31 -0
  79. data/spec/fixtures/unit/zpool_version/solaris_11 +43 -0
  80. data/spec/integration/facter_spec.rb +12 -0
  81. data/spec/spec_helper.rb +9 -0
  82. data/spec/unit/architecture_spec.rb +1 -1
  83. data/spec/unit/blockdevices_spec.rb +109 -0
  84. data/spec/unit/domain_spec.rb +189 -81
  85. data/spec/unit/ec2_spec.rb +15 -8
  86. data/spec/unit/filesystems_spec.rb +50 -0
  87. data/spec/unit/hardwaremodel_spec.rb +8 -1
  88. data/spec/unit/id_spec.rb +6 -5
  89. data/spec/unit/ipaddress6_spec.rb +14 -2
  90. data/spec/unit/ipaddress_spec.rb +1 -1
  91. data/spec/unit/kernel_spec.rb +24 -0
  92. data/spec/unit/kernelmajversion_spec.rb +17 -0
  93. data/spec/unit/kernelrelease_spec.rb +53 -0
  94. data/spec/unit/kernelversion_spec.rb +32 -0
  95. data/spec/unit/ldom_spec.rb +74 -0
  96. data/spec/unit/macaddress_spec.rb +3 -1
  97. data/spec/unit/manufacturer_spec.rb +115 -0
  98. data/spec/unit/memory_spec.rb +442 -75
  99. data/spec/unit/operatingsystem_spec.rb +16 -2
  100. data/spec/unit/operatingsystemmajrelease_spec.rb +16 -0
  101. data/spec/unit/operatingsystemrelease_spec.rb +110 -1
  102. data/spec/unit/processor_spec.rb +22 -7
  103. data/spec/unit/ps_spec.rb +42 -0
  104. data/spec/unit/ssh_spec.rb +76 -0
  105. data/spec/unit/util/collection_spec.rb +94 -118
  106. data/spec/unit/util/config_spec.rb +36 -5
  107. data/spec/unit/util/confine_spec.rb +31 -43
  108. data/spec/unit/util/directory_loader_spec.rb +87 -0
  109. data/spec/unit/util/fact_spec.rb +37 -25
  110. data/spec/unit/util/file_read_spec.rb +29 -0
  111. data/spec/unit/util/ip_spec.rb +4 -2
  112. data/spec/unit/util/loader_spec.rb +102 -45
  113. data/spec/unit/util/macosx_spec.rb +40 -9
  114. data/spec/unit/util/manufacturer_spec.rb +12 -1
  115. data/spec/unit/util/parser_spec.rb +135 -0
  116. data/spec/unit/util/resolution_spec.rb +136 -4
  117. data/spec/unit/util/solaris_zones_spec.rb +127 -0
  118. data/spec/unit/util/virtual_spec.rb +54 -0
  119. data/spec/unit/version_spec.rb +42 -0
  120. data/spec/unit/virtual_spec.rb +102 -27
  121. data/spec/unit/zfs_version_spec.rb +76 -0
  122. data/spec/unit/zonename_spec.rb +14 -0
  123. data/spec/unit/zones_spec.rb +55 -0
  124. data/spec/unit/zpool_version_spec.rb +76 -0
  125. metadata +113 -11
  126. data/lib/facter/arp.rb +0 -28
data/Gemfile CHANGED
@@ -1,16 +1,31 @@
1
- source "https://rubygems.org"
1
+ if gem_source = ENV['GEM_SOURCE']
2
+ source gem_source
3
+ else
4
+ source "https://rubygems.org"
5
+ end
2
6
 
3
- group :development do
4
- gem 'watchr'
7
+ # C Ruby (MRI) or Rubinius, but NOT Windows
8
+ platforms :ruby do
9
+ gem 'watchr', :group => :development
10
+ gem 'pry', :group => :development
11
+ gem 'yard', :group => :development
12
+ gem 'redcarpet', :group => :development
5
13
  end
6
14
 
7
15
  group :development, :test do
8
16
  gem 'rake'
9
- gem 'facter', ">= 1.0.0", :path => File.expand_path("..", __FILE__), :require => false
10
- gem 'rspec', "~> 2.11.0", :require => false
11
- gem 'mocha', "~> 0.10.5", :require => false
12
- gem 'json', "~> 1.7", :require => false
13
- gem 'puppetlabs_spec_helper', :require => false
17
+ gem 'facter', ">= 1.0.0", :path => File.expand_path("..", __FILE__)
18
+ gem 'rspec', "~> 2.11.0"
19
+ gem 'mocha', "~> 0.10.5"
20
+ gem 'json', "~> 1.7"
21
+ gem 'puppetlabs_spec_helper'
22
+ end
23
+
24
+ platform :mswin, :mingw do
25
+ gem "win32-api", "~> 1.4.8"
26
+ gem "win32-dir", "~> 0.3.7"
27
+ gem "windows-api", "~> 0.4.1"
28
+ gem "windows-pr", "~> 1.2.1"
14
29
  end
15
30
 
16
31
  if File.exists? "#{__FILE__}.local"
data/bin/facter CHANGED
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # = Usage
8
8
  #
9
- # facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [fact] [fact] [...]
9
+ # facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [--external-dir DIR] [--no-external-dir] [fact] [fact] [...]
10
10
  #
11
11
  # = Description
12
12
  #
@@ -42,6 +42,9 @@
42
42
  # timing::
43
43
  # Enable timing.
44
44
  #
45
+ # facts.d::
46
+ # The directory to use for external facts.
47
+ #
45
48
  # = Example
46
49
  #
47
50
  # facter kernel
@@ -2,7 +2,7 @@
2
2
  packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master'
3
3
  packaging_repo: 'packaging'
4
4
  default_cow: 'base-squeeze-i386.cow'
5
- cows: 'base-lucid-i386.cow base-oneiric-i386.cow base-precise-i386.cow base-quantal-i386.cow base-sid-i386.cow base-squeeze-i386.cow base-stable-i386.cow base-testing-i386.cow base-unstable-i386.cow base-wheezy-i386.cow'
5
+ cows: 'base-lucid-i386.cow base-lucid-amd64.cow base-oneiric-i386.cow base-oneiric-amd64.cow base-precise-i386.cow base-precise-amd64.cow base-quantal-i386.cow base-quantal-amd64.cow base-sid-i386.cow base-sid-amd64.cow base-squeeze-i386.cow base-squeeze-amd64.cow base-stable-i386.cow base-stable-amd64.cow base-testing-i386.cow base-testing-amd64.cow base-unstable-i386.cow base-unstable-amd64.cow base-wheezy-i386.cow base-wheezy-amd64.cow'
6
6
  pbuild_conf: '/etc/pbuilderrc'
7
7
  packager: 'puppetlabs'
8
8
  gpg_name: 'info@puppetlabs.com'
@@ -1,32 +1,14 @@
1
- facter (<%= @debversion %>) hardy lucid maverick natty oneiric unstable lenny sid wheezy lucid squeeze precise; urgency=low
1
+ facter (<%= @debversion %>) hardy lucid oneiric unstable sid wheezy lucid squeeze precise quantal; urgency=low
2
2
 
3
3
  * Update to version <% @debversion %>
4
4
 
5
5
  -- Puppet Labs Release <info@puppetlabs.com> <%= Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")%>
6
6
 
7
- facter (2.0.0-0.1rc4puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid wheezy lucid squeeze precise; urgency=low
7
+ facter (1.7.0-0.1rc1puppetlabs1) hardy lucid oneiric unstable sid wheezy lucid squeeze precise; urgency=low
8
8
 
9
- * Imported upstream 2.0.0rc4.
9
+ * Add dependency on virt-what to facter for better virutalization detection
10
10
 
11
- -- Moses Mendoza <moses@puppetlabs.com> Thu, 24 May 2012 17:09:25 +0000
12
-
13
- facter (2.0.0-0.1rc3puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid wheezy lucid squeeze precise; urgency=low
14
-
15
- * Imported upstream 2.0.0rc3.
16
-
17
- -- Moses Mendoza <moses@puppetlabs.com> Tue, 22 May 2012 11:48:25 +0000
18
-
19
- facter (2.0.0-0.1rc2puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid wheezy lucid squeeze precise; urgency=low
20
-
21
- * Imported upstream 2.0.0rc2.
22
-
23
- -- Moses Mendoza <moses@puppetlabs.com> Thu, 17 May 2012 13:15:25 +0000
24
-
25
- facter (2.0.0-0.1rc1puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid wheezy lucid squeeze precise; urgency=low
26
-
27
- * Imported upstream 2.0.0rc1. Updated debian/control to include ruby1.9 options.
28
-
29
- -- Matthaus Litteken <matthaus@puppetlabs.com> Tue, 15 May 2012 23:43:25 +0000
11
+ -- Matthaus Owens <matthaus@puppetlabs.com> Mon, 01 Apr 2013 13:11:30 +0000
30
12
 
31
13
  facter (1.6.8-1puppetlabs1) hardy lucid maverick natty oneiric unstable lenny sid wheezy lucid squeeze precise; urgency=low
32
14
 
@@ -7,8 +7,8 @@ Standards-Version: 3.9.1
7
7
  Homepage: http://www.puppetlabs.com
8
8
 
9
9
  Package: facter
10
- Architecture: all
11
- Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter, libopenssl-ruby | libopenssl-ruby1.8 | libopenssl-ruby1.9.1, dmidecode, pciutils
10
+ Architecture: any
11
+ Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter, libopenssl-ruby | libopenssl-ruby1.8 | libopenssl-ruby1.9.1, dmidecode [i386 amd64 ia64], virt-what, pciutils
12
12
  Description: Ruby module for collecting simple facts about a host operating system
13
13
  Some of the facts are preconfigured, such as the hostname and the operating
14
14
  system. Additional facts can be added through simple Ruby scripts.
@@ -7,7 +7,7 @@ summary: 'Facter, a system inventory tool'
7
7
  description: 'You can prove anything with facts!'
8
8
  version_file: 'lib/facter/version.rb'
9
9
  # files and gem_files are space separated lists
10
- files: '[A-Z]* acceptance bin documentation etc ext install.rb lib man spec'
10
+ files: '[A-Z]* acceptance bin documentation etc ext install.rb lib libexec man spec'
11
11
  gem_files: '[A-Z]* install.rb bin etc ext lib spec'
12
12
  gem_require_path: 'lib'
13
13
  gem_test_files: 'spec/**/*'
@@ -31,6 +31,7 @@ Requires: which
31
31
  Requires: dmidecode
32
32
  Requires: pciutils
33
33
  %endif
34
+ Requires: virt-what
34
35
  Requires: ruby(abi) >= 1.8
35
36
  BuildRequires: ruby >= 1.8.5
36
37
 
@@ -72,6 +73,9 @@ rm -rf %{buildroot}
72
73
  * <%= Time.now.strftime("%a %b %d %Y") %> Puppet Labs Release <info@puppetlabs.com> - 1:<%= @rpmversion %>-<%= @rpmrelease %>
73
74
  - Build for <%= @version %>
74
75
 
76
+ * Mon Apr 01 2013 Matthaus Owens <matthaus@puppetlabs.com> - 1:1.7.0-0.1rc1
77
+ - Add dependency on virt-what to facter for better virutalization detection
78
+
75
79
  * Wed Aug 08 2012 Moses Mendoza <moses@puppetlabs.com> - 1.6.11-2
76
80
  - Use correct ruby libdir for fedora 17 / ruby 1.9
77
81
 
@@ -84,17 +88,14 @@ rm -rf %{buildroot}
84
88
  * Sat Jul 07 2012 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.10-2
85
89
  - Attempt to build fro Ruby 1.9.3
86
90
 
87
- * Wed Jun 13 2012 Moses Mendoza <moses@puppetlabs.com> - 1.6.10-1
88
- - Update for 1.6.10
89
-
90
- * Fri Jun 8 2012 Moses Mendoza <moses@puppetlabs.com> - 1.6.10-0.1rc1.2
91
- - Bump epoch to 1 to address errant Facter 2.0 rc release
91
+ * Tue May 22 2012 Moses Mendoza <moses@puppetlabs.com> - 2.0.0-0.1rc3
92
+ - Update for 2.0.0rc3 release
92
93
 
93
- * Wed Jun 6 2012 Moses Mendoza <moses@puppetlabs.com> - 1.6.10-0.1rc1
94
- - Update for 1.6.10rc1
94
+ * Thu May 17 2012 Moses Mendoza <moses@puppetlabs.com> - 2.0.0-0.1rc2
95
+ - Update for 2.0.0rc2 release
95
96
 
96
- * Thu May 17 2012 Moses Mendoza <moses@puppetlabs.com> - 1.6.9-1
97
- - Update for 1.6.9
97
+ * Tue May 15 2012 Matthaus Litteken <matthaus@puppetlabs.com> - 2.0.0-0.1rc1
98
+ - Facter 2.0.0rc1 release
98
99
 
99
100
  * Thu May 10 2012 Matthaus Litteken <matthaus@puppetlabs.com> - 1.6.9-0.1rc1
100
101
  - Update for 1.6.9rc1
data/install.rb CHANGED
@@ -14,20 +14,17 @@
14
14
  #
15
15
  # bin/ # executable files -- "commands"
16
16
  # lib/ # the source of the library
17
- # tests/ # unit tests
18
17
  #
19
18
  # The default behaviour:
20
- # 1) Run all unit test files (ending in .rb) found in all directories under
21
- # tests/.
22
- # 2) Build Rdoc documentation from all files in bin/ (excluding .bat and .cmd),
19
+ # 1) Build Rdoc documentation from all files in bin/ (excluding .bat and .cmd),
23
20
  # all .rb files in lib/, ./README, ./ChangeLog, and ./Install.
24
- # 3) Build ri documentation from all files in bin/ (excluding .bat and .cmd),
21
+ # 2) Build ri documentation from all files in bin/ (excluding .bat and .cmd),
25
22
  # and all .rb files in lib/. This is disabled by default on Win32.
26
- # 4) Install commands from bin/ into the Ruby bin directory. On Windows, if a
23
+ # 3) Install commands from bin/ into the Ruby bin directory. On Windows, if a
27
24
  # if a corresponding batch file (.bat or .cmd) exists in the bin directory,
28
25
  # it will be copied over as well. Otherwise, a batch file (always .bat) will
29
26
  # be created to run the specified command.
30
- # 5) Install all library files ending in .rb from lib/ into Ruby's
27
+ # 4) Install all library files ending in .rb from lib/ into Ruby's
31
28
  # site_lib/version directory.
32
29
  #
33
30
  #++
@@ -59,7 +56,7 @@ rescue
59
56
  $haveman = false
60
57
  end
61
58
 
62
- $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
59
+ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
63
60
  require 'facter'
64
61
  @operatingsystem = Facter[:operatingsystem].value
65
62
 
@@ -74,14 +71,6 @@ def glob(list)
74
71
  g
75
72
  end
76
73
 
77
- # Set these values to what you want installed.
78
- bins = glob(%w{bin/*})
79
- rdoc = glob(%w{bin/* lib/**/*.rb README README-library TODO }).reject { |e| e=~ /\.(bat|cmd)$/ }
80
- ri = glob(%w(bin/*.rb lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ }
81
- man = glob(%w{man/man8/*})
82
- libs = glob(%w{lib/**/*.rb lib/**/*.py})
83
- tests = glob(%w{tests/**/*.rb})
84
-
85
74
  def do_bins(bins, target, strip = 's?bin/')
86
75
  bins.each do |bf|
87
76
  obf = bf.gsub(/#{strip}/, '')
@@ -91,7 +80,7 @@ end
91
80
 
92
81
  def do_libs(libs, strip = 'lib/')
93
82
  libs.each do |lf|
94
- olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
83
+ olf = File.join(InstallOptions.site_dir, lf.gsub(/^#{strip}/, ''))
95
84
  op = File.dirname(olf)
96
85
  FileUtils.makedirs(op, {:mode => 0755, :verbose => true})
97
86
  FileUtils.chmod(0755, op)
@@ -159,8 +148,6 @@ def prepare_installation
159
148
  InstallOptions.man = false
160
149
  end
161
150
 
162
- InstallOptions.tests = true
163
-
164
151
  ARGV.options do |opts|
165
152
  opts.banner = "Usage: #{File.basename($0)} [options]"
166
153
  opts.separator ""
@@ -173,8 +160,9 @@ def prepare_installation
173
160
  opts.on('--[no-]man', 'Presents the creation of man pages.', 'Default on.') do |onman|
174
161
  InstallOptions.man = onman
175
162
  end
176
- opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest|
163
+ opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default off.') do |ontest|
177
164
  InstallOptions.tests = ontest
165
+ warn "The tests flag has never worked in Facter, is deprecated as of Nov 29, 2012, and will be removed in a future release of Facter."
178
166
  end
179
167
  opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
180
168
  InstallOptions.destdir = destdir
@@ -194,12 +182,10 @@ def prepare_installation
194
182
  opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
195
183
  InstallOptions.rdoc = false
196
184
  InstallOptions.ri = false
197
- InstallOptions.tests = false
198
185
  end
199
186
  opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
200
187
  InstallOptions.rdoc = true
201
188
  InstallOptions.ri = true
202
- InstallOptions.tests = true
203
189
  end
204
190
  opts.separator("")
205
191
  opts.on_tail('--help', "Shows this help text.") do
@@ -332,27 +318,6 @@ def build_man(bins)
332
318
  end
333
319
  end
334
320
 
335
- def run_tests(test_list)
336
- begin
337
- require 'test/unit/ui/console/testrunner'
338
- $:.unshift "lib"
339
- test_list.each do |test|
340
- next if File.directory?(test)
341
- require test
342
- end
343
-
344
- tests = []
345
- ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
346
- tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
347
- tests.delete_if { |o| o == Test::Unit::TestCase }
348
-
349
- tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
350
- $:.shift
351
- rescue LoadError
352
- puts "Missing testrunner library; skipping tests"
353
- end
354
- end
355
-
356
321
  ##
357
322
  # Install file(s) from ./bin to RbConfig::CONFIG['bindir']. Patch it on the way
358
323
  # to insert a #! line; on a Unix install, the command is named as expected
@@ -409,13 +374,22 @@ EOS
409
374
  tmp_file.unlink
410
375
  end
411
376
 
412
- check_prereqs
413
- prepare_installation
414
-
415
- run_tests(tests) if InstallOptions.tests
416
- #build_rdoc(rdoc) if InstallOptions.rdoc
417
- #build_ri(ri) if InstallOptions.ri
418
- #build_man(bins) if InstallOptions.man
419
- do_bins(bins, InstallOptions.bin_dir)
420
- do_libs(libs)
421
- do_man(man)
377
+ # Change directory into the facter root so we don't get the wrong files for install.
378
+ FileUtils.cd File.dirname(__FILE__) do
379
+ # Set these values to what you want installed.
380
+ bins = glob(%w{bin/*})
381
+ rdoc = glob(%w{bin/* lib/**/*.rb README* }).reject { |e| e=~ /\.(bat|cmd)$/ }
382
+ ri = glob(%w(bin/*.rb lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ }
383
+ man = glob(%w{man/man8/*})
384
+ libs = glob(%w{lib/**/*.rb lib/**/*.py lib/**/LICENSE})
385
+
386
+ check_prereqs
387
+ prepare_installation
388
+
389
+ #build_rdoc(rdoc) if InstallOptions.rdoc
390
+ #build_ri(ri) if InstallOptions.ri
391
+ #build_man(bins) if InstallOptions.man
392
+ do_bins(bins, InstallOptions.bin_dir)
393
+ do_libs(libs)
394
+ do_man(man)
395
+ end
@@ -40,21 +40,20 @@ module Facter
40
40
  # puts Facter['operatingsystem']
41
41
  #
42
42
 
43
- # Set LANG to force i18n to C
44
- #
45
- ENV['LANG'] = 'C'
46
-
47
43
  GREEN = ""
48
44
  RESET = ""
49
45
  @@debug = 0
50
46
  @@timing = 0
51
47
  @@messages = {}
48
+ @@debug_messages = {}
52
49
 
53
50
  # module methods
54
51
 
55
52
  def self.collection
56
53
  unless defined?(@collection) and @collection
57
- @collection = Facter::Util::Collection.new
54
+ @collection = Facter::Util::Collection.new(
55
+ Facter::Util::Loader.new,
56
+ Facter::Util::Config.ext_fact_loader)
58
57
  end
59
58
  @collection
60
59
  end
@@ -69,6 +68,14 @@ module Facter
69
68
  end
70
69
  end
71
70
 
71
+ # Debug once.
72
+ def self.debugonce(msg)
73
+ if msg and not msg.empty? and @@debug_messages[msg].nil?
74
+ @@debug_messages[msg] = true
75
+ debug(msg)
76
+ end
77
+ end
78
+
72
79
  def self.debugging?
73
80
  @@debug != 0
74
81
  end
@@ -82,6 +89,17 @@ module Facter
82
89
  @@timing != 0
83
90
  end
84
91
 
92
+ # Facter.json? is meant to provide a lightweight way to check if the JSON
93
+ # "feature" is available.
94
+ def self.json?
95
+ begin
96
+ require 'json'
97
+ true
98
+ rescue LoadError
99
+ false
100
+ end
101
+ end
102
+
85
103
  # Return a fact object by name. If you use this, you still have to call
86
104
  # 'value' on it to retrieve the actual value.
87
105
  def self.[](name)
@@ -1,5 +1,21 @@
1
1
  module Facter
2
2
  module Application
3
+
4
+ require 'facter/util/nothing_loader'
5
+
6
+ def self.create_directory_loader(dir)
7
+ begin
8
+ Facter::Util::Config.ext_fact_loader = Facter::Util::DirectoryLoader.loader_for(dir)
9
+ rescue Facter::Util::DirectoryLoader::NoSuchDirectoryError => error
10
+ $stderr.puts "Specified external facts directory #{dir} does not exist."
11
+ exit(1)
12
+ end
13
+ end
14
+
15
+ def self.create_nothing_loader
16
+ Facter::Util::Config.ext_fact_loader = Facter::Util::NothingLoader.new
17
+ end
18
+
3
19
  def self.run(argv)
4
20
  require 'optparse'
5
21
  require 'facter'
@@ -9,6 +25,9 @@ module Facter
9
25
  # Accept fact names to return from the command line
10
26
  names = argv
11
27
 
28
+ # Change location of external facts dir
29
+ # Check here for valid ext_dir and exit program
30
+
12
31
  # Create the facts hash that is printed to standard out.
13
32
  unless names.empty?
14
33
  facts = {}
@@ -78,6 +97,8 @@ module Facter
78
97
  opts.on("-y", "--yaml") { |v| options[:yaml] = v }
79
98
  opts.on("-j", "--json") { |v| options[:json] = v }
80
99
  opts.on( "--trace") { |v| options[:trace] = v }
100
+ opts.on( "--external-dir DIR") { |v| create_directory_loader(v) }
101
+ opts.on( "--no-external-dir") { |v| create_nothing_loader }
81
102
  opts.on("-d", "--debug") { |v| Facter.debugging(1) }
82
103
  opts.on("-t", "--timing") { |v| Facter.timing(1) }
83
104
  opts.on("-p", "--puppet") { |v| load_puppet }
@@ -0,0 +1,105 @@
1
+ # Fact: blockdevice_<devicename>_size
2
+ #
3
+ # Purpose:
4
+ # Return the size of a block device in bytes
5
+ #
6
+ # Resolution:
7
+ # Parse the contents of /sys/block/<device>/size to receive the size (multiplying by 512 to correct for blocks-to-bytes)
8
+ #
9
+ # Caveats:
10
+ # Only supports Linux 2.6+ at this time, due to the reliance on sysfs
11
+ #
12
+
13
+ # Fact: blockdevice_<devicename>_vendor
14
+ #
15
+ # Purpose:
16
+ # Return the vendor name of block devices attached to the system
17
+ #
18
+ # Resolution:
19
+ # Parse the contents of /sys/block/<device>/device/vendor to retrieve the vendor for a device
20
+ #
21
+ # Caveats:
22
+ # Only supports Linux 2.6+ at this time, due to the reliance on sysfs
23
+ #
24
+
25
+ # Fact: blockdevice_<devicename>_model
26
+ #
27
+ # Purpose:
28
+ # Return the model name of block devices attached to the system
29
+ #
30
+ # Resolution:
31
+ # Parse the contents of /sys/block/<device>/device/model to retrieve the model name/number for a device
32
+ #
33
+ # Caveats:
34
+ # Only supports Linux 2.6+ at this time, due to the reliance on sysfs
35
+ #
36
+
37
+
38
+ # Fact: blockdevices
39
+ #
40
+ # Purpose:
41
+ # Return a comma seperated list of block devices
42
+ #
43
+ # Resolution:
44
+ # Retrieve the block devices that were identified and iterated over in the creation of the blockdevice_ facts
45
+ #
46
+ # Caveats:
47
+ # Block devices must have been identified using sysfs information
48
+ #
49
+
50
+ # Author: Jason Gill <jasongill@gmail.com>
51
+
52
+ require 'facter'
53
+
54
+ # Only Linux 2.6+ kernels support sysfs which is required to easily get device details
55
+ if Facter.value(:kernel) == 'Linux'
56
+
57
+ sysfs_block_directory = '/sys/block/'
58
+
59
+ blockdevices = []
60
+
61
+ # This should prevent any non-2.6 kernels or odd machines without sysfs support from being investigated further
62
+ if File.exist?(sysfs_block_directory)
63
+
64
+ # Iterate over each file in the /sys/block/ directory and skip ones that do not have a device subdirectory
65
+ Dir.entries(sysfs_block_directory).each do |device|
66
+ sysfs_device_directory = sysfs_block_directory + device + "/device"
67
+ next unless File.exist?(sysfs_device_directory)
68
+
69
+ # Add the device to the blockdevices list, which is returned as it's own fact later on
70
+ blockdevices << device
71
+
72
+ sizefile = sysfs_block_directory + device + "/size"
73
+ vendorfile = sysfs_device_directory + "/vendor"
74
+ modelfile = sysfs_device_directory + "/model"
75
+
76
+ if File.exist?(sizefile)
77
+ Facter.add("blockdevice_#{device}_size".to_sym) do
78
+ setcode { IO.read(sizefile).strip.to_i * 512 }
79
+ end
80
+ end
81
+
82
+ if File.exist?(vendorfile)
83
+ Facter.add("blockdevice_#{device}_vendor".to_sym) do
84
+ setcode { IO.read(vendorfile).strip }
85
+ end
86
+ end
87
+
88
+ if File.exist?(modelfile)
89
+ Facter.add("blockdevice_#{device}_model".to_sym) do
90
+ setcode { IO.read(modelfile).strip }
91
+ end
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+
98
+ # Return a comma-seperated list of block devices found
99
+ unless blockdevices.empty?
100
+ Facter.add(:blockdevices) do
101
+ setcode { blockdevices.sort.join(',') }
102
+ end
103
+ end
104
+
105
+ end