Merge lp:~gandelman-a/ubuntu/precise/facter/lp888671 into lp:ubuntu/precise/facter
- Precise (12.04)
- lp888671
- Merge into precise
Status: | Merged |
---|---|
Merge reported by: | Dave Walker |
Merged at revision: | not available |
Proposed branch: | lp:~gandelman-a/ubuntu/precise/facter/lp888671 |
Merge into: | lp:ubuntu/precise/facter |
Diff against target: |
10595 lines (+6067/-3319) 94 files modified
.pc/.version (+1/-0) .pc/applied-patches (+1/-0) .pc/no-require-rubygems/lib/facter/application.rb (+123/-0) CHANGELOG (+31/-0) Rakefile (+41/-36) conf/redhat/facter.spec (+11/-4) conf/solaris/pkginfo (+1/-1) debian/changelog (+27/-6) debian/control (+2/-2) debian/patches/no-require-rubygems (+15/-0) debian/patches/series (+1/-0) debian/rules (+5/-2) install.rb (+314/-314) lib/facter.rb (+229/-229) lib/facter/Cfkey.rb (+24/-24) lib/facter/architecture.rb (+22/-30) lib/facter/domain.rb (+39/-39) lib/facter/facterversion.rb (+1/-1) lib/facter/fqdn.rb (+8/-8) lib/facter/hardwareisa.rb (+2/-2) lib/facter/hardwaremodel.rb (+19/-19) lib/facter/hostname.rb (+14/-14) lib/facter/id.rb (+3/-3) lib/facter/interfaces.rb (+13/-13) lib/facter/ipaddress.rb (+123/-123) lib/facter/iphostnumber.rb (+14/-14) lib/facter/kernel.rb (+7/-7) lib/facter/kernelmajversion.rb (+3/-3) lib/facter/kernelrelease.rb (+18/-18) lib/facter/kernelversion.rb (+5/-5) lib/facter/lsb.rb (+14/-14) lib/facter/lsbmajdistrelease.rb (+8/-8) lib/facter/macaddress.rb (+63/-63) lib/facter/macosx.rb (+26/-26) lib/facter/manufacturer.rb (+28/-28) lib/facter/memory.rb (+173/-145) lib/facter/netmask.rb (+4/-4) lib/facter/network.rb (+4/-4) lib/facter/operatingsystem.rb (+83/-79) lib/facter/operatingsystemrelease.rb (+113/-107) lib/facter/osfamily.rb (+31/-0) lib/facter/path.rb (+3/-3) lib/facter/physicalprocessorcount.rb (+8/-0) lib/facter/processor.rb (+103/-84) lib/facter/ps.rb (+3/-3) lib/facter/puppetversion.rb (+7/-7) lib/facter/rubysitedir.rb (+5/-5) lib/facter/rubyversion.rb (+1/-1) lib/facter/ssh.rb (+16/-16) lib/facter/timezone.rb (+3/-3) lib/facter/uniqueid.rb (+2/-2) lib/facter/util/collection.rb (+122/-122) lib/facter/util/confine.rb (+34/-34) lib/facter/util/fact.rb (+115/-115) lib/facter/util/ip.rb (+197/-197) lib/facter/util/loader.rb (+106/-106) lib/facter/util/macosx.rb (+52/-52) lib/facter/util/manufacturer.rb (+97/-97) lib/facter/util/memory.rb (+79/-79) lib/facter/util/netmask.rb (+38/-38) lib/facter/util/plist.rb (+1/-1) lib/facter/util/plist/generator.rb (+209/-209) lib/facter/util/plist/parser.rb (+204/-204) lib/facter/util/processor.rb (+88/-0) lib/facter/util/resolution.rb (+175/-175) lib/facter/util/uptime.rb (+59/-59) lib/facter/util/values.rb (+9/-9) lib/facter/util/virtual.rb (+81/-71) lib/facter/util/vlans.rb (+17/-17) lib/facter/virtual.rb (+126/-131) lib/facter/vlans.rb (+6/-6) spec/fixtures/cpuinfo/amd64dual (+57/-0) spec/fixtures/cpuinfo/amd64quad (+79/-0) spec/fixtures/cpuinfo/amd64solo (+23/-0) spec/fixtures/cpuinfo/amd64tri (+86/-0) spec/fixtures/cpuinfo/bbg3-armel (+12/-0) spec/fixtures/cpuinfo/beaglexm-armel (+12/-0) spec/fixtures/cpuinfo/panda-armel (+17/-0) spec/fixtures/cpuinfo/ppc64 (+19/-0) spec/fixtures/cpuinfo/sparc (+10/-0) spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info (+1216/-0) spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info (+225/-0) spec/integration/facter_spec.rb (+21/-21) spec/spec_helper.rb (+10/-1) spec/unit/architecture_spec.rb (+54/-0) spec/unit/domain_spec.rb (+23/-0) spec/unit/memory_spec.rb (+78/-1) spec/unit/physicalprocessorcount_spec.rb (+47/-41) spec/unit/processor_spec.rb (+184/-3) spec/unit/util/processor_spec.rb (+62/-0) spec/unit/util/uptime_spec.rb (+4/-4) spec/unit/util/virtual_spec.rb (+26/-5) spec/unit/virtual_spec.rb (+47/-2) spec/watchr.rb (+125/-0) |
To merge this branch: | bzr merge lp:~gandelman-a/ubuntu/precise/facter/lp888671 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dave Walker (community) | Approve | ||
Ubuntu branches | Pending | ||
Review via email: mp+81894@code.launchpad.net |
Commit message
Description of the change
facter (1.6.2-1ubuntu1) precise; urgency=low
* Merge from Debian testing (LP: #888671). Remaining changes:
- debian/rules: use what we had in natty; we dont want ruby-pkg-tools
in main. (LP: #408402)
- debian/control: Continue using ruby + libopenssl-ruby as Build-Depends
even tho Debian has moved to gem2deb (not in main). Move ruby-json to
Suggests.
-- Adam Gandelman <email address hidden> Thu, 10 Nov 2011 10:11:05 -0800
- 18. By Adam Gandelman
-
debian/rules: Add build-arch and build-indep targets to satisfy lintian
- 19. By Adam Gandelman
-
debian/rules: use dh_prep instead of dh_clean
- 20. By Adam Gandelman
-
debian/control: Update to debhelper >= 8
- 21. By Adam Gandelman
-
debian/control: Depend on ruby1.8 explicitly
- 22. By Adam Gandelman
-
* debian/rules: Use dh_prep instead of dh_clean, add build-arch + build-indep
targets
* debian/control: Update debhelper Build-Depends to 8, make binary package
depend on ruby1.8 explicitly.
Adam Gandelman (gandelman-a) wrote : | # |
Hi Dave-
I've pushed some changes that fix the lintian warnings (I'll get in the habit of catching those myself soon, I promise :)
As for the ruby 1.8/1.9.. It's true that, as currently packaged, facter won't function with only 1.9.1, even though it installs fine. I've set ruby1.8 as an explicit dependency because (as you pointed out) we're explicitly setting that elsewhere, and I don't anticipate any other ruby interpreter entering main that would satisfy "ruby (>= 1.8) , ruby (<< 1.9)" If that's not ideal, let me know!
Thanks.
Adam
Dave Walker (davewalker) wrote : | # |
Thanks for addressing those things. I did notice a couple of other things, if it was just 1 - i'd have just uploaded it, but these should probably be addressed.
Ah! But depending on ruby1.8, rather than a ruby (>=1.8) has introduced:
http://
debian/changelog: "we dont want ruby-pkg-tools" , should be s/dont/don't/ ?
Seems our delta has lost the manpage for /usr/bin/facter. :(
Thanks for your work on this.
- 23. By Adam Gandelman
-
Install man pages, fix typo in changelog
Adam Gandelman (gandelman-a) wrote : | # |
Dave-
The 'ruby-script-
Other two points resolved in latest push.
Thanks for the input
Adam
Dave Walker (davewalker) wrote : | # |
Great work, thanks Adam.
Lintian did report this on the binary, which isn't a blocker.. but also not clear where it's being created.
I: facter: package-
Uploaded!
Preview Diff
1 | === added directory '.pc' |
2 | === added file '.pc/.version' |
3 | --- .pc/.version 1970-01-01 00:00:00 +0000 |
4 | +++ .pc/.version 2011-11-14 19:37:34 +0000 |
5 | @@ -0,0 +1,1 @@ |
6 | +2 |
7 | |
8 | === added file '.pc/applied-patches' |
9 | --- .pc/applied-patches 1970-01-01 00:00:00 +0000 |
10 | +++ .pc/applied-patches 2011-11-14 19:37:34 +0000 |
11 | @@ -0,0 +1,1 @@ |
12 | +no-require-rubygems |
13 | |
14 | === added directory '.pc/no-require-rubygems' |
15 | === added directory '.pc/no-require-rubygems/lib' |
16 | === added directory '.pc/no-require-rubygems/lib/facter' |
17 | === added file '.pc/no-require-rubygems/lib/facter/application.rb' |
18 | --- .pc/no-require-rubygems/lib/facter/application.rb 1970-01-01 00:00:00 +0000 |
19 | +++ .pc/no-require-rubygems/lib/facter/application.rb 2011-11-14 19:37:34 +0000 |
20 | @@ -0,0 +1,123 @@ |
21 | +module Facter |
22 | + module Application |
23 | + def self.run(argv) |
24 | + require 'optparse' |
25 | + require 'facter' |
26 | + |
27 | + options = parse(argv) |
28 | + |
29 | + # Accept fact names to return from the command line |
30 | + names = argv |
31 | + |
32 | + # Create the facts hash that is printed to standard out. |
33 | + unless names.empty? |
34 | + facts = {} |
35 | + names.each do |name| |
36 | + begin |
37 | + facts[name] = Facter.value(name) |
38 | + rescue => error |
39 | + $stderr.puts "Could not retrieve #{name}: #{error}" |
40 | + exit 10 |
41 | + end |
42 | + end |
43 | + end |
44 | + |
45 | + # Print everything if they didn't ask for specific facts. |
46 | + facts ||= Facter.to_hash |
47 | + |
48 | + # Print the facts as YAML and exit |
49 | + if options[:yaml] |
50 | + require 'yaml' |
51 | + puts YAML.dump(facts) |
52 | + exit(0) |
53 | + end |
54 | + |
55 | + # Print the facts as JSON and exit |
56 | + if options[:json] |
57 | + begin |
58 | + require 'rubygems' |
59 | + require 'json' |
60 | + puts JSON.dump(facts) |
61 | + exit(0) |
62 | + rescue LoadError |
63 | + $stderr.puts "You do not have JSON support in your version of Ruby. JSON output disabled" |
64 | + exit(1) |
65 | + end |
66 | + end |
67 | + |
68 | + # Print the value of a single fact, otherwise print a list sorted by fact |
69 | + # name and separated by "=>" |
70 | + if facts.length == 1 |
71 | + if value = facts.values.first |
72 | + puts value |
73 | + end |
74 | + else |
75 | + facts.sort_by{ |fact| fact.first }.each do |name,value| |
76 | + puts "#{name} => #{value}" |
77 | + end |
78 | + end |
79 | + |
80 | + rescue => e |
81 | + if options && options[:trace] |
82 | + raise e |
83 | + else |
84 | + $stderr.puts "Error: #{e}" |
85 | + exit(12) |
86 | + end |
87 | + end |
88 | + |
89 | + private |
90 | + |
91 | + def self.parse(argv) |
92 | + options = {} |
93 | + OptionParser.new do |opts| |
94 | + opts.on("-y", "--yaml") { |v| options[:yaml] = v } |
95 | + opts.on("-j", "--json") { |v| options[:json] = v } |
96 | + opts.on( "--trace") { |v| options[:trace] = v } |
97 | + opts.on("-d", "--debug") { |v| Facter.debugging(1) } |
98 | + opts.on("-t", "--timing") { |v| Facter.timing(1) } |
99 | + opts.on("-p", "--puppet") { |v| load_puppet } |
100 | + |
101 | + opts.on_tail("-v", "--version") do |
102 | + puts Facter.version |
103 | + exit(0) |
104 | + end |
105 | + |
106 | + opts.on_tail("-h", "--help") do |
107 | + begin |
108 | + require 'rdoc/ri/ri_paths' |
109 | + require 'rdoc/usage' |
110 | + RDoc.usage # print usage and exit |
111 | + rescue LoadError |
112 | + $stderr.puts "No help available unless your RDoc has RDoc.usage" |
113 | + exit(1) |
114 | + rescue => e |
115 | + $stderr.puts "fatal: #{e}" |
116 | + exit(1) |
117 | + end |
118 | + end |
119 | + end.parse! |
120 | + |
121 | + options |
122 | + rescue OptionParser::InvalidOption => e |
123 | + $stderr.puts e.message |
124 | + exit(12) |
125 | + end |
126 | + |
127 | + def self.load_puppet |
128 | + require 'puppet' |
129 | + Puppet.parse_config |
130 | + |
131 | + # If you've set 'vardir' but not 'libdir' in your |
132 | + # puppet.conf, then the hook to add libdir to $: |
133 | + # won't get triggered. This makes sure that it's setup |
134 | + # correctly. |
135 | + unless $LOAD_PATH.include?(Puppet[:libdir]) |
136 | + $LOAD_PATH << Puppet[:libdir] |
137 | + end |
138 | + rescue LoadError => detail |
139 | + $stderr.puts "Could not load Puppet: #{detail}" |
140 | + end |
141 | + |
142 | + end |
143 | +end |
144 | |
145 | === modified file 'CHANGELOG' |
146 | --- CHANGELOG 2011-10-18 10:32:42 +0000 |
147 | +++ CHANGELOG 2011-11-14 19:37:34 +0000 |
148 | @@ -1,3 +1,34 @@ |
149 | +1.6.2 |
150 | +=== |
151 | +d7c00f6 (#9852) Fixing watchr on facter |
152 | +abf636e (#9555) Change all cases of tabs and 4 space indentation to 2 space indentation. |
153 | +db1b5af (#9830) Add sshecdsakey fact |
154 | +1b69791 (#9404) Add memory & update processor facts for DragonFly and OpenBSD. |
155 | +bce2c69 (#9404) De-clumsify CPU count detection and swap detection on OpenBSD. |
156 | +cd0ae15 (#9404) Efficiency cleanups for DragonFly facts. |
157 | +d5511f6 (#9404) Add cross-fact support to facter for DragonFly BSD. |
158 | +0dfc4e9 (#6728) Improve openvz/cloudlinux detection. |
159 | +2c5ad52 (#6728) Facter improperly detects openvzve on CloudLinux systems |
160 | +9101e46 (#7951) added OS support for Amazon Linux |
161 | +b3784f7 add operatingsystema and operatingsystemrelease support for cloudlinux |
162 | +8605bba (#9787) Change rspec format so we use the default, not document |
163 | +b579613 (#7726) Silence prtconf error message inside zones |
164 | +db3c606 (#9786) Add aliases: specs, tests, test in rake that points at 'spec'. |
165 | +dfda9be (#4980, #6470) Fix architecture in Darwin and Ubuntu |
166 | +8f938c1 (#6792) Added osfamily fact. |
167 | +af1ef43 (#6515) Fix for ruby-1.8.5. Switched use of 'line.each' to 'each_line'. |
168 | +328ff75 (#6515 and #2945) Fix processorcount for arm, sparc & ppc for linux. |
169 | +51329b8 (#3856) Detect VirtualBox on Darwin as well as Linux and SunOS |
170 | +83498b5 (#7996) Restrict solaris cpu processor detection |
171 | +6e29ff7 (#8615) ENV hash is now local to tests |
172 | +124a09b (#8240) Fixed regex pattern for domain |
173 | +fd93c5f (#7996) Add solaris processor facts |
174 | +3f1a163 (#9593) Require rubygems to handle json output for ruby 1.8.7. |
175 | +c4fe415 (#9295) Added spec tests for Hyper-V detection |
176 | +ea23417 (#9295) Initial detection of Hyper-V hypervisor |
177 | +82351ab Stub out OS and HW model to avoid test failures. Only stub vmware -v (don't expect it) since it needn't be invoked if we already identified Xen or something else. |
178 | +16a8cab (#2747) Fix detection of xen0 vs xenu in Xen 3.2. |
179 | + |
180 | 1.6.1 |
181 | === |
182 | 1f009e0 Updated CHANGELOG for 1.6.1rc4 |
183 | |
184 | === modified file 'Rakefile' |
185 | --- Rakefile 2011-10-18 10:32:42 +0000 |
186 | +++ Rakefile 2011-11-14 19:37:34 +0000 |
187 | @@ -7,7 +7,7 @@ |
188 | require 'rspec' |
189 | require 'rspec/core/rake_task' |
190 | begin |
191 | - require 'rcov' |
192 | + require 'rcov' |
193 | rescue LoadError |
194 | end |
195 | |
196 | @@ -18,60 +18,65 @@ |
197 | require 'rake/gempackagetask' |
198 | |
199 | module Facter |
200 | - FACTERVERSION = File.read('lib/facter.rb')[/FACTERVERSION *= *'(.*)'/,1] or fail "Couldn't find FACTERVERSION" |
201 | + FACTERVERSION = File.read('lib/facter.rb')[/FACTERVERSION *= *'(.*)'/,1] or fail "Couldn't find FACTERVERSION" |
202 | end |
203 | |
204 | FILES = FileList[ |
205 | - '[A-Z]*', |
206 | - 'install.rb', |
207 | - 'bin/**/*', |
208 | - 'lib/**/*', |
209 | - 'conf/**/*', |
210 | - 'etc/**/*', |
211 | - 'spec/**/*' |
212 | + '[A-Z]*', |
213 | + 'install.rb', |
214 | + 'bin/**/*', |
215 | + 'lib/**/*', |
216 | + 'conf/**/*', |
217 | + 'etc/**/*', |
218 | + 'spec/**/*' |
219 | ] |
220 | |
221 | spec = Gem::Specification.new do |spec| |
222 | - spec.platform = Gem::Platform::RUBY |
223 | - spec.name = 'facter' |
224 | - spec.files = FILES.to_a |
225 | - spec.executables = %w{facter} |
226 | - spec.version = Facter::FACTERVERSION |
227 | - spec.summary = 'Facter, a system inventory tool' |
228 | - spec.author = 'Puppet Labs' |
229 | - spec.email = 'info@puppetlabs.com' |
230 | - spec.homepage = 'http://puppetlabs.com' |
231 | - spec.rubyforge_project = 'facter' |
232 | - spec.has_rdoc = true |
233 | - spec.rdoc_options << |
234 | - '--title' << 'Facter - System Inventory Tool' << |
235 | - '--main' << 'README' << |
236 | - '--line-numbers' |
237 | + spec.platform = Gem::Platform::RUBY |
238 | + spec.name = 'facter' |
239 | + spec.files = FILES.to_a |
240 | + spec.executables = %w{facter} |
241 | + spec.version = Facter::FACTERVERSION |
242 | + spec.summary = 'Facter, a system inventory tool' |
243 | + spec.author = 'Puppet Labs' |
244 | + spec.email = 'info@puppetlabs.com' |
245 | + spec.homepage = 'http://puppetlabs.com' |
246 | + spec.rubyforge_project = 'facter' |
247 | + spec.has_rdoc = true |
248 | + spec.rdoc_options << |
249 | + '--title' << 'Facter - System Inventory Tool' << |
250 | + '--main' << 'README' << |
251 | + '--line-numbers' |
252 | end |
253 | |
254 | Rake::PackageTask.new("facter", Facter::FACTERVERSION) do |pkg| |
255 | - pkg.package_dir = 'pkg' |
256 | - pkg.need_tar_gz = true |
257 | - pkg.package_files = FILES.to_a |
258 | + pkg.package_dir = 'pkg' |
259 | + pkg.need_tar_gz = true |
260 | + pkg.package_files = FILES.to_a |
261 | end |
262 | |
263 | Rake::GemPackageTask.new(spec) do |pkg| |
264 | end |
265 | |
266 | task :default do |
267 | - sh %{rake -T} |
268 | + sh %{rake -T} |
269 | end |
270 | |
271 | +# Aliases for spec |
272 | +task :test => [:spec] |
273 | +task :tests => [:spec] |
274 | +task :specs => [:spec] |
275 | + |
276 | RSpec::Core::RakeTask.new do |t| |
277 | - t.pattern ='spec/{unit,integration}/**/*_spec.rb' |
278 | - t.fail_on_error = true |
279 | + t.pattern ='spec/{unit,integration}/**/*_spec.rb' |
280 | + t.fail_on_error = true |
281 | end |
282 | |
283 | RSpec::Core::RakeTask.new('spec:rcov') do |t| |
284 | - t.pattern ='spec/{unit,integration}/**/*_spec.rb' |
285 | - t.fail_on_error = true |
286 | - if defined?(Rcov) |
287 | - t.rcov = true |
288 | - t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*'] |
289 | - end |
290 | + t.pattern ='spec/{unit,integration}/**/*_spec.rb' |
291 | + t.fail_on_error = true |
292 | + if defined?(Rcov) |
293 | + t.rcov = true |
294 | + t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*'] |
295 | + end |
296 | end |
297 | |
298 | === modified file 'conf/redhat/facter.spec' |
299 | --- conf/redhat/facter.spec 2011-10-06 10:48:30 +0000 |
300 | +++ conf/redhat/facter.spec 2011-11-14 19:37:34 +0000 |
301 | @@ -2,16 +2,17 @@ |
302 | |
303 | %define has_ruby_abi 0%{?fedora} || 0%{?rhel} >= 5 |
304 | %define has_ruby_noarch %has_ruby_abi |
305 | +%global _ver 1.6.2 |
306 | |
307 | Summary: Ruby module for collecting simple facts about a host operating system |
308 | Name: facter |
309 | -Version: 1.6.0 |
310 | +Version: 1.6.2 |
311 | Release: 1%{?dist} |
312 | License: Apache 2.0 |
313 | Group: System Environment/Base |
314 | URL: http://www.puppetlabs.com/puppet/related-projects/%{name}/ |
315 | -Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz |
316 | -Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz.sign |
317 | +Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{_ver}.tar.gz |
318 | +#Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz.sign |
319 | |
320 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) |
321 | %if %has_ruby_noarch |
322 | @@ -31,7 +32,7 @@ |
323 | operating system. Additional facts can be added through simple Ruby scripts |
324 | |
325 | %prep |
326 | -%setup -q |
327 | +%setup -q -n %{name}-%{_ver} |
328 | |
329 | %build |
330 | |
331 | @@ -52,6 +53,12 @@ |
332 | |
333 | |
334 | %changelog |
335 | +* Mon Oct 10 2011 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.2-1 |
336 | +- Update to 1.6.2 |
337 | + |
338 | +* Mon Oct 03 2011 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.2-0.1rc1 |
339 | +- Updates for 1.6.2-0.1rc1 |
340 | + |
341 | * Thu Jun 23 2011 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.0-1 |
342 | - Update to 1.6.0 |
343 | |
344 | |
345 | === modified file 'conf/solaris/pkginfo' |
346 | --- conf/solaris/pkginfo 2011-06-24 10:04:12 +0000 |
347 | +++ conf/solaris/pkginfo 2011-11-14 19:37:34 +0000 |
348 | @@ -1,6 +1,6 @@ |
349 | PKG=CSWfacter |
350 | NAME=facter - System Fact Gatherer |
351 | -VERSION=1.6.0 |
352 | +VERSION=1.6.2 |
353 | CATEGORY=application |
354 | VENDOR=http://www.puppetlabs.com/puppet/related-projects/facter |
355 | HOTLINE=http://puppetlabs.com/cgi-bin/facter.cgi |
356 | |
357 | === modified file 'debian/changelog' |
358 | --- debian/changelog 2011-10-18 10:32:42 +0000 |
359 | +++ debian/changelog 2011-11-14 19:37:34 +0000 |
360 | @@ -1,7 +1,28 @@ |
361 | +facter (1.6.2-1ubuntu1) precise; urgency=low |
362 | + |
363 | + * Merge from Debian testing (LP: #888671). Remaining changes: |
364 | + - debian/rules: use what we had in natty; we don't want ruby-pkg-tools |
365 | + in main. (LP: #408402) |
366 | + - debian/control: Continue using ruby + libopenssl-ruby as Build-Depends |
367 | + even tho Debian has moved to gem2deb (not in main). Move ruby-json to |
368 | + Suggests. |
369 | + * debian/rules: Use dh_prep instead of dh_clean, add build-arch + build-indep |
370 | + targets |
371 | + * debian/control: Update debhelper Build-Depends to 8, make binary package |
372 | + depend on ruby1.8 explicitly. |
373 | + |
374 | + -- Adam Gandelman <adamg@canonical.com> Thu, 10 Nov 2011 10:11:05 -0800 |
375 | + |
376 | +facter (1.6.2-1) unstable; urgency=low |
377 | + |
378 | + * New upstream release |
379 | + |
380 | + -- Stig Sandbeck Mathisen <ssm@debian.org> Wed, 12 Oct 2011 11:29:53 +0200 |
381 | + |
382 | facter (1.6.1-1ubuntu1) precise; urgency=low |
383 | |
384 | * Merge from Debian unstable (LP: #877621). Remaining changes: |
385 | - - debian/rules: use what we had in natty; we dont want ruby-pkg-tools |
386 | + - debian/rules: use what we had in natty; we don't want ruby-pkg-tools |
387 | in main. (LP: #408402) |
388 | * debian/control: Continue using ruby + libopenssl-ruby as Build-Depends |
389 | even tho Debian has moved to gem2deb (not in main). Move ruby-json to |
390 | @@ -29,7 +50,7 @@ |
391 | |
392 | * Merge from debian unstable (LP: #788284). Remaining changes: |
393 | - Dropped ruby-pkg-tools and libsetup-ruby1.8; debian/rules: use what we |
394 | - had in natty; we dont want ruby-pkg-tools in main. (LP: #408402) |
395 | + had in natty; we don't want ruby-pkg-tools in main. (LP: #408402) |
396 | * Dropped changes to lib/facter/ec2.rb. (Use the latest-meta api so it |
397 | always does not retunr false). This was fixed upstream. |
398 | |
399 | @@ -59,7 +80,7 @@ |
400 | facter (1.5.8-2ubuntu1) natty; urgency=low |
401 | |
402 | * Merge from debian unstable. Remaining changes: |
403 | - - Dropped ruby-pkg-tools and libsetup-ruby1.8, we dont want ruby-pkg-tools |
404 | + - Dropped ruby-pkg-tools and libsetup-ruby1.8, we don't want ruby-pkg-tools |
405 | in main. (LP: #408402) |
406 | |
407 | -- Chuck Short <zulcss@ubuntu.com> Tue, 08 Feb 2011 00:18:35 +0000 |
408 | @@ -97,7 +118,7 @@ |
409 | facter (1.5.7-3ubuntu1) natty; urgency=low |
410 | |
411 | * Merge from debian unstable, remaining changes are: |
412 | - - Dropped ruby-pkg-tools and libsetup-ruby1.8, we dont want ruby-pkg-tools |
413 | + - Dropped ruby-pkg-tools and libsetup-ruby1.8, we don't want ruby-pkg-tools |
414 | in main. (LP: #408402) |
415 | |
416 | -- Chuck Short <zulcss@ubuntu.com> Mon, 10 Jan 2011 11:25:00 -0500 |
417 | @@ -135,7 +156,7 @@ |
418 | |
419 | * Merge from debian testing. Remaining changes: |
420 | - Dropped ruby-pkg-tools, and libsetup-ruby1.8, and cdbs, use what |
421 | - we had in lucid. Since we dont want ruby-pkg-tools in main |
422 | + we had in lucid. Since we don't want ruby-pkg-tools in main |
423 | (LP: #408402) |
424 | |
425 | -- Chuck Short <zulcss@ubuntu.com> Fri, 26 Mar 2010 16:14:26 +0000 |
426 | @@ -165,7 +186,7 @@ |
427 | facter (1.5.6-2ubuntu2) lucid; urgency=low |
428 | |
429 | * Dropped ruby-pkg-tools, and libsetup-ruby1.8, and cdbs, use what |
430 | - we had in karmic. Since we dont want ruby-pkg-tools in main. |
431 | + we had in karmic. Since we don't want ruby-pkg-tools in main. |
432 | (LP: #408402) |
433 | |
434 | -- Chuck Short <zulcss@ubuntu.com> Fri, 26 Mar 2010 08:34:25 -0400 |
435 | |
436 | === modified file 'debian/control' |
437 | --- debian/control 2011-10-18 10:32:42 +0000 |
438 | +++ debian/control 2011-11-14 19:37:34 +0000 |
439 | @@ -4,7 +4,7 @@ |
440 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
441 | XSBC-Original-Maintainer: Puppet Package Maintainers <pkg-puppet-devel@lists.alioth.debian.org> |
442 | Uploaders: Andrew Pollock <apollock@debian.org>, Nigel Kersten <nigel@explanatorygap.net>, Micah Anderson <micah@debian.org>, Stig Sandbeck Mathisen <ssm@debian.org> |
443 | -Build-Depends: debhelper (>= 5.0.0), ruby (>= 1.8), libopenssl-ruby |
444 | +Build-Depends: debhelper (>= 8), ruby (>= 1.8), libopenssl-ruby |
445 | Standards-Version: 3.9.2 |
446 | Vcs-Git: git://git.debian.org/git/pkg-puppet/facter.git |
447 | Vcs-Browser: http://git.debian.org/?p=pkg-puppet/facter.git |
448 | @@ -14,7 +14,7 @@ |
449 | Package: facter |
450 | Architecture: all |
451 | XB-Ruby-Versions: ${ruby:Versions} |
452 | -Depends: ${misc:Depends}, ruby | ruby-interpreter, net-tools, bind9-host | host |
453 | +Depends: ${misc:Depends}, ruby1.8, net-tools, bind9-host | host |
454 | Recommends: pciutils |
455 | Suggests: ruby-json |
456 | Description: collect and display facts about the system |
457 | |
458 | === added directory 'debian/patches' |
459 | === added file 'debian/patches/no-require-rubygems' |
460 | --- debian/patches/no-require-rubygems 1970-01-01 00:00:00 +0000 |
461 | +++ debian/patches/no-require-rubygems 2011-11-14 19:37:34 +0000 |
462 | @@ -0,0 +1,15 @@ |
463 | +From: Stig Sandbeck Mathisen <ssm@debian.org> |
464 | +Forwarded: not-needed |
465 | +Subject: Do not require rubygems |
466 | + We do not require rubygems; the apt repository should contain all |
467 | + dependencies. |
468 | +--- a/lib/facter/application.rb |
469 | ++++ b/lib/facter/application.rb |
470 | +@@ -35,7 +35,6 @@ |
471 | + # Print the facts as JSON and exit |
472 | + if options[:json] |
473 | + begin |
474 | +- require 'rubygems' |
475 | + require 'json' |
476 | + puts JSON.dump(facts) |
477 | + exit(0) |
478 | |
479 | === added file 'debian/patches/series' |
480 | --- debian/patches/series 1970-01-01 00:00:00 +0000 |
481 | +++ debian/patches/series 2011-11-14 19:37:34 +0000 |
482 | @@ -0,0 +1,1 @@ |
483 | +no-require-rubygems |
484 | |
485 | === modified file 'debian/rules' |
486 | --- debian/rules 2011-10-18 10:32:42 +0000 |
487 | +++ debian/rules 2011-11-14 19:37:34 +0000 |
488 | @@ -18,7 +18,9 @@ |
489 | touch configure-stamp |
490 | |
491 | |
492 | -build: build-stamp |
493 | +build: build-arch build-indep |
494 | +build-arch: build-stamp |
495 | +build-indep: build-stamp |
496 | build-stamp: configure-stamp |
497 | dh_testdir |
498 | touch build-stamp |
499 | @@ -32,7 +34,7 @@ |
500 | install: build |
501 | dh_testdir |
502 | dh_testroot |
503 | - dh_clean -k |
504 | + dh_prep |
505 | dh_installdirs |
506 | |
507 | $(CURDIR)/install.rb --destdir=$(CURDIR)/debian/facter/ \ |
508 | @@ -49,6 +51,7 @@ |
509 | dh_testroot |
510 | dh_installchangelogs CHANGELOG |
511 | dh_installdocs |
512 | + dh_installman |
513 | dh_compress |
514 | dh_fixperms |
515 | dh_installdeb |
516 | |
517 | === modified file 'install.rb' |
518 | --- install.rb 2011-10-18 10:32:42 +0000 |
519 | +++ install.rb 2011-11-14 19:37:34 +0000 |
520 | @@ -12,23 +12,23 @@ |
521 | # In most cases, if you have a typical project layout, you will need to do |
522 | # absolutely nothing to make this work for you. This layout is: |
523 | # |
524 | -# bin/ # executable files -- "commands" |
525 | -# lib/ # the source of the library |
526 | +# bin/ # executable files -- "commands" |
527 | +# lib/ # the source of the library |
528 | # tests/ # unit tests |
529 | # |
530 | # The default behaviour: |
531 | # 1) Run all unit test files (ending in .rb) found in all directories under |
532 | -# tests/. |
533 | +# tests/. |
534 | # 2) Build Rdoc documentation from all files in bin/ (excluding .bat and .cmd), |
535 | -# all .rb files in lib/, ./README, ./ChangeLog, and ./Install. |
536 | +# all .rb files in lib/, ./README, ./ChangeLog, and ./Install. |
537 | # 3) Build ri documentation from all files in bin/ (excluding .bat and .cmd), |
538 | -# and all .rb files in lib/. This is disabled by default on Win32. |
539 | +# and all .rb files in lib/. This is disabled by default on Win32. |
540 | # 4) Install commands from bin/ into the Ruby bin directory. On Windows, if a |
541 | -# if a corresponding batch file (.bat or .cmd) exists in the bin directory, |
542 | -# it will be copied over as well. Otherwise, a batch file (always .bat) will |
543 | -# be created to run the specified command. |
544 | +# if a corresponding batch file (.bat or .cmd) exists in the bin directory, |
545 | +# it will be copied over as well. Otherwise, a batch file (always .bat) will |
546 | +# be created to run the specified command. |
547 | # 5) Install all library files ending in .rb from lib/ into Ruby's |
548 | -# site_lib/version directory. |
549 | +# site_lib/version directory. |
550 | # |
551 | #++ |
552 | |
553 | @@ -39,23 +39,23 @@ |
554 | require 'ostruct' |
555 | |
556 | begin |
557 | - require 'rdoc/rdoc' |
558 | - $haverdoc = true |
559 | + require 'rdoc/rdoc' |
560 | + $haverdoc = true |
561 | rescue LoadError |
562 | - puts "Missing rdoc; skipping documentation" |
563 | - $haverdoc = false |
564 | + puts "Missing rdoc; skipping documentation" |
565 | + $haverdoc = false |
566 | end |
567 | |
568 | begin |
569 | - if $haverdoc |
570 | - rst2man = %x{which rst2man.py} |
571 | - $haveman = true |
572 | - else |
573 | - $haveman = false |
574 | - end |
575 | + if $haverdoc |
576 | + rst2man = %x{which rst2man.py} |
577 | + $haveman = true |
578 | + else |
579 | + $haveman = false |
580 | + end |
581 | rescue |
582 | - puts "Missing rst2man; skipping man page creation" |
583 | - $haveman = false |
584 | + puts "Missing rst2man; skipping man page creation" |
585 | + $haveman = false |
586 | end |
587 | |
588 | $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib') |
589 | @@ -67,66 +67,66 @@ |
590 | InstallOptions = OpenStruct.new |
591 | |
592 | def glob(list) |
593 | - g = list.map { |i| Dir.glob(i) } |
594 | - g.flatten! |
595 | - g.compact! |
596 | - g.reject! { |e| e =~ /\.svn/ } |
597 | - g |
598 | + g = list.map { |i| Dir.glob(i) } |
599 | + g.flatten! |
600 | + g.compact! |
601 | + g.reject! { |e| e =~ /\.svn/ } |
602 | + g |
603 | end |
604 | |
605 | # Set these values to what you want installed. |
606 | sbins = glob(%w{sbin/*}) |
607 | bins = glob(%w{bin/*}) |
608 | rdoc = glob(%w{bin/* sbin/* lib/**/*.rb README README-library CHANGELOG TODO Install}).reject { |e| e=~ /\.(bat|cmd)$/ } |
609 | -ri = glob(%w(bin/*.rb sbin/* lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ } |
610 | +ri = glob(%w(bin/*.rb sbin/* lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ } |
611 | man = glob(%w{man/man8/*}) |
612 | libs = glob(%w{lib/**/*.rb lib/**/*.py}) |
613 | tests = glob(%w{tests/**/*.rb}) |
614 | |
615 | def do_bins(bins, target, strip = 's?bin/') |
616 | - bins.each do |bf| |
617 | - obf = bf.gsub(/#{strip}/, '') |
618 | - install_binfile(bf, obf, target) |
619 | - end |
620 | + bins.each do |bf| |
621 | + obf = bf.gsub(/#{strip}/, '') |
622 | + install_binfile(bf, obf, target) |
623 | + end |
624 | end |
625 | |
626 | def do_libs(libs, strip = 'lib/') |
627 | - libs.each do |lf| |
628 | - olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, '')) |
629 | - op = File.dirname(olf) |
630 | - FileUtils.makedirs(op, {:mode => 0755, :verbose => true}) |
631 | - FileUtils.chmod(0755, op) |
632 | - FileUtils.install(lf, olf, {:mode => 0644, :verbose => true}) |
633 | - end |
634 | + libs.each do |lf| |
635 | + olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, '')) |
636 | + op = File.dirname(olf) |
637 | + FileUtils.makedirs(op, {:mode => 0755, :verbose => true}) |
638 | + FileUtils.chmod(0755, op) |
639 | + FileUtils.install(lf, olf, {:mode => 0644, :verbose => true}) |
640 | + end |
641 | end |
642 | |
643 | def do_man(man, strip = 'man/') |
644 | if (InstallOptions.man == true) |
645 | - man.each do |mf| |
646 | - omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, '')) |
647 | - om = File.dirname(omf) |
648 | - FileUtils.makedirs(om, {:mode => 0755, :verbose => true}) |
649 | - FileUtils.chmod(0755, om) |
650 | - FileUtils.install(mf, omf, {:mode => 0644, :verbose => true}) |
651 | - gzip = %x{which gzip} |
652 | - gzip.chomp! |
653 | - %x{#{gzip} -f #{omf}} |
654 | - end |
655 | + man.each do |mf| |
656 | + omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, '')) |
657 | + om = File.dirname(omf) |
658 | + FileUtils.makedirs(om, {:mode => 0755, :verbose => true}) |
659 | + FileUtils.chmod(0755, om) |
660 | + FileUtils.install(mf, omf, {:mode => 0644, :verbose => true}) |
661 | + gzip = %x{which gzip} |
662 | + gzip.chomp! |
663 | + %x{#{gzip} -f #{omf}} |
664 | + end |
665 | else |
666 | - puts "Skipping Man Page Generation" |
667 | + puts "Skipping Man Page Generation" |
668 | end |
669 | end |
670 | |
671 | # Verify that all of the prereqs are installed |
672 | def check_prereqs |
673 | - PREREQS.each { |pre| |
674 | - begin |
675 | - require pre |
676 | - rescue LoadError |
677 | - puts "Could not load #{pre} Ruby library; cannot install" |
678 | - exit -1 |
679 | - end |
680 | - } |
681 | + PREREQS.each { |pre| |
682 | + begin |
683 | + require pre |
684 | + rescue LoadError |
685 | + puts "Could not load #{pre} Ruby library; cannot install" |
686 | + exit -1 |
687 | + end |
688 | + } |
689 | end |
690 | |
691 | def is_windows? |
692 | @@ -137,160 +137,160 @@ |
693 | # Prepare the file installation. |
694 | # |
695 | def prepare_installation |
696 | - # Only try to do docs if we're sure they have rdoc |
697 | - if $haverdoc |
698 | - InstallOptions.rdoc = true |
699 | - if is_windows? |
700 | - InstallOptions.ri = false |
701 | - else |
702 | - InstallOptions.ri = true |
703 | - end |
704 | - else |
705 | - InstallOptions.rdoc = false |
706 | - InstallOptions.ri = false |
707 | - end |
708 | - |
709 | - |
710 | - if $haveman |
711 | - InstallOptions.man = true |
712 | - if is_windows? |
713 | - InstallOptions.man = false |
714 | - end |
715 | - else |
716 | - InstallOptions.man = false |
717 | - end |
718 | - |
719 | - InstallOptions.tests = true |
720 | - |
721 | - ARGV.options do |opts| |
722 | - opts.banner = "Usage: #{File.basename($0)} [options]" |
723 | - opts.separator "" |
724 | - opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc| |
725 | - InstallOptions.rdoc = onrdoc |
726 | - end |
727 | - opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri| |
728 | - InstallOptions.ri = onri |
729 | - end |
730 | - opts.on('--[no-]man', 'Presents the creation of man pages.', 'Default on.') do |onman| |
731 | - InstallOptions.man = onman |
732 | - end |
733 | - opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest| |
734 | - InstallOptions.tests = ontest |
735 | - end |
736 | - opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir| |
737 | - InstallOptions.destdir = destdir |
738 | - end |
739 | - opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir| |
740 | - InstallOptions.bindir = bindir |
741 | - end |
742 | - opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir| |
743 | - InstallOptions.sbindir = sbindir |
744 | - end |
745 | - opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir| |
746 | - InstallOptions.sitelibdir = sitelibdir |
747 | - end |
748 | - opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir| |
749 | - InstallOptions.mandir = mandir |
750 | - end |
751 | - opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick| |
752 | - InstallOptions.rdoc = false |
753 | - InstallOptions.ri = false |
754 | - InstallOptions.tests = false |
755 | - end |
756 | - opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full| |
757 | - InstallOptions.rdoc = true |
758 | - InstallOptions.ri = true |
759 | - InstallOptions.tests = true |
760 | - end |
761 | - opts.separator("") |
762 | - opts.on_tail('--help', "Shows this help text.") do |
763 | - $stderr.puts opts |
764 | - exit |
765 | - end |
766 | - |
767 | - opts.parse! |
768 | - end |
769 | - |
770 | - tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."] |
771 | - |
772 | - version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".") |
773 | - libdir = File.join(Config::CONFIG["libdir"], "ruby", version) |
774 | - |
775 | - # Mac OS X 10.5 and higher declare bindir and sbindir as |
776 | - # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin |
777 | - # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin |
778 | - # which is not generally where people expect executables to be installed |
779 | - # These settings are appropriate defaults for all OS X versions. |
780 | - if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/ |
781 | - Config::CONFIG['bindir'] = "/usr/bin" |
782 | - Config::CONFIG['sbindir'] = "/usr/sbin" |
783 | - end |
784 | - |
785 | - if not InstallOptions.bindir.nil? |
786 | - bindir = InstallOptions.bindir |
787 | - else |
788 | - bindir = Config::CONFIG['bindir'] |
789 | - end |
790 | - |
791 | - if not InstallOptions.sbindir.nil? |
792 | - sbindir = InstallOptions.sbindir |
793 | - else |
794 | - sbindir = Config::CONFIG['sbindir'] |
795 | - end |
796 | - |
797 | - if not InstallOptions.sitelibdir.nil? |
798 | - sitelibdir = InstallOptions.sitelibdir |
799 | - else |
800 | - sitelibdir = Config::CONFIG["sitelibdir"] |
801 | - if sitelibdir.nil? |
802 | - sitelibdir = $:.find { |x| x =~ /site_ruby/ } |
803 | - if sitelibdir.nil? |
804 | - sitelibdir = File.join(libdir, "site_ruby") |
805 | - elsif sitelibdir !~ Regexp.quote(version) |
806 | - sitelibdir = File.join(sitelibdir, version) |
807 | - end |
808 | - end |
809 | - end |
810 | - |
811 | - if not InstallOptions.mandir.nil? |
812 | - mandir = InstallOptions.mandir |
813 | - else |
814 | - mandir = Config::CONFIG['mandir'] |
815 | - end |
816 | - |
817 | - # To be deprecated once people move over to using --destdir option |
818 | - if (destdir = ENV['DESTDIR']) |
819 | - warn "DESTDIR is deprecated. Use --destdir instead." |
820 | - bindir = join(destdir, bindir) |
821 | - sbindir = join(destdir, sbindir) |
822 | - mandir = join(destdir, mandir) |
823 | - sitelibdir = join(destdir, sitelibdir) |
824 | - |
825 | - FileUtils.makedirs(bindir) |
826 | - FileUtils.makedirs(sbindir) |
827 | - FileUtils.makedirs(mandir) |
828 | - FileUtils.makedirs(sitelibdir) |
829 | - # This is the new way forward |
830 | - elsif (destdir = InstallOptions.destdir) |
831 | - bindir = join(destdir, bindir) |
832 | - sbindir = join(destdir, sbindir) |
833 | - mandir = join(destdir, mandir) |
834 | - sitelibdir = join(destdir, sitelibdir) |
835 | - |
836 | - FileUtils.makedirs(bindir) |
837 | - FileUtils.makedirs(sbindir) |
838 | - FileUtils.makedirs(mandir) |
839 | - FileUtils.makedirs(sitelibdir) |
840 | - end |
841 | - |
842 | - tmpdirs << bindir |
843 | - |
844 | - InstallOptions.tmp_dirs = tmpdirs.compact |
845 | - InstallOptions.site_dir = sitelibdir |
846 | - InstallOptions.bin_dir = bindir |
847 | - InstallOptions.sbin_dir = sbindir |
848 | - InstallOptions.lib_dir = libdir |
849 | - InstallOptions.man_dir = mandir |
850 | + # Only try to do docs if we're sure they have rdoc |
851 | + if $haverdoc |
852 | + InstallOptions.rdoc = true |
853 | + if is_windows? |
854 | + InstallOptions.ri = false |
855 | + else |
856 | + InstallOptions.ri = true |
857 | + end |
858 | + else |
859 | + InstallOptions.rdoc = false |
860 | + InstallOptions.ri = false |
861 | + end |
862 | + |
863 | + |
864 | + if $haveman |
865 | + InstallOptions.man = true |
866 | + if is_windows? |
867 | + InstallOptions.man = false |
868 | + end |
869 | + else |
870 | + InstallOptions.man = false |
871 | + end |
872 | + |
873 | + InstallOptions.tests = true |
874 | + |
875 | + ARGV.options do |opts| |
876 | + opts.banner = "Usage: #{File.basename($0)} [options]" |
877 | + opts.separator "" |
878 | + opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc| |
879 | + InstallOptions.rdoc = onrdoc |
880 | + end |
881 | + opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri| |
882 | + InstallOptions.ri = onri |
883 | + end |
884 | + opts.on('--[no-]man', 'Presents the creation of man pages.', 'Default on.') do |onman| |
885 | + InstallOptions.man = onman |
886 | + end |
887 | + opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest| |
888 | + InstallOptions.tests = ontest |
889 | + end |
890 | + opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir| |
891 | + InstallOptions.destdir = destdir |
892 | + end |
893 | + opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir| |
894 | + InstallOptions.bindir = bindir |
895 | + end |
896 | + opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir| |
897 | + InstallOptions.sbindir = sbindir |
898 | + end |
899 | + opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir| |
900 | + InstallOptions.sitelibdir = sitelibdir |
901 | + end |
902 | + opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir| |
903 | + InstallOptions.mandir = mandir |
904 | + end |
905 | + opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick| |
906 | + InstallOptions.rdoc = false |
907 | + InstallOptions.ri = false |
908 | + InstallOptions.tests = false |
909 | + end |
910 | + opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full| |
911 | + InstallOptions.rdoc = true |
912 | + InstallOptions.ri = true |
913 | + InstallOptions.tests = true |
914 | + end |
915 | + opts.separator("") |
916 | + opts.on_tail('--help', "Shows this help text.") do |
917 | + $stderr.puts opts |
918 | + exit |
919 | + end |
920 | + |
921 | + opts.parse! |
922 | + end |
923 | + |
924 | + tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."] |
925 | + |
926 | + version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".") |
927 | + libdir = File.join(Config::CONFIG["libdir"], "ruby", version) |
928 | + |
929 | + # Mac OS X 10.5 and higher declare bindir and sbindir as |
930 | + # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin |
931 | + # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin |
932 | + # which is not generally where people expect executables to be installed |
933 | + # These settings are appropriate defaults for all OS X versions. |
934 | + if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/ |
935 | + Config::CONFIG['bindir'] = "/usr/bin" |
936 | + Config::CONFIG['sbindir'] = "/usr/sbin" |
937 | + end |
938 | + |
939 | + if not InstallOptions.bindir.nil? |
940 | + bindir = InstallOptions.bindir |
941 | + else |
942 | + bindir = Config::CONFIG['bindir'] |
943 | + end |
944 | + |
945 | + if not InstallOptions.sbindir.nil? |
946 | + sbindir = InstallOptions.sbindir |
947 | + else |
948 | + sbindir = Config::CONFIG['sbindir'] |
949 | + end |
950 | + |
951 | + if not InstallOptions.sitelibdir.nil? |
952 | + sitelibdir = InstallOptions.sitelibdir |
953 | + else |
954 | + sitelibdir = Config::CONFIG["sitelibdir"] |
955 | + if sitelibdir.nil? |
956 | + sitelibdir = $:.find { |x| x =~ /site_ruby/ } |
957 | + if sitelibdir.nil? |
958 | + sitelibdir = File.join(libdir, "site_ruby") |
959 | + elsif sitelibdir !~ Regexp.quote(version) |
960 | + sitelibdir = File.join(sitelibdir, version) |
961 | + end |
962 | + end |
963 | + end |
964 | + |
965 | + if not InstallOptions.mandir.nil? |
966 | + mandir = InstallOptions.mandir |
967 | + else |
968 | + mandir = Config::CONFIG['mandir'] |
969 | + end |
970 | + |
971 | + # To be deprecated once people move over to using --destdir option |
972 | + if (destdir = ENV['DESTDIR']) |
973 | + warn "DESTDIR is deprecated. Use --destdir instead." |
974 | + bindir = join(destdir, bindir) |
975 | + sbindir = join(destdir, sbindir) |
976 | + mandir = join(destdir, mandir) |
977 | + sitelibdir = join(destdir, sitelibdir) |
978 | + |
979 | + FileUtils.makedirs(bindir) |
980 | + FileUtils.makedirs(sbindir) |
981 | + FileUtils.makedirs(mandir) |
982 | + FileUtils.makedirs(sitelibdir) |
983 | + # This is the new way forward |
984 | + elsif (destdir = InstallOptions.destdir) |
985 | + bindir = join(destdir, bindir) |
986 | + sbindir = join(destdir, sbindir) |
987 | + mandir = join(destdir, mandir) |
988 | + sitelibdir = join(destdir, sitelibdir) |
989 | + |
990 | + FileUtils.makedirs(bindir) |
991 | + FileUtils.makedirs(sbindir) |
992 | + FileUtils.makedirs(mandir) |
993 | + FileUtils.makedirs(sitelibdir) |
994 | + end |
995 | + |
996 | + tmpdirs << bindir |
997 | + |
998 | + InstallOptions.tmp_dirs = tmpdirs.compact |
999 | + InstallOptions.site_dir = sitelibdir |
1000 | + InstallOptions.bin_dir = bindir |
1001 | + InstallOptions.sbin_dir = sbindir |
1002 | + InstallOptions.lib_dir = libdir |
1003 | + InstallOptions.man_dir = mandir |
1004 | end |
1005 | |
1006 | ## |
1007 | @@ -307,69 +307,69 @@ |
1008 | # Build the rdoc documentation. Also, try to build the RI documentation. |
1009 | # |
1010 | def build_rdoc(files) |
1011 | - return unless $haverdoc |
1012 | - begin |
1013 | - r = RDoc::RDoc.new |
1014 | - r.document(["--main", "README", "--title", |
1015 | - "Puppet -- Site Configuration Management", "--line-numbers"] + files) |
1016 | - rescue RDoc::RDocError => e |
1017 | - $stderr.puts e.message |
1018 | - rescue Exception => e |
1019 | - $stderr.puts "Couldn't build RDoc documentation\n#{e.message}" |
1020 | - end |
1021 | + return unless $haverdoc |
1022 | + begin |
1023 | + r = RDoc::RDoc.new |
1024 | + r.document(["--main", "README", "--title", |
1025 | + "Puppet -- Site Configuration Management", "--line-numbers"] + files) |
1026 | + rescue RDoc::RDocError => e |
1027 | + $stderr.puts e.message |
1028 | + rescue Exception => e |
1029 | + $stderr.puts "Couldn't build RDoc documentation\n#{e.message}" |
1030 | + end |
1031 | end |
1032 | |
1033 | def build_ri(files) |
1034 | - return unless $haverdoc |
1035 | - begin |
1036 | - ri = RDoc::RDoc.new |
1037 | - #ri.document(["--ri-site", "--merge"] + files) |
1038 | - ri.document(["--ri-site"] + files) |
1039 | - rescue RDoc::RDocError => e |
1040 | - $stderr.puts e.message |
1041 | - rescue Exception => e |
1042 | - $stderr.puts "Couldn't build Ri documentation\n#{e.message}" |
1043 | - $stderr.puts "Continuing with install..." |
1044 | - end |
1045 | + return unless $haverdoc |
1046 | + begin |
1047 | + ri = RDoc::RDoc.new |
1048 | + #ri.document(["--ri-site", "--merge"] + files) |
1049 | + ri.document(["--ri-site"] + files) |
1050 | + rescue RDoc::RDocError => e |
1051 | + $stderr.puts e.message |
1052 | + rescue Exception => e |
1053 | + $stderr.puts "Couldn't build Ri documentation\n#{e.message}" |
1054 | + $stderr.puts "Continuing with install..." |
1055 | + end |
1056 | end |
1057 | |
1058 | def build_man(bins) |
1059 | - return unless $haveman |
1060 | - begin |
1061 | - # Locate rst2man |
1062 | - rst2man = %x{which rst2man.py} |
1063 | - rst2man.chomp! |
1064 | - bins.each do |bin| |
1065 | - b = bin.gsub( "bin/", "") |
1066 | - %x{#{bin} --help > ./#{b}.rst} |
1067 | - %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8} |
1068 | - File.unlink("./#{b}.rst") |
1069 | - end |
1070 | - rescue SystemCallError |
1071 | - $stderr.puts "Couldn't build man pages: " + $! |
1072 | - $stderr.puts "Continuing with install..." |
1073 | + return unless $haveman |
1074 | + begin |
1075 | + # Locate rst2man |
1076 | + rst2man = %x{which rst2man.py} |
1077 | + rst2man.chomp! |
1078 | + bins.each do |bin| |
1079 | + b = bin.gsub( "bin/", "") |
1080 | + %x{#{bin} --help > ./#{b}.rst} |
1081 | + %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8} |
1082 | + File.unlink("./#{b}.rst") |
1083 | end |
1084 | + rescue SystemCallError |
1085 | + $stderr.puts "Couldn't build man pages: " + $! |
1086 | + $stderr.puts "Continuing with install..." |
1087 | + end |
1088 | end |
1089 | |
1090 | def run_tests(test_list) |
1091 | - begin |
1092 | - require 'test/unit/ui/console/testrunner' |
1093 | - $:.unshift "lib" |
1094 | - test_list.each do |test| |
1095 | - next if File.directory?(test) |
1096 | - require test |
1097 | - end |
1098 | - |
1099 | - tests = [] |
1100 | - ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) } |
1101 | - tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) } |
1102 | - tests.delete_if { |o| o == Test::Unit::TestCase } |
1103 | - |
1104 | - tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) } |
1105 | - $:.shift |
1106 | - rescue LoadError |
1107 | - puts "Missing testrunner library; skipping tests" |
1108 | + begin |
1109 | + require 'test/unit/ui/console/testrunner' |
1110 | + $:.unshift "lib" |
1111 | + test_list.each do |test| |
1112 | + next if File.directory?(test) |
1113 | + require test |
1114 | end |
1115 | + |
1116 | + tests = [] |
1117 | + ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) } |
1118 | + tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) } |
1119 | + tests.delete_if { |o| o == Test::Unit::TestCase } |
1120 | + |
1121 | + tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) } |
1122 | + $:.shift |
1123 | + rescue LoadError |
1124 | + puts "Missing testrunner library; skipping tests" |
1125 | + end |
1126 | end |
1127 | |
1128 | ## |
1129 | @@ -378,57 +378,57 @@ |
1130 | # (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under |
1131 | # windows, we add an '.rb' extension and let file associations do their stuff. |
1132 | def install_binfile(from, op_file, target) |
1133 | - tmp_dir = nil |
1134 | - InstallOptions.tmp_dirs.each do |t| |
1135 | - if File.directory?(t) and File.writable?(t) |
1136 | - tmp_dir = t |
1137 | - break |
1138 | - end |
1139 | - end |
1140 | - |
1141 | - fail "Cannot find a temporary directory" unless tmp_dir |
1142 | - tmp_file = File.join(tmp_dir, '_tmp') |
1143 | - ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) |
1144 | - |
1145 | - File.open(from) do |ip| |
1146 | - File.open(tmp_file, "w") do |op| |
1147 | - ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) |
1148 | - op.puts "#!#{ruby}" |
1149 | - contents = ip.readlines |
1150 | - if contents[0] =~ /^#!/ |
1151 | - contents.shift |
1152 | - end |
1153 | - op.write contents.join() |
1154 | - end |
1155 | - end |
1156 | - |
1157 | - if is_windows? |
1158 | - installed_wrapper = false |
1159 | - |
1160 | - if File.exists?("#{from}.bat") |
1161 | - FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true) |
1162 | - installed_wrapper = true |
1163 | - end |
1164 | - |
1165 | - if File.exists?("#{from}.cmd") |
1166 | - FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true) |
1167 | - installed_wrapper = true |
1168 | - end |
1169 | - |
1170 | - if not installed_wrapper |
1171 | - tmp_file2 = File.join(tmp_dir, '_tmp_wrapper') |
1172 | - cwn = File.join(Config::CONFIG['bindir'], op_file) |
1173 | - cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } ) |
1174 | - |
1175 | - File.open(tmp_file2, "wb") { |cw| cw.puts cwv } |
1176 | - FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true) |
1177 | - |
1178 | - File.unlink(tmp_file2) |
1179 | - installed_wrapper = true |
1180 | - end |
1181 | - end |
1182 | - FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true) |
1183 | - File.unlink(tmp_file) |
1184 | + tmp_dir = nil |
1185 | + InstallOptions.tmp_dirs.each do |t| |
1186 | + if File.directory?(t) and File.writable?(t) |
1187 | + tmp_dir = t |
1188 | + break |
1189 | + end |
1190 | + end |
1191 | + |
1192 | + fail "Cannot find a temporary directory" unless tmp_dir |
1193 | + tmp_file = File.join(tmp_dir, '_tmp') |
1194 | + ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) |
1195 | + |
1196 | + File.open(from) do |ip| |
1197 | + File.open(tmp_file, "w") do |op| |
1198 | + ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) |
1199 | + op.puts "#!#{ruby}" |
1200 | + contents = ip.readlines |
1201 | + if contents[0] =~ /^#!/ |
1202 | + contents.shift |
1203 | + end |
1204 | + op.write contents.join() |
1205 | + end |
1206 | + end |
1207 | + |
1208 | + if is_windows? |
1209 | + installed_wrapper = false |
1210 | + |
1211 | + if File.exists?("#{from}.bat") |
1212 | + FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true) |
1213 | + installed_wrapper = true |
1214 | + end |
1215 | + |
1216 | + if File.exists?("#{from}.cmd") |
1217 | + FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true) |
1218 | + installed_wrapper = true |
1219 | + end |
1220 | + |
1221 | + if not installed_wrapper |
1222 | + tmp_file2 = File.join(tmp_dir, '_tmp_wrapper') |
1223 | + cwn = File.join(Config::CONFIG['bindir'], op_file) |
1224 | + cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } ) |
1225 | + |
1226 | + File.open(tmp_file2, "wb") { |cw| cw.puts cwv } |
1227 | + FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true) |
1228 | + |
1229 | + File.unlink(tmp_file2) |
1230 | + installed_wrapper = true |
1231 | + end |
1232 | + end |
1233 | + FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true) |
1234 | + File.unlink(tmp_file) |
1235 | end |
1236 | |
1237 | CMD_WRAPPER = <<-EOS |
1238 | |
1239 | === modified file 'lib/facter.rb' |
1240 | --- lib/facter.rb 2011-10-18 10:32:42 +0000 |
1241 | +++ lib/facter.rb 2011-11-14 19:37:34 +0000 |
1242 | @@ -15,233 +15,233 @@ |
1243 | # limitations under the License. |
1244 | |
1245 | module Facter |
1246 | - # This is just so the other classes have the constant. |
1247 | - module Util; end |
1248 | - |
1249 | - require 'facter/util/fact' |
1250 | - require 'facter/util/collection' |
1251 | - |
1252 | - include Comparable |
1253 | - include Enumerable |
1254 | - |
1255 | - FACTERVERSION = '1.6.1' |
1256 | - # = Facter |
1257 | - # Functions as a hash of 'facts' you might care about about your |
1258 | - # system, such as mac address, IP address, Video card, etc. |
1259 | - # returns them dynamically |
1260 | - |
1261 | - # == Synopsis |
1262 | - # |
1263 | - # Generally, treat <tt>Facter</tt> as a hash: |
1264 | - # == Example |
1265 | - # require 'facter' |
1266 | - # puts Facter['operatingsystem'] |
1267 | - # |
1268 | - |
1269 | - # Set LANG to force i18n to C |
1270 | - # |
1271 | - ENV['LANG'] = 'C' |
1272 | - |
1273 | - GREEN = "[0;32m" |
1274 | - RESET = "[0m" |
1275 | - @@debug = 0 |
1276 | - @@timing = 0 |
1277 | - @@messages = {} |
1278 | - |
1279 | - # module methods |
1280 | - |
1281 | - def self.collection |
1282 | - unless defined?(@collection) and @collection |
1283 | - @collection = Facter::Util::Collection.new |
1284 | - end |
1285 | - @collection |
1286 | - end |
1287 | - |
1288 | - # Return the version of the library. |
1289 | - def self.version |
1290 | - return FACTERVERSION |
1291 | - end |
1292 | - |
1293 | - # Add some debugging |
1294 | - def self.debug(string) |
1295 | - if string.nil? |
1296 | - return |
1297 | - end |
1298 | - if self.debugging? |
1299 | - puts GREEN + string + RESET |
1300 | - end |
1301 | - end |
1302 | - |
1303 | - def self.debugging? |
1304 | - @@debug != 0 |
1305 | - end |
1306 | - |
1307 | - # show the timing information |
1308 | - def self.show_time(string) |
1309 | - puts "#{GREEN}#{string}#{RESET}" if string and Facter.timing? |
1310 | - end |
1311 | - |
1312 | - def self.timing? |
1313 | - @@timing != 0 |
1314 | - end |
1315 | - |
1316 | - # Return a fact object by name. If you use this, you still have to call |
1317 | - # 'value' on it to retrieve the actual value. |
1318 | - def self.[](name) |
1319 | - collection.fact(name) |
1320 | - end |
1321 | - |
1322 | - class << self |
1323 | - [:fact, :flush, :list, :value].each do |method| |
1324 | - define_method(method) do |*args| |
1325 | - collection.send(method, *args) |
1326 | - end |
1327 | - end |
1328 | - |
1329 | - [:list, :to_hash].each do |method| |
1330 | - define_method(method) do |*args| |
1331 | - collection.load_all |
1332 | - collection.send(method, *args) |
1333 | - end |
1334 | - end |
1335 | - end |
1336 | - |
1337 | - |
1338 | - # Add a resolution mechanism for a named fact. This does not distinguish |
1339 | - # between adding a new fact and adding a new way to resolve a fact. |
1340 | - def self.add(name, options = {}, &block) |
1341 | - collection.add(name, options, &block) |
1342 | - end |
1343 | - |
1344 | - def self.each |
1345 | - # Make sure all facts are loaded. |
1346 | - collection.load_all |
1347 | - |
1348 | - collection.each do |*args| |
1349 | - yield(*args) |
1350 | - end |
1351 | - end |
1352 | - |
1353 | - class << self |
1354 | - # Allow users to call fact names directly on the Facter class, |
1355 | - # either retrieving the value or comparing it to an existing value. |
1356 | - def method_missing(name, *args) |
1357 | - question = false |
1358 | - if name.to_s =~ /\?$/ |
1359 | - question = true |
1360 | - name = name.to_s.sub(/\?$/,'') |
1361 | - end |
1362 | - |
1363 | - if fact = collection.fact(name) |
1364 | - if question |
1365 | - value = fact.value.downcase |
1366 | - args.each do |arg| |
1367 | - if arg.to_s.downcase == value |
1368 | - return true |
1369 | - end |
1370 | - end |
1371 | - |
1372 | - # If we got this far, there was no match. |
1373 | - return false |
1374 | - else |
1375 | - return fact.value |
1376 | - end |
1377 | - else |
1378 | - # Else, fail like a normal missing method. |
1379 | - raise NoMethodError, "Could not find fact '%s'" % name |
1380 | - end |
1381 | - end |
1382 | - end |
1383 | - |
1384 | - # Clear all facts. Mostly used for testing. |
1385 | - def self.clear |
1386 | - Facter.flush |
1387 | - Facter.reset |
1388 | - end |
1389 | - |
1390 | - # Clear all messages. Used only in testing. Can't add to self.clear |
1391 | - # because we don't want to warn multiple times for items that are warnonce'd |
1392 | - def self.clear_messages |
1393 | - @@messages.clear |
1394 | - end |
1395 | - |
1396 | - # Set debugging on or off. |
1397 | - def self.debugging(bit) |
1398 | - if bit |
1399 | - case bit |
1400 | - when TrueClass; @@debug = 1 |
1401 | - when FalseClass; @@debug = 0 |
1402 | - when Fixnum |
1403 | - if bit > 0 |
1404 | - @@debug = 1 |
1405 | - else |
1406 | - @@debug = 0 |
1407 | - end |
1408 | - when String; |
1409 | - if bit.downcase == 'off' |
1410 | - @@debug = 0 |
1411 | - else |
1412 | - @@debug = 1 |
1413 | - end |
1414 | - else |
1415 | - @@debug = 0 |
1416 | - end |
1417 | - else |
1418 | - @@debug = 0 |
1419 | - end |
1420 | - end |
1421 | - |
1422 | - # Set timing on or off. |
1423 | - def self.timing(bit) |
1424 | - if bit |
1425 | - case bit |
1426 | - when TrueClass; @@timing = 1 |
1427 | - when Fixnum |
1428 | - if bit > 0 |
1429 | - @@timing = 1 |
1430 | - else |
1431 | - @@timing = 0 |
1432 | - end |
1433 | - end |
1434 | - else |
1435 | - @@timing = 0 |
1436 | - end |
1437 | - end |
1438 | - |
1439 | - def self.warn(msg) |
1440 | - if Facter.debugging? and msg and not msg.empty? |
1441 | - msg = [msg] unless msg.respond_to? :each |
1442 | - msg.each { |line| Kernel.warn line } |
1443 | - end |
1444 | - end |
1445 | - |
1446 | - # Warn once. |
1447 | - def self.warnonce(msg) |
1448 | - if msg and not msg.empty? and @@messages[msg].nil? |
1449 | - @@messages[msg] = true |
1450 | - Kernel.warn(msg) |
1451 | - end |
1452 | - end |
1453 | - |
1454 | - # Remove them all. |
1455 | - def self.reset |
1456 | - @collection = nil |
1457 | - end |
1458 | - |
1459 | - # Load all of the default facts, and then everything from disk. |
1460 | - def self.loadfacts |
1461 | - collection.load_all |
1462 | - end |
1463 | - |
1464 | - @search_path = [] |
1465 | - |
1466 | - # Register a directory to search through. |
1467 | - def self.search(*dirs) |
1468 | - @search_path += dirs |
1469 | - end |
1470 | - |
1471 | - # Return our registered search directories. |
1472 | - def self.search_path |
1473 | - @search_path.dup |
1474 | - end |
1475 | + # This is just so the other classes have the constant. |
1476 | + module Util; end |
1477 | + |
1478 | + require 'facter/util/fact' |
1479 | + require 'facter/util/collection' |
1480 | + |
1481 | + include Comparable |
1482 | + include Enumerable |
1483 | + |
1484 | + FACTERVERSION = '1.6.2' |
1485 | + # = Facter |
1486 | + # Functions as a hash of 'facts' you might care about about your |
1487 | + # system, such as mac address, IP address, Video card, etc. |
1488 | + # returns them dynamically |
1489 | + |
1490 | + # == Synopsis |
1491 | + # |
1492 | + # Generally, treat <tt>Facter</tt> as a hash: |
1493 | + # == Example |
1494 | + # require 'facter' |
1495 | + # puts Facter['operatingsystem'] |
1496 | + # |
1497 | + |
1498 | + # Set LANG to force i18n to C |
1499 | + # |
1500 | + ENV['LANG'] = 'C' |
1501 | + |
1502 | + GREEN = "[0;32m" |
1503 | + RESET = "[0m" |
1504 | + @@debug = 0 |
1505 | + @@timing = 0 |
1506 | + @@messages = {} |
1507 | + |
1508 | + # module methods |
1509 | + |
1510 | + def self.collection |
1511 | + unless defined?(@collection) and @collection |
1512 | + @collection = Facter::Util::Collection.new |
1513 | + end |
1514 | + @collection |
1515 | + end |
1516 | + |
1517 | + # Return the version of the library. |
1518 | + def self.version |
1519 | + return FACTERVERSION |
1520 | + end |
1521 | + |
1522 | + # Add some debugging |
1523 | + def self.debug(string) |
1524 | + if string.nil? |
1525 | + return |
1526 | + end |
1527 | + if self.debugging? |
1528 | + puts GREEN + string + RESET |
1529 | + end |
1530 | + end |
1531 | + |
1532 | + def self.debugging? |
1533 | + @@debug != 0 |
1534 | + end |
1535 | + |
1536 | + # show the timing information |
1537 | + def self.show_time(string) |
1538 | + puts "#{GREEN}#{string}#{RESET}" if string and Facter.timing? |
1539 | + end |
1540 | + |
1541 | + def self.timing? |
1542 | + @@timing != 0 |
1543 | + end |
1544 | + |
1545 | + # Return a fact object by name. If you use this, you still have to call |
1546 | + # 'value' on it to retrieve the actual value. |
1547 | + def self.[](name) |
1548 | + collection.fact(name) |
1549 | + end |
1550 | + |
1551 | + class << self |
1552 | + [:fact, :flush, :list, :value].each do |method| |
1553 | + define_method(method) do |*args| |
1554 | + collection.send(method, *args) |
1555 | + end |
1556 | + end |
1557 | + |
1558 | + [:list, :to_hash].each do |method| |
1559 | + define_method(method) do |*args| |
1560 | + collection.load_all |
1561 | + collection.send(method, *args) |
1562 | + end |
1563 | + end |
1564 | + end |
1565 | + |
1566 | + |
1567 | + # Add a resolution mechanism for a named fact. This does not distinguish |
1568 | + # between adding a new fact and adding a new way to resolve a fact. |
1569 | + def self.add(name, options = {}, &block) |
1570 | + collection.add(name, options, &block) |
1571 | + end |
1572 | + |
1573 | + def self.each |
1574 | + # Make sure all facts are loaded. |
1575 | + collection.load_all |
1576 | + |
1577 | + collection.each do |*args| |
1578 | + yield(*args) |
1579 | + end |
1580 | + end |
1581 | + |
1582 | + class << self |
1583 | + # Allow users to call fact names directly on the Facter class, |
1584 | + # either retrieving the value or comparing it to an existing value. |
1585 | + def method_missing(name, *args) |
1586 | + question = false |
1587 | + if name.to_s =~ /\?$/ |
1588 | + question = true |
1589 | + name = name.to_s.sub(/\?$/,'') |
1590 | + end |
1591 | + |
1592 | + if fact = collection.fact(name) |
1593 | + if question |
1594 | + value = fact.value.downcase |
1595 | + args.each do |arg| |
1596 | + if arg.to_s.downcase == value |
1597 | + return true |
1598 | + end |
1599 | + end |
1600 | + |
1601 | + # If we got this far, there was no match. |
1602 | + return false |
1603 | + else |
1604 | + return fact.value |
1605 | + end |
1606 | + else |
1607 | + # Else, fail like a normal missing method. |
1608 | + raise NoMethodError, "Could not find fact '%s'" % name |
1609 | + end |
1610 | + end |
1611 | + end |
1612 | + |
1613 | + # Clear all facts. Mostly used for testing. |
1614 | + def self.clear |
1615 | + Facter.flush |
1616 | + Facter.reset |
1617 | + end |
1618 | + |
1619 | + # Clear all messages. Used only in testing. Can't add to self.clear |
1620 | + # because we don't want to warn multiple times for items that are warnonce'd |
1621 | + def self.clear_messages |
1622 | + @@messages.clear |
1623 | + end |
1624 | + |
1625 | + # Set debugging on or off. |
1626 | + def self.debugging(bit) |
1627 | + if bit |
1628 | + case bit |
1629 | + when TrueClass; @@debug = 1 |
1630 | + when FalseClass; @@debug = 0 |
1631 | + when Fixnum |
1632 | + if bit > 0 |
1633 | + @@debug = 1 |
1634 | + else |
1635 | + @@debug = 0 |
1636 | + end |
1637 | + when String; |
1638 | + if bit.downcase == 'off' |
1639 | + @@debug = 0 |
1640 | + else |
1641 | + @@debug = 1 |
1642 | + end |
1643 | + else |
1644 | + @@debug = 0 |
1645 | + end |
1646 | + else |
1647 | + @@debug = 0 |
1648 | + end |
1649 | + end |
1650 | + |
1651 | + # Set timing on or off. |
1652 | + def self.timing(bit) |
1653 | + if bit |
1654 | + case bit |
1655 | + when TrueClass; @@timing = 1 |
1656 | + when Fixnum |
1657 | + if bit > 0 |
1658 | + @@timing = 1 |
1659 | + else |
1660 | + @@timing = 0 |
1661 | + end |
1662 | + end |
1663 | + else |
1664 | + @@timing = 0 |
1665 | + end |
1666 | + end |
1667 | + |
1668 | + def self.warn(msg) |
1669 | + if Facter.debugging? and msg and not msg.empty? |
1670 | + msg = [msg] unless msg.respond_to? :each |
1671 | + msg.each { |line| Kernel.warn line } |
1672 | + end |
1673 | + end |
1674 | + |
1675 | + # Warn once. |
1676 | + def self.warnonce(msg) |
1677 | + if msg and not msg.empty? and @@messages[msg].nil? |
1678 | + @@messages[msg] = true |
1679 | + Kernel.warn(msg) |
1680 | + end |
1681 | + end |
1682 | + |
1683 | + # Remove them all. |
1684 | + def self.reset |
1685 | + @collection = nil |
1686 | + end |
1687 | + |
1688 | + # Load all of the default facts, and then everything from disk. |
1689 | + def self.loadfacts |
1690 | + collection.load_all |
1691 | + end |
1692 | + |
1693 | + @search_path = [] |
1694 | + |
1695 | + # Register a directory to search through. |
1696 | + def self.search(*dirs) |
1697 | + @search_path += dirs |
1698 | + end |
1699 | + |
1700 | + # Return our registered search directories. |
1701 | + def self.search_path |
1702 | + @search_path.dup |
1703 | + end |
1704 | end |
1705 | |
1706 | === modified file 'lib/facter/Cfkey.rb' |
1707 | --- lib/facter/Cfkey.rb 2011-06-24 10:04:12 +0000 |
1708 | +++ lib/facter/Cfkey.rb 2011-11-14 19:37:34 +0000 |
1709 | @@ -14,29 +14,29 @@ |
1710 | ## |
1711 | |
1712 | Facter.add(:Cfkey) do |
1713 | - setcode do |
1714 | - value = nil |
1715 | - ["/usr/local/etc/cfkey.pub", |
1716 | - "/etc/cfkey.pub", |
1717 | - "/var/cfng/keys/localhost.pub", |
1718 | - "/var/cfengine/ppkeys/localhost.pub", |
1719 | - "/var/lib/cfengine/ppkeys/localhost.pub", |
1720 | - "/var/lib/cfengine2/ppkeys/localhost.pub" |
1721 | - ].each do |file| |
1722 | - if FileTest.file?(file) |
1723 | - File.open(file) { |openfile| |
1724 | - value = openfile.readlines.reject { |line| |
1725 | - line =~ /PUBLIC KEY/ |
1726 | - }.collect { |line| |
1727 | - line.chomp |
1728 | - }.join("") |
1729 | - } |
1730 | - end |
1731 | - if value |
1732 | - break |
1733 | - end |
1734 | - end |
1735 | - |
1736 | - value |
1737 | + setcode do |
1738 | + value = nil |
1739 | + ["/usr/local/etc/cfkey.pub", |
1740 | + "/etc/cfkey.pub", |
1741 | + "/var/cfng/keys/localhost.pub", |
1742 | + "/var/cfengine/ppkeys/localhost.pub", |
1743 | + "/var/lib/cfengine/ppkeys/localhost.pub", |
1744 | + "/var/lib/cfengine2/ppkeys/localhost.pub" |
1745 | + ].each do |file| |
1746 | + if FileTest.file?(file) |
1747 | + File.open(file) { |openfile| |
1748 | + value = openfile.readlines.reject { |line| |
1749 | + line =~ /PUBLIC KEY/ |
1750 | + }.collect { |line| |
1751 | + line.chomp |
1752 | + }.join("") |
1753 | + } |
1754 | + end |
1755 | + if value |
1756 | + break |
1757 | + end |
1758 | end |
1759 | + |
1760 | + value |
1761 | + end |
1762 | end |
1763 | |
1764 | === modified file 'lib/facter/architecture.rb' |
1765 | --- lib/facter/architecture.rb 2011-06-24 10:04:12 +0000 |
1766 | +++ lib/facter/architecture.rb 2011-11-14 19:37:34 +0000 |
1767 | @@ -12,35 +12,27 @@ |
1768 | # |
1769 | |
1770 | Facter.add(:architecture) do |
1771 | - confine :kernel => [:linux, :"gnu/kfreebsd"] |
1772 | - setcode do |
1773 | - model = Facter.value(:hardwaremodel) |
1774 | - case model |
1775 | - # most linuxen use "x86_64" |
1776 | - when "x86_64" |
1777 | - case Facter.value(:operatingsystem) |
1778 | - when "Debian", "Gentoo", "GNU/kFreeBSD" |
1779 | - "amd64" |
1780 | - else |
1781 | - model |
1782 | - end |
1783 | - when /(i[3456]86|pentium)/ |
1784 | - case Facter.value(:operatingsystem) |
1785 | - when "Gentoo" |
1786 | - "x86" |
1787 | - else |
1788 | - "i386" |
1789 | - end |
1790 | - else |
1791 | - model |
1792 | - end |
1793 | - end |
1794 | -end |
1795 | - |
1796 | -Facter.add(:architecture) do |
1797 | - confine :kernel => :openbsd |
1798 | - setcode do |
1799 | - architecture = Facter.value(:hardwaremodel) |
1800 | - end |
1801 | + setcode do |
1802 | + model = Facter.value(:hardwaremodel) |
1803 | + case model |
1804 | + # most linuxen use "x86_64" |
1805 | + when "x86_64" |
1806 | + case Facter.value(:operatingsystem) |
1807 | + when "Debian", "Gentoo", "GNU/kFreeBSD", "Ubuntu" |
1808 | + "amd64" |
1809 | + else |
1810 | + model |
1811 | + end |
1812 | + when /(i[3456]86|pentium)/ |
1813 | + case Facter.value(:operatingsystem) |
1814 | + when "Gentoo" |
1815 | + "x86" |
1816 | + else |
1817 | + "i386" |
1818 | + end |
1819 | + else |
1820 | + model |
1821 | + end |
1822 | + end |
1823 | end |
1824 | |
1825 | |
1826 | === modified file 'lib/facter/domain.rb' |
1827 | --- lib/facter/domain.rb 2011-10-06 10:48:30 +0000 |
1828 | +++ lib/facter/domain.rb 2011-11-14 19:37:34 +0000 |
1829 | @@ -19,45 +19,45 @@ |
1830 | # |
1831 | |
1832 | Facter.add(:domain) do |
1833 | - setcode do |
1834 | - # Get the domain from various sources; the order of these |
1835 | - # steps is important |
1836 | - |
1837 | - if name = Facter::Util::Resolution.exec('hostname') and |
1838 | - name =~ /.*?\.(.+$)/ |
1839 | - |
1840 | - $1 |
1841 | - elsif domain = Facter::Util::Resolution.exec('dnsdomainname') and |
1842 | - domain =~ /.+\..+/ |
1843 | - |
1844 | - domain |
1845 | - elsif FileTest.exists?("/etc/resolv.conf") |
1846 | - domain = nil |
1847 | - search = nil |
1848 | - File.open("/etc/resolv.conf") { |file| |
1849 | - file.each { |line| |
1850 | - if line =~ /domain\s+(\S+)/ |
1851 | - domain = $1 |
1852 | - elsif line =~ /search\s+(\S+)/ |
1853 | - search = $1 |
1854 | - end |
1855 | - } |
1856 | - } |
1857 | - next domain if domain |
1858 | - next search if search |
1859 | - end |
1860 | - end |
1861 | -end |
1862 | - |
1863 | -Facter.add(:domain) do |
1864 | - confine :kernel => :windows |
1865 | - setcode do |
1866 | - require 'facter/util/wmi' |
1867 | - domain = "" |
1868 | - Facter::Util::WMI.execquery("select DNSDomain from Win32_NetworkAdapterConfiguration where IPEnabled = True").each { |nic| |
1869 | - domain = nic.DNSDomain |
1870 | - break |
1871 | + setcode do |
1872 | + # Get the domain from various sources; the order of these |
1873 | + # steps is important |
1874 | + |
1875 | + if name = Facter::Util::Resolution.exec('hostname') and |
1876 | + name =~ /.*?\.(.+$)/ |
1877 | + |
1878 | + $1 |
1879 | + elsif domain = Facter::Util::Resolution.exec('dnsdomainname') and |
1880 | + domain =~ /.+\..+/ |
1881 | + |
1882 | + domain |
1883 | + elsif FileTest.exists?("/etc/resolv.conf") |
1884 | + domain = nil |
1885 | + search = nil |
1886 | + File.open("/etc/resolv.conf") { |file| |
1887 | + file.each { |line| |
1888 | + if line =~ /^\s*domain\s+(\S+)/ |
1889 | + domain = $1 |
1890 | + elsif line =~ /^\s*search\s+(\S+)/ |
1891 | + search = $1 |
1892 | + end |
1893 | } |
1894 | - domain |
1895 | + } |
1896 | + next domain if domain |
1897 | + next search if search |
1898 | end |
1899 | + end |
1900 | +end |
1901 | + |
1902 | +Facter.add(:domain) do |
1903 | + confine :kernel => :windows |
1904 | + setcode do |
1905 | + require 'facter/util/wmi' |
1906 | + domain = "" |
1907 | + Facter::Util::WMI.execquery("select DNSDomain from Win32_NetworkAdapterConfiguration where IPEnabled = True").each { |nic| |
1908 | + domain = nic.DNSDomain |
1909 | + break |
1910 | + } |
1911 | + domain |
1912 | + end |
1913 | end |
1914 | |
1915 | === modified file 'lib/facter/facterversion.rb' |
1916 | --- lib/facter/facterversion.rb 2011-06-24 10:04:12 +0000 |
1917 | +++ lib/facter/facterversion.rb 2011-11-14 19:37:34 +0000 |
1918 | @@ -8,5 +8,5 @@ |
1919 | # |
1920 | |
1921 | Facter.add(:facterversion) do |
1922 | - setcode { Facter::FACTERVERSION.to_s } |
1923 | + setcode { Facter::FACTERVERSION.to_s } |
1924 | end |
1925 | |
1926 | === modified file 'lib/facter/fqdn.rb' |
1927 | --- lib/facter/fqdn.rb 2011-06-24 10:04:12 +0000 |
1928 | +++ lib/facter/fqdn.rb 2011-11-14 19:37:34 +0000 |
1929 | @@ -10,13 +10,13 @@ |
1930 | # |
1931 | |
1932 | Facter.add(:fqdn) do |
1933 | - setcode do |
1934 | - host = Facter.value(:hostname) |
1935 | - domain = Facter.value(:domain) |
1936 | - if host and domain |
1937 | - [host, domain].join(".") |
1938 | - else |
1939 | - nil |
1940 | - end |
1941 | + setcode do |
1942 | + host = Facter.value(:hostname) |
1943 | + domain = Facter.value(:domain) |
1944 | + if host and domain |
1945 | + [host, domain].join(".") |
1946 | + else |
1947 | + nil |
1948 | end |
1949 | + end |
1950 | end |
1951 | |
1952 | === modified file 'lib/facter/hardwareisa.rb' |
1953 | --- lib/facter/hardwareisa.rb 2011-10-06 10:48:30 +0000 |
1954 | +++ lib/facter/hardwareisa.rb 2011-11-14 19:37:34 +0000 |
1955 | @@ -11,6 +11,6 @@ |
1956 | # |
1957 | |
1958 | Facter.add(:hardwareisa) do |
1959 | - setcode 'uname -p' |
1960 | - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD OEL OracleLinux OVS GNU/kFreeBSD} |
1961 | + setcode 'uname -p' |
1962 | + confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD DragonFly OEL OracleLinux OVS GNU/kFreeBSD} |
1963 | end |
1964 | |
1965 | === modified file 'lib/facter/hardwaremodel.rb' |
1966 | --- lib/facter/hardwaremodel.rb 2011-06-24 10:04:12 +0000 |
1967 | +++ lib/facter/hardwaremodel.rb 2011-11-14 19:37:34 +0000 |
1968 | @@ -12,23 +12,23 @@ |
1969 | # |
1970 | |
1971 | Facter.add(:hardwaremodel) do |
1972 | - setcode 'uname -m' |
1973 | -end |
1974 | - |
1975 | -Facter.add(:hardwaremodel) do |
1976 | - confine :operatingsystem => :aix |
1977 | - setcode do |
1978 | - model = Facter::Util::Resolution.exec('lsattr -El sys0 -a modelname') |
1979 | - if model =~ /modelname\s(\S+)\s/ |
1980 | - $1 |
1981 | - end |
1982 | - end |
1983 | -end |
1984 | - |
1985 | -Facter.add(:hardwaremodel) do |
1986 | - confine :operatingsystem => :windows |
1987 | - setcode do |
1988 | - require 'rbconfig' |
1989 | - Config::CONFIG['host_cpu'] |
1990 | - end |
1991 | + setcode 'uname -m' |
1992 | +end |
1993 | + |
1994 | +Facter.add(:hardwaremodel) do |
1995 | + confine :operatingsystem => :aix |
1996 | + setcode do |
1997 | + model = Facter::Util::Resolution.exec('lsattr -El sys0 -a modelname') |
1998 | + if model =~ /modelname\s(\S+)\s/ |
1999 | + $1 |
2000 | + end |
2001 | + end |
2002 | +end |
2003 | + |
2004 | +Facter.add(:hardwaremodel) do |
2005 | + confine :operatingsystem => :windows |
2006 | + setcode do |
2007 | + require 'rbconfig' |
2008 | + Config::CONFIG['host_cpu'] |
2009 | + end |
2010 | end |
2011 | |
2012 | === modified file 'lib/facter/hostname.rb' |
2013 | --- lib/facter/hostname.rb 2011-10-06 10:48:30 +0000 |
2014 | +++ lib/facter/hostname.rb 2011-11-14 19:37:34 +0000 |
2015 | @@ -12,22 +12,22 @@ |
2016 | # |
2017 | |
2018 | Facter.add(:hostname, :ldapname => "cn") do |
2019 | - setcode do |
2020 | - hostname = nil |
2021 | - if name = Facter::Util::Resolution.exec('hostname') |
2022 | - if name =~ /(.*?)\./ |
2023 | - hostname = $1 |
2024 | - else |
2025 | - hostname = name |
2026 | - end |
2027 | - end |
2028 | - hostname |
2029 | + setcode do |
2030 | + hostname = nil |
2031 | + if name = Facter::Util::Resolution.exec('hostname') |
2032 | + if name =~ /(.*?)\./ |
2033 | + hostname = $1 |
2034 | + else |
2035 | + hostname = name |
2036 | + end |
2037 | end |
2038 | + hostname |
2039 | + end |
2040 | end |
2041 | |
2042 | Facter.add(:hostname) do |
2043 | - confine :kernel => :darwin, :kernelrelease => "R7" |
2044 | - setcode do |
2045 | - Facter::Util::Resolution.exec('/usr/sbin/scutil --get LocalHostName') |
2046 | - end |
2047 | + confine :kernel => :darwin, :kernelrelease => "R7" |
2048 | + setcode do |
2049 | + Facter::Util::Resolution.exec('/usr/sbin/scutil --get LocalHostName') |
2050 | + end |
2051 | end |
2052 | |
2053 | === modified file 'lib/facter/id.rb' |
2054 | --- lib/facter/id.rb 2011-06-24 10:04:12 +0000 |
2055 | +++ lib/facter/id.rb 2011-11-14 19:37:34 +0000 |
2056 | @@ -12,10 +12,10 @@ |
2057 | # |
2058 | |
2059 | Facter.add(:id) do |
2060 | - setcode "whoami" |
2061 | + setcode "whoami" |
2062 | end |
2063 | |
2064 | Facter.add(:id) do |
2065 | - confine :kernel => :SunOS |
2066 | - setcode "/usr/xpg4/bin/id -un" |
2067 | + confine :kernel => :SunOS |
2068 | + setcode "/usr/xpg4/bin/id -un" |
2069 | end |
2070 | |
2071 | === modified file 'lib/facter/interfaces.rb' |
2072 | --- lib/facter/interfaces.rb 2011-06-24 10:04:12 +0000 |
2073 | +++ lib/facter/interfaces.rb 2011-11-14 19:37:34 +0000 |
2074 | @@ -20,22 +20,22 @@ |
2075 | # is missing. |
2076 | |
2077 | Facter.add(:interfaces) do |
2078 | - confine :kernel => Facter::Util::IP.supported_platforms |
2079 | - setcode do |
2080 | - Facter::Util::IP.get_interfaces.collect { |iface| Facter::Util::IP.alphafy(iface) }.join(",") |
2081 | - end |
2082 | + confine :kernel => Facter::Util::IP.supported_platforms |
2083 | + setcode do |
2084 | + Facter::Util::IP.get_interfaces.collect { |iface| Facter::Util::IP.alphafy(iface) }.join(",") |
2085 | + end |
2086 | end |
2087 | |
2088 | Facter::Util::IP.get_interfaces.each do |interface| |
2089 | |
2090 | - # Make a fact for each detail of each interface. Yay. |
2091 | - # There's no point in confining these facts, since we wouldn't be able to create |
2092 | - # them if we weren't running on a supported platform. |
2093 | - %w{ipaddress ipaddress6 macaddress netmask}.each do |label| |
2094 | - Facter.add(label + "_" + Facter::Util::IP.alphafy(interface)) do |
2095 | - setcode do |
2096 | - Facter::Util::IP.get_interface_value(interface, label) |
2097 | - end |
2098 | - end |
2099 | + # Make a fact for each detail of each interface. Yay. |
2100 | + # There's no point in confining these facts, since we wouldn't be able to create |
2101 | + # them if we weren't running on a supported platform. |
2102 | + %w{ipaddress ipaddress6 macaddress netmask}.each do |label| |
2103 | + Facter.add(label + "_" + Facter::Util::IP.alphafy(interface)) do |
2104 | + setcode do |
2105 | + Facter::Util::IP.get_interface_value(interface, label) |
2106 | + end |
2107 | end |
2108 | + end |
2109 | end |
2110 | |
2111 | === modified file 'lib/facter/ipaddress.rb' |
2112 | --- lib/facter/ipaddress.rb 2011-06-24 10:04:12 +0000 |
2113 | +++ lib/facter/ipaddress.rb 2011-11-14 19:37:34 +0000 |
2114 | @@ -23,138 +23,138 @@ |
2115 | # |
2116 | |
2117 | Facter.add(:ipaddress) do |
2118 | - confine :kernel => :linux |
2119 | - setcode do |
2120 | - ip = nil |
2121 | - output = %x{/sbin/ifconfig} |
2122 | - |
2123 | - output.split(/^\S/).each { |str| |
2124 | - if str =~ /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
2125 | - tmp = $1 |
2126 | - unless tmp =~ /^127\./ |
2127 | - ip = tmp |
2128 | - break |
2129 | - end |
2130 | - end |
2131 | - } |
2132 | - |
2133 | - ip |
2134 | - end |
2135 | -end |
2136 | - |
2137 | -Facter.add(:ipaddress) do |
2138 | - confine :kernel => %w{FreeBSD OpenBSD Darwin} |
2139 | - setcode do |
2140 | - ip = nil |
2141 | - output = %x{/sbin/ifconfig} |
2142 | - |
2143 | - output.split(/^\S/).each { |str| |
2144 | - if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
2145 | - tmp = $1 |
2146 | - unless tmp =~ /^127\./ |
2147 | - ip = tmp |
2148 | - break |
2149 | - end |
2150 | - end |
2151 | - } |
2152 | - |
2153 | - ip |
2154 | - end |
2155 | -end |
2156 | - |
2157 | -Facter.add(:ipaddress) do |
2158 | - confine :kernel => %w{NetBSD SunOS} |
2159 | - setcode do |
2160 | - ip = nil |
2161 | - output = %x{/sbin/ifconfig -a} |
2162 | - |
2163 | - output.split(/^\S/).each { |str| |
2164 | - if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
2165 | - tmp = $1 |
2166 | - unless tmp =~ /^127\./ or tmp == "0.0.0.0" |
2167 | - ip = tmp |
2168 | - break |
2169 | - end |
2170 | - end |
2171 | - } |
2172 | - |
2173 | - ip |
2174 | - end |
2175 | -end |
2176 | - |
2177 | -Facter.add(:ipaddress) do |
2178 | - confine :kernel => %w{AIX} |
2179 | - setcode do |
2180 | - ip = nil |
2181 | - output = %x{/usr/sbin/ifconfig -a} |
2182 | - |
2183 | - output.split(/^\S/).each { |str| |
2184 | - if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
2185 | - tmp = $1 |
2186 | - unless tmp =~ /^127\./ |
2187 | - ip = tmp |
2188 | - break |
2189 | - end |
2190 | - end |
2191 | - } |
2192 | - |
2193 | - ip |
2194 | - end |
2195 | -end |
2196 | - |
2197 | -Facter.add(:ipaddress) do |
2198 | - confine :kernel => %w{windows} |
2199 | - setcode do |
2200 | - require 'socket' |
2201 | - IPSocket.getaddress(Socket.gethostname) |
2202 | - end |
2203 | + confine :kernel => :linux |
2204 | + setcode do |
2205 | + ip = nil |
2206 | + output = %x{/sbin/ifconfig} |
2207 | + |
2208 | + output.split(/^\S/).each { |str| |
2209 | + if str =~ /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
2210 | + tmp = $1 |
2211 | + unless tmp =~ /^127\./ |
2212 | + ip = tmp |
2213 | + break |
2214 | + end |
2215 | + end |
2216 | + } |
2217 | + |
2218 | + ip |
2219 | + end |
2220 | +end |
2221 | + |
2222 | +Facter.add(:ipaddress) do |
2223 | + confine :kernel => %w{FreeBSD OpenBSD Darwin DragonFly} |
2224 | + setcode do |
2225 | + ip = nil |
2226 | + output = %x{/sbin/ifconfig} |
2227 | + |
2228 | + output.split(/^\S/).each { |str| |
2229 | + if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
2230 | + tmp = $1 |
2231 | + unless tmp =~ /^127\./ |
2232 | + ip = tmp |
2233 | + break |
2234 | + end |
2235 | + end |
2236 | + } |
2237 | + |
2238 | + ip |
2239 | + end |
2240 | +end |
2241 | + |
2242 | +Facter.add(:ipaddress) do |
2243 | + confine :kernel => %w{NetBSD SunOS} |
2244 | + setcode do |
2245 | + ip = nil |
2246 | + output = %x{/sbin/ifconfig -a} |
2247 | + |
2248 | + output.split(/^\S/).each { |str| |
2249 | + if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
2250 | + tmp = $1 |
2251 | + unless tmp =~ /^127\./ or tmp == "0.0.0.0" |
2252 | + ip = tmp |
2253 | + break |
2254 | + end |
2255 | + end |
2256 | + } |
2257 | + |
2258 | + ip |
2259 | + end |
2260 | +end |
2261 | + |
2262 | +Facter.add(:ipaddress) do |
2263 | + confine :kernel => %w{AIX} |
2264 | + setcode do |
2265 | + ip = nil |
2266 | + output = %x{/usr/sbin/ifconfig -a} |
2267 | + |
2268 | + output.split(/^\S/).each { |str| |
2269 | + if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
2270 | + tmp = $1 |
2271 | + unless tmp =~ /^127\./ |
2272 | + ip = tmp |
2273 | + break |
2274 | + end |
2275 | + end |
2276 | + } |
2277 | + |
2278 | + ip |
2279 | + end |
2280 | +end |
2281 | + |
2282 | +Facter.add(:ipaddress) do |
2283 | + confine :kernel => %w{windows} |
2284 | + setcode do |
2285 | + require 'socket' |
2286 | + IPSocket.getaddress(Socket.gethostname) |
2287 | + end |
2288 | end |
2289 | |
2290 | Facter.add(:ipaddress, :ldapname => "iphostnumber", :timeout => 2) do |
2291 | - setcode do |
2292 | + setcode do |
2293 | + if Facter.value(:kernel) == 'windows' |
2294 | + require 'win32/resolv' |
2295 | + else |
2296 | + require 'resolv' |
2297 | + end |
2298 | + |
2299 | + begin |
2300 | + if hostname = Facter.value(:hostname) |
2301 | if Facter.value(:kernel) == 'windows' |
2302 | - require 'win32/resolv' |
2303 | + ip = Win32::Resolv.get_resolv_info.last[0] |
2304 | else |
2305 | - require 'resolv' |
2306 | - end |
2307 | - |
2308 | - begin |
2309 | - if hostname = Facter.value(:hostname) |
2310 | - if Facter.value(:kernel) == 'windows' |
2311 | - ip = Win32::Resolv.get_resolv_info.last[0] |
2312 | - else |
2313 | - ip = Resolv.getaddress(hostname) |
2314 | - end |
2315 | - unless ip == "127.0.0.1" |
2316 | - ip |
2317 | - end |
2318 | - else |
2319 | - nil |
2320 | - end |
2321 | - rescue Resolv::ResolvError |
2322 | - nil |
2323 | - rescue NoMethodError # i think this is a bug in resolv.rb? |
2324 | - nil |
2325 | - end |
2326 | + ip = Resolv.getaddress(hostname) |
2327 | + end |
2328 | + unless ip == "127.0.0.1" |
2329 | + ip |
2330 | + end |
2331 | + else |
2332 | + nil |
2333 | + end |
2334 | + rescue Resolv::ResolvError |
2335 | + nil |
2336 | + rescue NoMethodError # i think this is a bug in resolv.rb? |
2337 | + nil |
2338 | end |
2339 | + end |
2340 | end |
2341 | |
2342 | Facter.add(:ipaddress, :timeout => 2) do |
2343 | - setcode do |
2344 | - if hostname = Facter.value(:hostname) |
2345 | - # we need Hostname to exist for this to work |
2346 | - host = nil |
2347 | - if host = Facter::Util::Resolution.exec("host #{hostname}") |
2348 | - list = host.chomp.split(/\s/) |
2349 | - if defined? list[-1] and |
2350 | - list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ |
2351 | - list[-1] |
2352 | - end |
2353 | - else |
2354 | - nil |
2355 | - end |
2356 | - else |
2357 | - nil |
2358 | + setcode do |
2359 | + if hostname = Facter.value(:hostname) |
2360 | + # we need Hostname to exist for this to work |
2361 | + host = nil |
2362 | + if host = Facter::Util::Resolution.exec("host #{hostname}") |
2363 | + list = host.chomp.split(/\s/) |
2364 | + if defined? list[-1] and |
2365 | + list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ |
2366 | + list[-1] |
2367 | end |
2368 | + else |
2369 | + nil |
2370 | + end |
2371 | + else |
2372 | + nil |
2373 | end |
2374 | + end |
2375 | end |
2376 | |
2377 | === modified file 'lib/facter/iphostnumber.rb' |
2378 | --- lib/facter/iphostnumber.rb 2011-06-24 10:04:12 +0000 |
2379 | +++ lib/facter/iphostnumber.rb 2011-11-14 19:37:34 +0000 |
2380 | @@ -10,20 +10,20 @@ |
2381 | # |
2382 | |
2383 | Facter.add(:iphostnumber) do |
2384 | - confine :kernel => :darwin, :kernelrelease => "R6" |
2385 | - setcode do |
2386 | - %x{/usr/sbin/scutil --get LocalHostName} |
2387 | - end |
2388 | + confine :kernel => :darwin, :kernelrelease => "R6" |
2389 | + setcode do |
2390 | + %x{/usr/sbin/scutil --get LocalHostName} |
2391 | + end |
2392 | end |
2393 | Facter.add(:iphostnumber) do |
2394 | - confine :kernel => :darwin, :kernelrelease => "R6" |
2395 | - setcode do |
2396 | - ether = nil |
2397 | - output = %x{/sbin/ifconfig} |
2398 | - |
2399 | - output =~ /HWaddr (\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ |
2400 | - ether = $1 |
2401 | - |
2402 | - ether |
2403 | - end |
2404 | + confine :kernel => :darwin, :kernelrelease => "R6" |
2405 | + setcode do |
2406 | + ether = nil |
2407 | + output = %x{/sbin/ifconfig} |
2408 | + |
2409 | + output =~ /HWaddr (\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ |
2410 | + ether = $1 |
2411 | + |
2412 | + ether |
2413 | + end |
2414 | end |
2415 | |
2416 | === modified file 'lib/facter/kernel.rb' |
2417 | --- lib/facter/kernel.rb 2011-10-06 10:48:30 +0000 |
2418 | +++ lib/facter/kernel.rb 2011-11-14 19:37:34 +0000 |
2419 | @@ -10,13 +10,13 @@ |
2420 | # |
2421 | |
2422 | Facter.add(:kernel) do |
2423 | - setcode do |
2424 | - require 'facter/util/config' |
2425 | + setcode do |
2426 | + require 'facter/util/config' |
2427 | |
2428 | - if Facter::Util::Config.is_windows? |
2429 | - 'windows' |
2430 | - else |
2431 | - Facter::Util::Resolution.exec("uname -s") |
2432 | - end |
2433 | + if Facter::Util::Config.is_windows? |
2434 | + 'windows' |
2435 | + else |
2436 | + Facter::Util::Resolution.exec("uname -s") |
2437 | end |
2438 | + end |
2439 | end |
2440 | |
2441 | === modified file 'lib/facter/kernelmajversion.rb' |
2442 | --- lib/facter/kernelmajversion.rb 2011-06-24 10:04:12 +0000 |
2443 | +++ lib/facter/kernelmajversion.rb 2011-11-14 19:37:34 +0000 |
2444 | @@ -9,7 +9,7 @@ |
2445 | # |
2446 | |
2447 | Facter.add("kernelmajversion") do |
2448 | - setcode do |
2449 | - Facter.value(:kernelversion).split('.')[0..1].join('.') |
2450 | - end |
2451 | + setcode do |
2452 | + Facter.value(:kernelversion).split('.')[0..1].join('.') |
2453 | + end |
2454 | end |
2455 | |
2456 | === modified file 'lib/facter/kernelrelease.rb' |
2457 | --- lib/facter/kernelrelease.rb 2011-10-06 10:48:30 +0000 |
2458 | +++ lib/facter/kernelrelease.rb 2011-11-14 19:37:34 +0000 |
2459 | @@ -12,23 +12,23 @@ |
2460 | # |
2461 | |
2462 | Facter.add(:kernelrelease) do |
2463 | - setcode 'uname -r' |
2464 | -end |
2465 | - |
2466 | -Facter.add(:kernelrelease) do |
2467 | - confine :kernel => :aix |
2468 | - setcode 'oslevel -s' |
2469 | -end |
2470 | - |
2471 | -Facter.add(:kernelrelease) do |
2472 | - confine :kernel => %{windows} |
2473 | - setcode do |
2474 | - require 'facter/util/wmi' |
2475 | - version = "" |
2476 | - Facter::Util::WMI.execquery("SELECT Version from Win32_OperatingSystem").each do |ole| |
2477 | - version = "#{ole.Version}" |
2478 | - break |
2479 | - end |
2480 | - version |
2481 | + setcode 'uname -r' |
2482 | +end |
2483 | + |
2484 | +Facter.add(:kernelrelease) do |
2485 | + confine :kernel => :aix |
2486 | + setcode 'oslevel -s' |
2487 | +end |
2488 | + |
2489 | +Facter.add(:kernelrelease) do |
2490 | + confine :kernel => %{windows} |
2491 | + setcode do |
2492 | + require 'facter/util/wmi' |
2493 | + version = "" |
2494 | + Facter::Util::WMI.execquery("SELECT Version from Win32_OperatingSystem").each do |ole| |
2495 | + version = "#{ole.Version}" |
2496 | + break |
2497 | end |
2498 | + version |
2499 | + end |
2500 | end |
2501 | |
2502 | === modified file 'lib/facter/kernelversion.rb' |
2503 | --- lib/facter/kernelversion.rb 2011-06-24 10:04:12 +0000 |
2504 | +++ lib/facter/kernelversion.rb 2011-11-14 19:37:34 +0000 |
2505 | @@ -11,12 +11,12 @@ |
2506 | # |
2507 | |
2508 | Facter.add("kernelversion") do |
2509 | - setcode do |
2510 | - Facter['kernelrelease'].value.split('-')[0] |
2511 | - end |
2512 | + setcode do |
2513 | + Facter['kernelrelease'].value.split('-')[0] |
2514 | + end |
2515 | end |
2516 | |
2517 | Facter.add("kernelversion") do |
2518 | - confine :kernel => :sunos |
2519 | - setcode 'uname -v' |
2520 | + confine :kernel => :sunos |
2521 | + setcode 'uname -v' |
2522 | end |
2523 | |
2524 | === modified file 'lib/facter/lsb.rb' |
2525 | --- lib/facter/lsb.rb 2011-06-24 10:04:12 +0000 |
2526 | +++ lib/facter/lsb.rb 2011-11-14 19:37:34 +0000 |
2527 | @@ -20,20 +20,20 @@ |
2528 | "LSBDistDescription" => %r{^Description:\t(.*)$}, |
2529 | "LSBDistCodeName" => %r{^Codename:\t(.*)$} |
2530 | }.each do |fact, pattern| |
2531 | - Facter.add(fact) do |
2532 | - confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
2533 | - setcode do |
2534 | - unless defined?(lsbdata) and defined?(lsbtime) and (Time.now.to_i - lsbtime.to_i < 5) |
2535 | - type = nil |
2536 | - lsbtime = Time.now |
2537 | - lsbdata = Facter::Util::Resolution.exec('lsb_release -a 2>/dev/null') |
2538 | - end |
2539 | + Facter.add(fact) do |
2540 | + confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
2541 | + setcode do |
2542 | + unless defined?(lsbdata) and defined?(lsbtime) and (Time.now.to_i - lsbtime.to_i < 5) |
2543 | + type = nil |
2544 | + lsbtime = Time.now |
2545 | + lsbdata = Facter::Util::Resolution.exec('lsb_release -a 2>/dev/null') |
2546 | + end |
2547 | |
2548 | - if pattern.match(lsbdata) |
2549 | - $1 |
2550 | - else |
2551 | - nil |
2552 | - end |
2553 | - end |
2554 | + if pattern.match(lsbdata) |
2555 | + $1 |
2556 | + else |
2557 | + nil |
2558 | + end |
2559 | end |
2560 | + end |
2561 | end |
2562 | |
2563 | === modified file 'lib/facter/lsbmajdistrelease.rb' |
2564 | --- lib/facter/lsbmajdistrelease.rb 2011-10-06 10:48:30 +0000 |
2565 | +++ lib/facter/lsbmajdistrelease.rb 2011-11-14 19:37:34 +0000 |
2566 | @@ -15,13 +15,13 @@ |
2567 | require 'facter' |
2568 | |
2569 | Facter.add("lsbmajdistrelease") do |
2570 | - confine :operatingsystem => %w{Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo OEL OracleLinux OVS GNU/kFreeBSD} |
2571 | - setcode do |
2572 | - if /(\d*)\./i =~ Facter.value(:lsbdistrelease) |
2573 | - result=$1 |
2574 | - else |
2575 | - result=Facter.value(:lsbdistrelease) |
2576 | - end |
2577 | - result |
2578 | + confine :operatingsystem => %w{Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo OEL OracleLinux OVS GNU/kFreeBSD} |
2579 | + setcode do |
2580 | + if /(\d*)\./i =~ Facter.value(:lsbdistrelease) |
2581 | + result=$1 |
2582 | + else |
2583 | + result=Facter.value(:lsbdistrelease) |
2584 | end |
2585 | + result |
2586 | + end |
2587 | end |
2588 | |
2589 | === modified file 'lib/facter/macaddress.rb' |
2590 | --- lib/facter/macaddress.rb 2011-10-06 10:48:30 +0000 |
2591 | +++ lib/facter/macaddress.rb 2011-11-14 19:37:34 +0000 |
2592 | @@ -10,69 +10,69 @@ |
2593 | require 'facter/util/macaddress' |
2594 | |
2595 | Facter.add(:macaddress) do |
2596 | - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Gentoo Ubuntu OEL OracleLinux OVS GNU/kFreeBSD} |
2597 | - setcode do |
2598 | - ether = [] |
2599 | - output = Facter::Util::Resolution.exec("/sbin/ifconfig -a") |
2600 | - output.each_line do |s| |
2601 | - ether.push($1) if s =~ /(?:ether|HWaddr) (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ |
2602 | - end |
2603 | - Facter::Util::Macaddress.standardize(ether[0]) |
2604 | - end |
2605 | -end |
2606 | - |
2607 | -Facter.add(:macaddress) do |
2608 | - confine :operatingsystem => "Solaris" |
2609 | - setcode do |
2610 | - ether = [] |
2611 | - output = Facter::Util::Resolution.exec("/usr/bin/netstat -np") |
2612 | - output.each_line do |s| |
2613 | - ether.push($1) if s =~ /(?:SPLA)\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/ |
2614 | - end |
2615 | - Facter::Util::Macaddress.standardize(ether[0]) |
2616 | - end |
2617 | -end |
2618 | - |
2619 | -Facter.add(:macaddress) do |
2620 | - confine :operatingsystem => %w{FreeBSD OpenBSD} |
2621 | - setcode do |
2622 | - ether = [] |
2623 | - output = Facter::Util::Resolution.exec("/sbin/ifconfig") |
2624 | - output.each_line do |s| |
2625 | - if s =~ /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ |
2626 | - ether.push($1) |
2627 | - end |
2628 | - end |
2629 | - Facter::Util::Macaddress.standardize(ether[0]) |
2630 | - end |
2631 | -end |
2632 | - |
2633 | -Facter.add(:macaddress) do |
2634 | - confine :kernel => :darwin |
2635 | - setcode { Facter::Util::Macaddress::Darwin.macaddress } |
2636 | -end |
2637 | - |
2638 | -Facter.add(:macaddress) do |
2639 | - confine :kernel => %w{AIX} |
2640 | - setcode do |
2641 | - ether = [] |
2642 | - ip = nil |
2643 | - output = %x{/usr/sbin/ifconfig -a} |
2644 | - output.each_line do |str| |
2645 | - if str =~ /([a-z]+\d+): flags=/ |
2646 | - devname = $1 |
2647 | - unless devname =~ /lo0/ |
2648 | - output2 = %x{/usr/bin/entstat #{devname}} |
2649 | - output2.each_line do |str2| |
2650 | - if str2 =~ /^Hardware Address: (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ |
2651 | - ether.push($1) |
2652 | - end |
2653 | - end |
2654 | - end |
2655 | - end |
2656 | - end |
2657 | - Facter::Util::Macaddress.standardize(ether[0]) |
2658 | - end |
2659 | + confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Gentoo Ubuntu OEL OracleLinux OVS GNU/kFreeBSD} |
2660 | + setcode do |
2661 | + ether = [] |
2662 | + output = Facter::Util::Resolution.exec("/sbin/ifconfig -a") |
2663 | + output.each_line do |s| |
2664 | + ether.push($1) if s =~ /(?:ether|HWaddr) (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ |
2665 | + end |
2666 | + Facter::Util::Macaddress.standardize(ether[0]) |
2667 | + end |
2668 | +end |
2669 | + |
2670 | +Facter.add(:macaddress) do |
2671 | + confine :operatingsystem => "Solaris" |
2672 | + setcode do |
2673 | + ether = [] |
2674 | + output = Facter::Util::Resolution.exec("/usr/bin/netstat -np") |
2675 | + output.each_line do |s| |
2676 | + ether.push($1) if s =~ /(?:SPLA)\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/ |
2677 | + end |
2678 | + Facter::Util::Macaddress.standardize(ether[0]) |
2679 | + end |
2680 | +end |
2681 | + |
2682 | +Facter.add(:macaddress) do |
2683 | + confine :operatingsystem => %w{FreeBSD OpenBSD DragonFly} |
2684 | + setcode do |
2685 | + ether = [] |
2686 | + output = Facter::Util::Resolution.exec("/sbin/ifconfig") |
2687 | + output.each_line do |s| |
2688 | + if s =~ /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ |
2689 | + ether.push($1) |
2690 | + end |
2691 | + end |
2692 | + Facter::Util::Macaddress.standardize(ether[0]) |
2693 | + end |
2694 | +end |
2695 | + |
2696 | +Facter.add(:macaddress) do |
2697 | + confine :kernel => :darwin |
2698 | + setcode { Facter::Util::Macaddress::Darwin.macaddress } |
2699 | +end |
2700 | + |
2701 | +Facter.add(:macaddress) do |
2702 | + confine :kernel => %w{AIX} |
2703 | + setcode do |
2704 | + ether = [] |
2705 | + ip = nil |
2706 | + output = %x{/usr/sbin/ifconfig -a} |
2707 | + output.each_line do |str| |
2708 | + if str =~ /([a-z]+\d+): flags=/ |
2709 | + devname = $1 |
2710 | + unless devname =~ /lo0/ |
2711 | + output2 = %x{/usr/bin/entstat #{devname}} |
2712 | + output2.each_line do |str2| |
2713 | + if str2 =~ /^Hardware Address: (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ |
2714 | + ether.push($1) |
2715 | + end |
2716 | + end |
2717 | + end |
2718 | + end |
2719 | + end |
2720 | + Facter::Util::Macaddress.standardize(ether[0]) |
2721 | + end |
2722 | end |
2723 | |
2724 | Facter.add(:macaddress) do |
2725 | |
2726 | === modified file 'lib/facter/macosx.rb' |
2727 | --- lib/facter/macosx.rb 2011-10-18 10:32:42 +0000 |
2728 | +++ lib/facter/macosx.rb 2011-11-14 19:37:34 +0000 |
2729 | @@ -27,30 +27,30 @@ |
2730 | require 'facter/util/macosx' |
2731 | |
2732 | if Facter.value(:kernel) == "Darwin" |
2733 | - Facter::Util::Macosx.hardware_overview.each do |fact, value| |
2734 | - Facter.add("sp_#{fact}") do |
2735 | - confine :kernel => :darwin |
2736 | - setcode do |
2737 | - value.to_s |
2738 | - end |
2739 | - end |
2740 | - end |
2741 | - |
2742 | - Facter::Util::Macosx.os_overview.each do |fact, value| |
2743 | - Facter.add("sp_#{fact}") do |
2744 | - confine :kernel => :darwin |
2745 | - setcode do |
2746 | - value.to_s |
2747 | - end |
2748 | - end |
2749 | - end |
2750 | - |
2751 | - Facter::Util::Macosx.sw_vers.each do |fact, value| |
2752 | - Facter.add(fact) do |
2753 | - confine :kernel => :darwin |
2754 | - setcode do |
2755 | - value |
2756 | - end |
2757 | - end |
2758 | - end |
2759 | + Facter::Util::Macosx.hardware_overview.each do |fact, value| |
2760 | + Facter.add("sp_#{fact}") do |
2761 | + confine :kernel => :darwin |
2762 | + setcode do |
2763 | + value.to_s |
2764 | + end |
2765 | + end |
2766 | + end |
2767 | + |
2768 | + Facter::Util::Macosx.os_overview.each do |fact, value| |
2769 | + Facter.add("sp_#{fact}") do |
2770 | + confine :kernel => :darwin |
2771 | + setcode do |
2772 | + value.to_s |
2773 | + end |
2774 | + end |
2775 | + end |
2776 | + |
2777 | + Facter::Util::Macosx.sw_vers.each do |fact, value| |
2778 | + Facter.add(fact) do |
2779 | + confine :kernel => :darwin |
2780 | + setcode do |
2781 | + value |
2782 | + end |
2783 | + end |
2784 | + end |
2785 | end |
2786 | |
2787 | === modified file 'lib/facter/manufacturer.rb' |
2788 | --- lib/facter/manufacturer.rb 2011-10-18 10:32:42 +0000 |
2789 | +++ lib/facter/manufacturer.rb 2011-11-14 19:37:34 +0000 |
2790 | @@ -19,39 +19,39 @@ |
2791 | require 'facter/util/manufacturer' |
2792 | |
2793 | if Facter.value(:kernel) == "OpenBSD" |
2794 | - mfg_keys = { |
2795 | - 'hw.vendor' => 'manufacturer', |
2796 | - 'hw.product' => 'productname', |
2797 | - 'hw.serialno' => 'serialnumber' |
2798 | - } |
2799 | + mfg_keys = { |
2800 | + 'hw.vendor' => 'manufacturer', |
2801 | + 'hw.product' => 'productname', |
2802 | + 'hw.serialno' => 'serialnumber' |
2803 | + } |
2804 | |
2805 | - Facter::Manufacturer.sysctl_find_system_info(mfg_keys) |
2806 | + Facter::Manufacturer.sysctl_find_system_info(mfg_keys) |
2807 | elsif Facter.value(:kernel) == "Darwin" |
2808 | - mfg_keys = { |
2809 | - 'hw.model' => 'productname' |
2810 | - } |
2811 | - Facter::Manufacturer.sysctl_find_system_info(mfg_keys) |
2812 | + mfg_keys = { |
2813 | + 'hw.model' => 'productname' |
2814 | + } |
2815 | + Facter::Manufacturer.sysctl_find_system_info(mfg_keys) |
2816 | elsif Facter.value(:kernel) == "SunOS" and Facter.value(:hardwareisa) == "sparc" |
2817 | - Facter::Manufacturer.prtdiag_sparc_find_system_info() |
2818 | + Facter::Manufacturer.prtdiag_sparc_find_system_info() |
2819 | elsif Facter.value(:kernel) == "windows" |
2820 | - win32_keys = { |
2821 | - 'manufacturer' => ['Manufacturer', 'Bios'], |
2822 | - 'serialNumber' => ['Serialnumber', 'Bios'], |
2823 | - 'productname' => ['Name', 'ComputerSystemProduct'] |
2824 | - } |
2825 | - Facter::Manufacturer.win32_find_system_info(win32_keys) |
2826 | + win32_keys = { |
2827 | + 'manufacturer' => ['Manufacturer', 'Bios'], |
2828 | + 'serialNumber' => ['Serialnumber', 'Bios'], |
2829 | + 'productname' => ['Name', 'ComputerSystemProduct'] |
2830 | + } |
2831 | + Facter::Manufacturer.win32_find_system_info(win32_keys) |
2832 | else |
2833 | - query = { |
2834 | - '[Ss]ystem [Ii]nformation' => [ |
2835 | - { 'Manufacturer:' => 'manufacturer' }, |
2836 | - { 'Product(?: Name)?:' => 'productname' }, |
2837 | - { 'Serial Number:' => 'serialnumber' } |
2838 | - ], |
2839 | - '(Chassis Information|system enclosure or chassis)' => [ |
2840 | - { '(?:Chassis )?Type:' => 'type' } |
2841 | - ] |
2842 | - } |
2843 | + query = { |
2844 | + '[Ss]ystem [Ii]nformation' => [ |
2845 | + { 'Manufacturer:' => 'manufacturer' }, |
2846 | + { 'Product(?: Name)?:' => 'productname' }, |
2847 | + { 'Serial Number:' => 'serialnumber' } |
2848 | + ], |
2849 | + '(Chassis Information|system enclosure or chassis)' => [ |
2850 | + { '(?:Chassis )?Type:' => 'type' } |
2851 | + ] |
2852 | + } |
2853 | |
2854 | - Facter::Manufacturer.dmi_find_system_info(query) |
2855 | + Facter::Manufacturer.dmi_find_system_info(query) |
2856 | end |
2857 | |
2858 | |
2859 | === modified file 'lib/facter/memory.rb' |
2860 | --- lib/facter/memory.rb 2011-10-06 10:48:30 +0000 |
2861 | +++ lib/facter/memory.rb 2011-11-14 19:37:34 +0000 |
2862 | @@ -29,182 +29,180 @@ |
2863 | :SwapSize => "SwapTotal", |
2864 | :SwapFree => "SwapFree" |
2865 | }.each do |fact, name| |
2866 | - Facter.add(fact) do |
2867 | - confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
2868 | - setcode do |
2869 | - Facter::Memory.meminfo_number(name) |
2870 | - end |
2871 | + Facter.add(fact) do |
2872 | + confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
2873 | + setcode do |
2874 | + Facter::Memory.meminfo_number(name) |
2875 | end |
2876 | + end |
2877 | end |
2878 | |
2879 | Facter.add("SwapSize") do |
2880 | - confine :kernel => :Darwin |
2881 | - setcode do |
2882 | + confine :kernel => :Darwin |
2883 | + setcode do |
2884 | swap = Facter::Util::Resolution.exec('sysctl vm.swapusage') |
2885 | swaptotal = 0 |
2886 | if swap =~ /total = (\S+)/ then swaptotal = $1; end |
2887 | - swaptotal |
2888 | - end |
2889 | + swaptotal |
2890 | + end |
2891 | end |
2892 | |
2893 | Facter.add("SwapFree") do |
2894 | - confine :kernel => :Darwin |
2895 | - setcode do |
2896 | + confine :kernel => :Darwin |
2897 | + setcode do |
2898 | swap = Facter::Util::Resolution.exec('sysctl vm.swapusage') |
2899 | swapfree = 0 |
2900 | if swap =~ /free = (\S+)/ then swapfree = $1; end |
2901 | - swapfree |
2902 | - end |
2903 | + swapfree |
2904 | + end |
2905 | end |
2906 | |
2907 | Facter.add("SwapEncrypted") do |
2908 | - confine :kernel => :Darwin |
2909 | - setcode do |
2910 | + confine :kernel => :Darwin |
2911 | + setcode do |
2912 | swap = Facter::Util::Resolution.exec('sysctl vm.swapusage') |
2913 | encrypted = false |
2914 | if swap =~ /\(encrypted\)/ then encrypted = true; end |
2915 | - encrypted |
2916 | - end |
2917 | + encrypted |
2918 | + end |
2919 | end |
2920 | |
2921 | if Facter.value(:kernel) == "AIX" and Facter.value(:id) == "root" |
2922 | - swap = Facter::Util::Resolution.exec('swap -l') |
2923 | - swapfree, swaptotal = 0, 0 |
2924 | - swap.each_line do |dev| |
2925 | - if dev =~ /^\/\S+\s.*\s+(\S+)MB\s+(\S+)MB/ |
2926 | - swaptotal += $1.to_i |
2927 | - swapfree += $2.to_i |
2928 | - end |
2929 | - end |
2930 | - |
2931 | - Facter.add("SwapSize") do |
2932 | - confine :kernel => :aix |
2933 | - setcode do |
2934 | - Facter::Memory.scale_number(swaptotal.to_f,"MB") |
2935 | - end |
2936 | - end |
2937 | - |
2938 | - Facter.add("SwapFree") do |
2939 | - confine :kernel => :aix |
2940 | - setcode do |
2941 | - Facter::Memory.scale_number(swapfree.to_f,"MB") |
2942 | - end |
2943 | - end |
2944 | + swap = Facter::Util::Resolution.exec('swap -l') |
2945 | + swapfree, swaptotal = 0, 0 |
2946 | + swap.each_line do |dev| |
2947 | + if dev =~ /^\/\S+\s.*\s+(\S+)MB\s+(\S+)MB/ |
2948 | + swaptotal += $1.to_i |
2949 | + swapfree += $2.to_i |
2950 | + end |
2951 | + end |
2952 | + |
2953 | + Facter.add("SwapSize") do |
2954 | + confine :kernel => :aix |
2955 | + setcode do |
2956 | + Facter::Memory.scale_number(swaptotal.to_f,"MB") |
2957 | + end |
2958 | + end |
2959 | + |
2960 | + Facter.add("SwapFree") do |
2961 | + confine :kernel => :aix |
2962 | + setcode do |
2963 | + Facter::Memory.scale_number(swapfree.to_f,"MB") |
2964 | + end |
2965 | + end |
2966 | end |
2967 | |
2968 | if Facter.value(:kernel) == "OpenBSD" |
2969 | - swap = Facter::Util::Resolution.exec('swapctl -l | sed 1d') |
2970 | - swapfree, swaptotal = 0, 0 |
2971 | - swap.each_line do |dev| |
2972 | - if dev =~ /^\S+\s+(\S+)\s+\S+\s+(\S+)\s+.*$/ |
2973 | - swaptotal += $1.to_i |
2974 | - swapfree += $2.to_i |
2975 | - end |
2976 | - end |
2977 | - |
2978 | - Facter.add("SwapSize") do |
2979 | - confine :kernel => :openbsd |
2980 | - setcode do |
2981 | - Facter::Memory.scale_number(swaptotal.to_f,"kB") |
2982 | - end |
2983 | - end |
2984 | - |
2985 | - Facter.add("SwapFree") do |
2986 | - confine :kernel => :openbsd |
2987 | - setcode do |
2988 | - Facter::Memory.scale_number(swapfree.to_f,"kB") |
2989 | - end |
2990 | - end |
2991 | - |
2992 | - Facter::Memory.vmstat_find_free_memory() |
2993 | - |
2994 | - Facter.add("MemoryTotal") do |
2995 | - confine :kernel => :openbsd |
2996 | - memtotal = Facter::Util::Resolution.exec("sysctl hw.physmem | cut -d'=' -f2") |
2997 | - setcode do |
2998 | - Facter::Memory.scale_number(memtotal.to_f,"") |
2999 | - end |
3000 | - end |
3001 | + swap = Facter::Util::Resolution.exec('swapctl -s') |
3002 | + swapfree, swaptotal = 0, 0 |
3003 | + if swap =~ /^total: (\d+)k bytes allocated = \d+k used, (\d+)k available$/ |
3004 | + swaptotal = $1.to_i |
3005 | + swapfree = $2.to_i |
3006 | + end |
3007 | + |
3008 | + Facter.add("SwapSize") do |
3009 | + confine :kernel => :openbsd |
3010 | + setcode do |
3011 | + Facter::Memory.scale_number(swaptotal.to_f,"kB") |
3012 | + end |
3013 | + end |
3014 | + |
3015 | + Facter.add("SwapFree") do |
3016 | + confine :kernel => :openbsd |
3017 | + setcode do |
3018 | + Facter::Memory.scale_number(swapfree.to_f,"kB") |
3019 | + end |
3020 | + end |
3021 | + |
3022 | + Facter::Memory.vmstat_find_free_memory() |
3023 | + |
3024 | + Facter.add("MemoryTotal") do |
3025 | + confine :kernel => :openbsd |
3026 | + memtotal = Facter::Util::Resolution.exec("sysctl hw.physmem | cut -d'=' -f2") |
3027 | + setcode do |
3028 | + Facter::Memory.scale_number(memtotal.to_f,"") |
3029 | + end |
3030 | + end |
3031 | end |
3032 | |
3033 | if Facter.value(:kernel) == "Darwin" |
3034 | - swap = Facter::Util::Resolution.exec('sysctl vm.swapusage') |
3035 | - swapfree, swaptotal = 0, 0 |
3036 | - unless swap.empty? |
3037 | - # Parse the line: |
3038 | - # vm.swapusage: total = 128.00M used = 0.37M free = 127.63M (encrypted) |
3039 | - if swap =~ /total\s=\s(\S+)\s+used\s=\s(\S+)\s+free\s=\s(\S+)\s/ |
3040 | - swaptotal += $1.to_i |
3041 | - swapfree += $3.to_i |
3042 | - end |
3043 | - end |
3044 | - |
3045 | - Facter.add("SwapSize") do |
3046 | - confine :kernel => :Darwin |
3047 | - setcode do |
3048 | - Facter::Memory.scale_number(swaptotal.to_f,"MB") |
3049 | - end |
3050 | - end |
3051 | - |
3052 | - Facter.add("SwapFree") do |
3053 | - confine :kernel => :Darwin |
3054 | - setcode do |
3055 | - Facter::Memory.scale_number(swapfree.to_f,"MB") |
3056 | - end |
3057 | - end |
3058 | - |
3059 | - Facter::Memory.vmstat_darwin_find_free_memory() |
3060 | - |
3061 | - Facter.add("MemoryTotal") do |
3062 | - confine :kernel => :Darwin |
3063 | - memtotal = Facter::Util::Resolution.exec("sysctl hw.memsize | cut -d':' -f2") |
3064 | - setcode do |
3065 | - Facter::Memory.scale_number(memtotal.to_f,"") |
3066 | - end |
3067 | - end |
3068 | + swap = Facter::Util::Resolution.exec('sysctl vm.swapusage') |
3069 | + swapfree, swaptotal = 0, 0 |
3070 | + unless swap.empty? |
3071 | + # Parse the line: |
3072 | + # vm.swapusage: total = 128.00M used = 0.37M free = 127.63M (encrypted) |
3073 | + if swap =~ /total\s=\s(\S+)\s+used\s=\s(\S+)\s+free\s=\s(\S+)\s/ |
3074 | + swaptotal += $1.to_i |
3075 | + swapfree += $3.to_i |
3076 | + end |
3077 | + end |
3078 | + |
3079 | + Facter.add("SwapSize") do |
3080 | + confine :kernel => :Darwin |
3081 | + setcode do |
3082 | + Facter::Memory.scale_number(swaptotal.to_f,"MB") |
3083 | + end |
3084 | + end |
3085 | + |
3086 | + Facter.add("SwapFree") do |
3087 | + confine :kernel => :Darwin |
3088 | + setcode do |
3089 | + Facter::Memory.scale_number(swapfree.to_f,"MB") |
3090 | + end |
3091 | + end |
3092 | + |
3093 | + Facter::Memory.vmstat_darwin_find_free_memory() |
3094 | + |
3095 | + Facter.add("MemoryTotal") do |
3096 | + confine :kernel => :Darwin |
3097 | + memtotal = Facter::Util::Resolution.exec("sysctl hw.memsize | cut -d':' -f2") |
3098 | + setcode do |
3099 | + Facter::Memory.scale_number(memtotal.to_f,"") |
3100 | + end |
3101 | + end |
3102 | end |
3103 | |
3104 | if Facter.value(:kernel) == "SunOS" |
3105 | - swap = Facter::Util::Resolution.exec('/usr/sbin/swap -l') |
3106 | - swapfree, swaptotal = 0, 0 |
3107 | - swap.each_line do |dev| |
3108 | - if dev =~ /^\/\S+\s.*\s+(\d+)\s+(\d+)$/ |
3109 | - swaptotal += $1.to_i / 2 |
3110 | - swapfree += $2.to_i / 2 |
3111 | - end |
3112 | - end |
3113 | - |
3114 | - Facter.add("SwapSize") do |
3115 | - confine :kernel => :sunos |
3116 | - setcode do |
3117 | - Facter::Memory.scale_number(swaptotal.to_f,"kB") |
3118 | - end |
3119 | - end |
3120 | - |
3121 | - Facter.add("SwapFree") do |
3122 | - confine :kernel => :sunos |
3123 | - setcode do |
3124 | - Facter::Memory.scale_number(swapfree.to_f,"kB") |
3125 | - end |
3126 | - end |
3127 | - |
3128 | - # Total memory size available from prtconf |
3129 | - pconf = Facter::Util::Resolution.exec('/usr/sbin/prtconf') |
3130 | - phymem = "" |
3131 | - pconf.each_line do |line| |
3132 | - if line =~ /^Memory size:\s+(\d+) Megabytes/ |
3133 | - phymem = $1 |
3134 | - end |
3135 | - end |
3136 | - |
3137 | - Facter.add("MemorySize") do |
3138 | - confine :kernel => :sunos |
3139 | - setcode do |
3140 | - Facter::Memory.scale_number(phymem.to_f,"MB") |
3141 | - end |
3142 | - end |
3143 | - |
3144 | - Facter::Memory.vmstat_find_free_memory() |
3145 | + swap = Facter::Util::Resolution.exec('/usr/sbin/swap -l') |
3146 | + swapfree, swaptotal = 0, 0 |
3147 | + swap.each_line do |dev| |
3148 | + if dev =~ /^\/\S+\s.*\s+(\d+)\s+(\d+)$/ |
3149 | + swaptotal += $1.to_i / 2 |
3150 | + swapfree += $2.to_i / 2 |
3151 | + end |
3152 | + end |
3153 | + |
3154 | + Facter.add("SwapSize") do |
3155 | + confine :kernel => :sunos |
3156 | + setcode do |
3157 | + Facter::Memory.scale_number(swaptotal.to_f,"kB") |
3158 | + end |
3159 | + end |
3160 | + |
3161 | + Facter.add("SwapFree") do |
3162 | + confine :kernel => :sunos |
3163 | + setcode do |
3164 | + Facter::Memory.scale_number(swapfree.to_f,"kB") |
3165 | + end |
3166 | + end |
3167 | + |
3168 | + # Total memory size available from prtconf |
3169 | + pconf = Facter::Util::Resolution.exec('/usr/sbin/prtconf 2>/dev/null') |
3170 | + phymem = "" |
3171 | + pconf.each_line do |line| |
3172 | + if line =~ /^Memory size:\s+(\d+) Megabytes/ |
3173 | + phymem = $1 |
3174 | + end |
3175 | + end |
3176 | + |
3177 | + Facter.add("MemorySize") do |
3178 | + confine :kernel => :sunos |
3179 | + setcode do |
3180 | + Facter::Memory.scale_number(phymem.to_f,"MB") |
3181 | + end |
3182 | + end |
3183 | + |
3184 | + Facter::Memory.vmstat_find_free_memory() |
3185 | end |
3186 | |
3187 | if Facter.value(:kernel) == "windows" |
3188 | @@ -234,3 +232,33 @@ |
3189 | end |
3190 | end |
3191 | end |
3192 | + |
3193 | +Facter.add("SwapSize") do |
3194 | + confine :kernel => :dragonfly |
3195 | + setcode do |
3196 | + page_size = Facter::Util::Resolution.exec("/sbin/sysctl -n hw.pagesize").to_f |
3197 | + swaptotal = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_size").to_f * page_size |
3198 | + Facter::Memory.scale_number(swaptotal.to_f,"") |
3199 | + end |
3200 | +end |
3201 | + |
3202 | +Facter.add("SwapFree") do |
3203 | + confine :kernel => :dragonfly |
3204 | + setcode do |
3205 | + page_size = Facter::Util::Resolution.exec("/sbin/sysctl -n hw.pagesize").to_f |
3206 | + swaptotal = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_size").to_f * page_size |
3207 | + swap_anon_use = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_anon_use").to_f * page_size |
3208 | + swap_cache_use = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_cache_use").to_f * page_size |
3209 | + swapfree = swaptotal - swap_anon_use - swap_cache_use |
3210 | + Facter::Memory.scale_number(swapfree.to_f,"") |
3211 | + end |
3212 | +end |
3213 | + |
3214 | +Facter.add("MemoryTotal") do |
3215 | + confine :kernel => :dragonfly |
3216 | + setcode do |
3217 | + Facter::Memory.vmstat_find_free_memory() |
3218 | + memtotal = Facter::Util::Resolution.exec("sysctl -n hw.physmem") |
3219 | + Facter::Memory.scale_number(memtotal.to_f,"") |
3220 | + end |
3221 | +end |
3222 | |
3223 | === modified file 'lib/facter/netmask.rb' |
3224 | --- lib/facter/netmask.rb 2011-06-24 10:04:12 +0000 |
3225 | +++ lib/facter/netmask.rb 2011-11-14 19:37:34 +0000 |
3226 | @@ -18,9 +18,9 @@ |
3227 | require 'facter/util/netmask' |
3228 | |
3229 | Facter.add("netmask") do |
3230 | - confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd" ] |
3231 | - setcode do |
3232 | - Facter::NetMask.get_netmask |
3233 | - end |
3234 | + confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd", :dragonfly ] |
3235 | + setcode do |
3236 | + Facter::NetMask.get_netmask |
3237 | + end |
3238 | end |
3239 | |
3240 | |
3241 | === modified file 'lib/facter/network.rb' |
3242 | --- lib/facter/network.rb 2011-06-24 10:04:12 +0000 |
3243 | +++ lib/facter/network.rb 2011-11-14 19:37:34 +0000 |
3244 | @@ -13,9 +13,9 @@ |
3245 | require 'facter/util/ip' |
3246 | |
3247 | Facter::Util::IP.get_interfaces.each do |interface| |
3248 | - Facter.add("network_" + Facter::Util::IP.alphafy(interface)) do |
3249 | - setcode do |
3250 | - Facter::Util::IP.get_network_value(interface) |
3251 | - end |
3252 | + Facter.add("network_" + Facter::Util::IP.alphafy(interface)) do |
3253 | + setcode do |
3254 | + Facter::Util::IP.get_network_value(interface) |
3255 | end |
3256 | + end |
3257 | end |
3258 | |
3259 | === modified file 'lib/facter/operatingsystem.rb' |
3260 | --- lib/facter/operatingsystem.rb 2011-10-06 10:48:30 +0000 |
3261 | +++ lib/facter/operatingsystem.rb 2011-11-14 19:37:34 +0000 |
3262 | @@ -14,83 +14,87 @@ |
3263 | require 'facter/lsb' |
3264 | |
3265 | Facter.add(:operatingsystem) do |
3266 | - confine :kernel => :sunos |
3267 | - setcode do "Solaris" end |
3268 | -end |
3269 | - |
3270 | -Facter.add(:operatingsystem) do |
3271 | - confine :kernel => :linux |
3272 | - setcode do |
3273 | - if Facter.value(:lsbdistid) == "Ubuntu" |
3274 | - "Ubuntu" |
3275 | - elsif FileTest.exists?("/etc/debian_version") |
3276 | - "Debian" |
3277 | - elsif FileTest.exists?("/etc/gentoo-release") |
3278 | - "Gentoo" |
3279 | - elsif FileTest.exists?("/etc/fedora-release") |
3280 | - "Fedora" |
3281 | - elsif FileTest.exists?("/etc/mandriva-release") |
3282 | - "Mandriva" |
3283 | - elsif FileTest.exists?("/etc/mandrake-release") |
3284 | - "Mandrake" |
3285 | - elsif FileTest.exists?("/etc/meego-release") |
3286 | - "MeeGo" |
3287 | - elsif FileTest.exists?("/etc/arch-release") |
3288 | - "Archlinux" |
3289 | - elsif FileTest.exists?("/etc/oracle-release") |
3290 | - "OracleLinux" |
3291 | - elsif FileTest.exists?("/etc/enterprise-release") |
3292 | - if FileTest.exists?("/etc/ovs-release") |
3293 | - "OVS" |
3294 | - else |
3295 | - "OEL" |
3296 | - end |
3297 | - elsif FileTest.exists?("/etc/arch-release") |
3298 | - "Arch" |
3299 | - elsif FileTest.exists?("/etc/vmware-release") |
3300 | - "VMWareESX" |
3301 | - elsif FileTest.exists?("/etc/redhat-release") |
3302 | - txt = File.read("/etc/redhat-release") |
3303 | - if txt =~ /centos/i |
3304 | - "CentOS" |
3305 | - elsif txt =~ /CERN/ |
3306 | - "SLC" |
3307 | - elsif txt =~ /scientific/i |
3308 | - "Scientific" |
3309 | - else |
3310 | - "RedHat" |
3311 | - end |
3312 | - elsif FileTest.exists?("/etc/SuSE-release") |
3313 | - txt = File.read("/etc/SuSE-release") |
3314 | - if txt =~ /^SUSE LINUX Enterprise Server/i |
3315 | - "SLES" |
3316 | - elsif txt =~ /^SUSE LINUX Enterprise Desktop/i |
3317 | - "SLED" |
3318 | - elsif txt =~ /^openSUSE/i |
3319 | - "OpenSuSE" |
3320 | - else |
3321 | - "SuSE" |
3322 | - end |
3323 | - elsif FileTest.exists?("/etc/bluewhite64-version") |
3324 | - "Bluewhite64" |
3325 | - elsif FileTest.exists?("/etc/slamd64-version") |
3326 | - "Slamd64" |
3327 | - elsif FileTest.exists?("/etc/slackware-version") |
3328 | - "Slackware" |
3329 | - elsif FileTest.exists?("/etc/alpine-release") |
3330 | - "Alpine" |
3331 | - end |
3332 | - end |
3333 | -end |
3334 | - |
3335 | -Facter.add(:operatingsystem) do |
3336 | - confine :kernel => "VMkernel" |
3337 | - setcode do |
3338 | - "ESXi" |
3339 | - end |
3340 | -end |
3341 | - |
3342 | -Facter.add(:operatingsystem) do |
3343 | - # Default to just returning the kernel as the operating system |
3344 | - setcode do Facter[:kernel].value end |
3345 | + confine :kernel => :sunos |
3346 | + setcode do "Solaris" end |
3347 | +end |
3348 | + |
3349 | +Facter.add(:operatingsystem) do |
3350 | + confine :kernel => :linux |
3351 | + setcode do |
3352 | + if Facter.value(:lsbdistid) == "Ubuntu" |
3353 | + "Ubuntu" |
3354 | + elsif FileTest.exists?("/etc/debian_version") |
3355 | + "Debian" |
3356 | + elsif FileTest.exists?("/etc/gentoo-release") |
3357 | + "Gentoo" |
3358 | + elsif FileTest.exists?("/etc/fedora-release") |
3359 | + "Fedora" |
3360 | + elsif FileTest.exists?("/etc/mandriva-release") |
3361 | + "Mandriva" |
3362 | + elsif FileTest.exists?("/etc/mandrake-release") |
3363 | + "Mandrake" |
3364 | + elsif FileTest.exists?("/etc/meego-release") |
3365 | + "MeeGo" |
3366 | + elsif FileTest.exists?("/etc/arch-release") |
3367 | + "Archlinux" |
3368 | + elsif FileTest.exists?("/etc/oracle-release") |
3369 | + "OracleLinux" |
3370 | + elsif FileTest.exists?("/etc/enterprise-release") |
3371 | + if FileTest.exists?("/etc/ovs-release") |
3372 | + "OVS" |
3373 | + else |
3374 | + "OEL" |
3375 | + end |
3376 | + elsif FileTest.exists?("/etc/arch-release") |
3377 | + "Arch" |
3378 | + elsif FileTest.exists?("/etc/vmware-release") |
3379 | + "VMWareESX" |
3380 | + elsif FileTest.exists?("/etc/redhat-release") |
3381 | + txt = File.read("/etc/redhat-release") |
3382 | + if txt =~ /centos/i |
3383 | + "CentOS" |
3384 | + elsif txt =~ /CERN/ |
3385 | + "SLC" |
3386 | + elsif txt =~ /scientific/i |
3387 | + "Scientific" |
3388 | + elsif txt =~ /^cloudlinux/i |
3389 | + "CloudLinux" |
3390 | + else |
3391 | + "RedHat" |
3392 | + end |
3393 | + elsif FileTest.exists?("/etc/SuSE-release") |
3394 | + txt = File.read("/etc/SuSE-release") |
3395 | + if txt =~ /^SUSE LINUX Enterprise Server/i |
3396 | + "SLES" |
3397 | + elsif txt =~ /^SUSE LINUX Enterprise Desktop/i |
3398 | + "SLED" |
3399 | + elsif txt =~ /^openSUSE/i |
3400 | + "OpenSuSE" |
3401 | + else |
3402 | + "SuSE" |
3403 | + end |
3404 | + elsif FileTest.exists?("/etc/bluewhite64-version") |
3405 | + "Bluewhite64" |
3406 | + elsif FileTest.exists?("/etc/slamd64-version") |
3407 | + "Slamd64" |
3408 | + elsif FileTest.exists?("/etc/slackware-version") |
3409 | + "Slackware" |
3410 | + elsif FileTest.exists?("/etc/alpine-release") |
3411 | + "Alpine" |
3412 | + elsif Facter.value(:lsbdistdescription) =~ /Amazon Linux/ |
3413 | + "Amazon" |
3414 | + end |
3415 | + end |
3416 | +end |
3417 | + |
3418 | +Facter.add(:operatingsystem) do |
3419 | + confine :kernel => "VMkernel" |
3420 | + setcode do |
3421 | + "ESXi" |
3422 | + end |
3423 | +end |
3424 | + |
3425 | +Facter.add(:operatingsystem) do |
3426 | + # Default to just returning the kernel as the operating system |
3427 | + setcode do Facter[:kernel].value end |
3428 | end |
3429 | |
3430 | === modified file 'lib/facter/operatingsystemrelease.rb' |
3431 | --- lib/facter/operatingsystemrelease.rb 2011-10-06 10:48:30 +0000 |
3432 | +++ lib/facter/operatingsystemrelease.rb 2011-11-14 19:37:34 +0000 |
3433 | @@ -9,6 +9,7 @@ |
3434 | # On Suse, derivatives, parses '/etc/SuSE-release' for a selection of version |
3435 | # information. |
3436 | # On Slackware, parses '/etc/slackware-version'. |
3437 | +# On Amazon Linux, returns the 'lsbdistrelease' value. |
3438 | # |
3439 | # On all remaining systems, returns the 'kernelrelease' value. |
3440 | # |
3441 | @@ -16,112 +17,112 @@ |
3442 | # |
3443 | |
3444 | Facter.add(:operatingsystemrelease) do |
3445 | - confine :operatingsystem => %w{CentOS Fedora oel ovs OracleLinux RedHat MeeGo Scientific SLC} |
3446 | - setcode do |
3447 | - case Facter.value(:operatingsystem) |
3448 | - when "CentOS", "RedHat", "Scientific", "SLC" |
3449 | - releasefile = "/etc/redhat-release" |
3450 | - when "Fedora" |
3451 | - releasefile = "/etc/fedora-release" |
3452 | - when "MeeGo" |
3453 | - releasefile = "/etc/meego-release" |
3454 | - when "OracleLinux" |
3455 | - releasefile = "/etc/oracle-release" |
3456 | - when "OEL", "oel" |
3457 | - releasefile = "/etc/enterprise-release" |
3458 | - when "OVS", "ovs" |
3459 | - releasefile = "/etc/ovs-release" |
3460 | - end |
3461 | - File::open(releasefile, "r") do |f| |
3462 | - line = f.readline.chomp |
3463 | - if line =~ /\(Rawhide\)$/ |
3464 | - "Rawhide" |
3465 | - elsif line =~ /release (\d[\d.]*)/ |
3466 | - $1 |
3467 | - end |
3468 | - end |
3469 | - end |
3470 | -end |
3471 | - |
3472 | -Facter.add(:operatingsystemrelease) do |
3473 | - confine :operatingsystem => %w{Debian} |
3474 | - setcode do |
3475 | - release = Facter::Util::Resolution.exec('cat /etc/debian_version') |
3476 | - end |
3477 | -end |
3478 | - |
3479 | -Facter.add(:operatingsystemrelease) do |
3480 | - confine :operatingsystem => %w{Ubuntu} |
3481 | - setcode do |
3482 | - release = Facter::Util::Resolution.exec('cat /etc/issue') |
3483 | - if release =~ /Ubuntu (\d+.\d+)/ |
3484 | - $1 |
3485 | - end |
3486 | - end |
3487 | -end |
3488 | - |
3489 | -Facter.add(:operatingsystemrelease) do |
3490 | - confine :operatingsystem => %w{SLES SLED OpenSuSE} |
3491 | - setcode do |
3492 | - releasefile = Facter::Util::Resolution.exec('cat /etc/SuSE-release') |
3493 | - if releasefile =~ /^VERSION\s*=\s*(\d+)/ |
3494 | - releasemajor = $1 |
3495 | - if releasefile =~ /^PATCHLEVEL\s*=\s*(\d+)/ |
3496 | - releaseminor = $1 |
3497 | - elsif releasefile =~ /^VERSION\s=.*.(\d+)/ |
3498 | - releaseminor = $1 |
3499 | - else |
3500 | - releaseminor = "0" |
3501 | - end |
3502 | - releasemajor + "." + releaseminor |
3503 | - else |
3504 | - "unknown" |
3505 | - end |
3506 | - end |
3507 | -end |
3508 | - |
3509 | -Facter.add(:operatingsystemrelease) do |
3510 | - confine :operatingsystem => %w{Slackware} |
3511 | - setcode do |
3512 | - release = Facter::Util::Resolution.exec('cat /etc/slackware-version') |
3513 | - if release =~ /Slackware ([0-9.]+)/ |
3514 | - $1 |
3515 | - end |
3516 | - end |
3517 | -end |
3518 | - |
3519 | -Facter.add(:operatingsystemrelease) do |
3520 | - confine :operatingsystem => %w{Bluewhite64} |
3521 | - setcode do |
3522 | - releasefile = Facter::Util::Resolution.exec('cat /etc/bluewhite64-version') |
3523 | - if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/ |
3524 | - $1 + "." + $2 |
3525 | - else |
3526 | - "unknown" |
3527 | - end |
3528 | - end |
3529 | -end |
3530 | - |
3531 | -Facter.add(:operatingsystemrelease) do |
3532 | - confine :operatingsystem => %w{VMwareESX} |
3533 | - setcode do |
3534 | - release = Facter::Util::Resolution.exec('vmware -v') |
3535 | - if release =~ /VMware ESX .*?(\d.*)/ |
3536 | - $1 |
3537 | - end |
3538 | - end |
3539 | -end |
3540 | - |
3541 | -Facter.add(:operatingsystemrelease) do |
3542 | - confine :operatingsystem => %w{Slamd64} |
3543 | - setcode do |
3544 | - releasefile = Facter::Util::Resolution.exec('cat /etc/slamd64-version') |
3545 | - if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/ |
3546 | - $1 + "." + $2 |
3547 | - else |
3548 | - "unknown" |
3549 | - end |
3550 | - end |
3551 | + confine :operatingsystem => %w{CentOS Fedora oel ovs OracleLinux RedHat MeeGo Scientific SLC CloudLinux} |
3552 | + setcode do |
3553 | + case Facter.value(:operatingsystem) |
3554 | + when "CentOS", "RedHat", "Scientific", "SLC", "CloudLinux" |
3555 | + releasefile = "/etc/redhat-release" |
3556 | + when "Fedora" |
3557 | + releasefile = "/etc/fedora-release" |
3558 | + when "MeeGo" |
3559 | + releasefile = "/etc/meego-release" |
3560 | + when "OracleLinux" |
3561 | + releasefile = "/etc/oracle-release" |
3562 | + when "OEL", "oel" |
3563 | + releasefile = "/etc/enterprise-release" |
3564 | + when "OVS", "ovs" |
3565 | + releasefile = "/etc/ovs-release" |
3566 | + end |
3567 | + File::open(releasefile, "r") do |f| |
3568 | + line = f.readline.chomp |
3569 | + if line =~ /\(Rawhide\)$/ |
3570 | + "Rawhide" |
3571 | + elsif line =~ /release (\d[\d.]*)/ |
3572 | + $1 |
3573 | + end |
3574 | + end |
3575 | + end |
3576 | +end |
3577 | + |
3578 | +Facter.add(:operatingsystemrelease) do |
3579 | + confine :operatingsystem => %w{Debian} |
3580 | + setcode do |
3581 | + release = Facter::Util::Resolution.exec('cat /etc/debian_version') |
3582 | + end |
3583 | +end |
3584 | + |
3585 | +Facter.add(:operatingsystemrelease) do |
3586 | + confine :operatingsystem => %w{Ubuntu} |
3587 | + setcode do |
3588 | + release = Facter::Util::Resolution.exec('cat /etc/issue') |
3589 | + if release =~ /Ubuntu (\d+.\d+)/ |
3590 | + $1 |
3591 | + end |
3592 | + end |
3593 | +end |
3594 | + |
3595 | +Facter.add(:operatingsystemrelease) do |
3596 | + confine :operatingsystem => %w{SLES SLED OpenSuSE} |
3597 | + setcode do |
3598 | + releasefile = Facter::Util::Resolution.exec('cat /etc/SuSE-release') |
3599 | + if releasefile =~ /^VERSION\s*=\s*(\d+)/ |
3600 | + releasemajor = $1 |
3601 | + if releasefile =~ /^PATCHLEVEL\s*=\s*(\d+)/ |
3602 | + releaseminor = $1 |
3603 | + elsif releasefile =~ /^VERSION\s=.*.(\d+)/ |
3604 | + releaseminor = $1 |
3605 | + else |
3606 | + releaseminor = "0" |
3607 | + end |
3608 | + releasemajor + "." + releaseminor |
3609 | + else |
3610 | + "unknown" |
3611 | + end |
3612 | + end |
3613 | +end |
3614 | + |
3615 | +Facter.add(:operatingsystemrelease) do |
3616 | + confine :operatingsystem => %w{Slackware} |
3617 | + setcode do |
3618 | + release = Facter::Util::Resolution.exec('cat /etc/slackware-version') |
3619 | + if release =~ /Slackware ([0-9.]+)/ |
3620 | + $1 |
3621 | + end |
3622 | + end |
3623 | +end |
3624 | + |
3625 | +Facter.add(:operatingsystemrelease) do |
3626 | + confine :operatingsystem => %w{Bluewhite64} |
3627 | + setcode do |
3628 | + releasefile = Facter::Util::Resolution.exec('cat /etc/bluewhite64-version') |
3629 | + if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/ |
3630 | + $1 + "." + $2 |
3631 | + else |
3632 | + "unknown" |
3633 | + end |
3634 | + end |
3635 | +end |
3636 | + |
3637 | +Facter.add(:operatingsystemrelease) do |
3638 | + confine :operatingsystem => %w{VMwareESX} |
3639 | + setcode do |
3640 | + release = Facter::Util::Resolution.exec('vmware -v') |
3641 | + if release =~ /VMware ESX .*?(\d.*)/ |
3642 | + $1 |
3643 | + end |
3644 | + end |
3645 | +end |
3646 | + |
3647 | +Facter.add(:operatingsystemrelease) do |
3648 | + confine :operatingsystem => %w{Slamd64} |
3649 | + setcode do |
3650 | + releasefile = Facter::Util::Resolution.exec('cat /etc/slamd64-version') |
3651 | + if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/ |
3652 | + $1 + "." + $2 |
3653 | + else |
3654 | + "unknown" |
3655 | + end |
3656 | + end |
3657 | end |
3658 | |
3659 | Facter.add(:operatingsystemrelease) do |
3660 | @@ -132,5 +133,10 @@ |
3661 | end |
3662 | |
3663 | Facter.add(:operatingsystemrelease) do |
3664 | - setcode do Facter[:kernelrelease].value end |
3665 | + confine :operatingsystem => %W{Amazon} |
3666 | + setcode do Facter[:lsbdistrelease].value end |
3667 | +end |
3668 | + |
3669 | +Facter.add(:operatingsystemrelease) do |
3670 | + setcode do Facter[:kernelrelease].value end |
3671 | end |
3672 | |
3673 | === added file 'lib/facter/osfamily.rb' |
3674 | --- lib/facter/osfamily.rb 1970-01-01 00:00:00 +0000 |
3675 | +++ lib/facter/osfamily.rb 2011-11-14 19:37:34 +0000 |
3676 | @@ -0,0 +1,31 @@ |
3677 | +# Fact: osfamily |
3678 | +# |
3679 | +# Purpose: Returns the operating system |
3680 | +# |
3681 | +# Resolution: |
3682 | +# Maps operating systems to operating system families, such as linux |
3683 | +# distribution derivatives. Adds mappings from specific operating systems |
3684 | +# to kernels in the case that it is relevant. |
3685 | +# |
3686 | +# Caveats: |
3687 | +# This fact is completely reliant on the operatingsystem fact, and no |
3688 | +# heuristics are used |
3689 | +# |
3690 | + |
3691 | +Facter.add(:osfamily) do |
3692 | + |
3693 | + setcode do |
3694 | + case Facter.value(:operatingsystem) |
3695 | + when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "CloudLinux", "OracleLinux", "OVS", "OEL" |
3696 | + "RedHat" |
3697 | + when "Ubuntu", "Debian" |
3698 | + "Debian" |
3699 | + when "SLES", "SLED", "OpenSuSE", "SuSE" |
3700 | + "Suse" |
3701 | + when "Solaris" |
3702 | + "Solaris" |
3703 | + else |
3704 | + Facter.value("kernel") |
3705 | + end |
3706 | + end |
3707 | +end |
3708 | |
3709 | === modified file 'lib/facter/path.rb' |
3710 | --- lib/facter/path.rb 2011-06-24 10:04:12 +0000 |
3711 | +++ lib/facter/path.rb 2011-11-14 19:37:34 +0000 |
3712 | @@ -8,7 +8,7 @@ |
3713 | # |
3714 | |
3715 | Facter.add(:path) do |
3716 | - setcode do |
3717 | - ENV['PATH'] |
3718 | - end |
3719 | + setcode do |
3720 | + ENV['PATH'] |
3721 | + end |
3722 | end |
3723 | |
3724 | === modified file 'lib/facter/physicalprocessorcount.rb' |
3725 | --- lib/facter/physicalprocessorcount.rb 2011-10-06 10:48:30 +0000 |
3726 | +++ lib/facter/physicalprocessorcount.rb 2011-11-14 19:37:34 +0000 |
3727 | @@ -62,3 +62,11 @@ |
3728 | Facter::Util::WMI.execquery("select Name from Win32_Processor").Count |
3729 | end |
3730 | end |
3731 | + |
3732 | +Facter.add('physicalprocessorcount') do |
3733 | + confine :kernel => :sunos |
3734 | + |
3735 | + setcode do |
3736 | + Facter::Util::Resolution.exec("/usr/sbin/psrinfo -p") |
3737 | + end |
3738 | +end |
3739 | |
3740 | === modified file 'lib/facter/processor.rb' |
3741 | --- lib/facter/processor.rb 2011-10-06 10:48:30 +0000 |
3742 | +++ lib/facter/processor.rb 2011-11-14 19:37:34 +0000 |
3743 | @@ -19,90 +19,87 @@ |
3744 | # |
3745 | |
3746 | require 'thread' |
3747 | - |
3748 | -if ["Linux", "GNU/kFreeBSD"].include? Facter.value(:kernel) |
3749 | - processor_num = -1 |
3750 | - processor_list = [] |
3751 | - Thread::exclusive do |
3752 | - File.readlines("/proc/cpuinfo").each do |l| |
3753 | - if l =~ /processor\s+:\s+(\d+)/ |
3754 | - processor_num = $1.to_i |
3755 | - elsif l =~ /model name\s+:\s+(.*)\s*$/ |
3756 | - processor_list[processor_num] = $1 unless processor_num == -1 |
3757 | - processor_num = -1 |
3758 | - elsif l =~ /processor\s+(\d+):\s+(.*)/ |
3759 | - processor_num = $1.to_i |
3760 | - processor_list[processor_num] = $2 unless processor_num == -1 |
3761 | - end |
3762 | - end |
3763 | - end |
3764 | - |
3765 | - Facter.add("ProcessorCount") do |
3766 | - confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
3767 | - setcode do |
3768 | - processor_list.length.to_s |
3769 | - end |
3770 | - end |
3771 | - |
3772 | - processor_list.each_with_index do |desc, i| |
3773 | - Facter.add("Processor#{i}") do |
3774 | - confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
3775 | - setcode do |
3776 | - desc |
3777 | - end |
3778 | - end |
3779 | - end |
3780 | -end |
3781 | - |
3782 | -if Facter.value(:kernel) == "AIX" |
3783 | - processor_num = -1 |
3784 | - processor_list = {} |
3785 | - Thread::exclusive do |
3786 | - procs = Facter::Util::Resolution.exec('lsdev -Cc processor') |
3787 | - procs.each do |proc| |
3788 | - if proc =~ /^proc(\d+)/ |
3789 | - processor_num = $1.to_i |
3790 | - # Not retrieving the frequency since AIX 4.3.3 doesn't support the |
3791 | - # attribute and some people still use the OS. |
3792 | - proctype = Facter::Util::Resolution.exec('lsattr -El proc0 -a type') |
3793 | - if proctype =~ /^type\s+(\S+)\s+/ |
3794 | - processor_list["processor#{processor_num}"] = $1 |
3795 | - end |
3796 | - end |
3797 | - end |
3798 | - end |
3799 | - |
3800 | - Facter.add("ProcessorCount") do |
3801 | - confine :kernel => :aix |
3802 | - setcode do |
3803 | - processor_list.length.to_s |
3804 | - end |
3805 | - end |
3806 | - |
3807 | - processor_list.each do |proc, desc| |
3808 | - Facter.add(proc) do |
3809 | - confine :kernel => :aix |
3810 | - setcode do |
3811 | - desc |
3812 | - end |
3813 | - end |
3814 | - end |
3815 | -end |
3816 | - |
3817 | -if Facter.value(:kernel) == "OpenBSD" |
3818 | - Facter.add("Processor") do |
3819 | - confine :kernel => :openbsd |
3820 | - setcode do |
3821 | - Facter::Util::Resolution.exec("uname -p") |
3822 | - end |
3823 | - end |
3824 | - |
3825 | - Facter.add("ProcessorCount") do |
3826 | - confine :kernel => :openbsd |
3827 | - setcode do |
3828 | - Facter::Util::Resolution.exec("sysctl hw.ncpu | cut -d'=' -f2") |
3829 | - end |
3830 | - end |
3831 | +require 'facter/util/processor' |
3832 | + |
3833 | +Facter.add("ProcessorCount") do |
3834 | + confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
3835 | + setcode do |
3836 | + processor_list = Facter::Util::Processor.enum_cpuinfo |
3837 | + |
3838 | + ## If this returned nothing, then don't resolve the fact |
3839 | + if processor_list.length != 0 |
3840 | + processor_list.length.to_s |
3841 | + end |
3842 | + end |
3843 | +end |
3844 | + |
3845 | +Facter.add("ProcessorCount") do |
3846 | + confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
3847 | + setcode do |
3848 | + ## The method above is preferable since it provides the description of the CPU as well |
3849 | + ## but if that returned 0, then we enumerate sysfs |
3850 | + sysfs_cpu_directory = '/sys/devices/system/cpu' |
3851 | + if File.exists?(sysfs_cpu_directory) |
3852 | + lookup_pattern = "#{sysfs_cpu_directory}" + "/cpu[0-9]*" |
3853 | + cpuCount = Dir.glob(lookup_pattern).length |
3854 | + cpuCount.to_s |
3855 | + end |
3856 | + end |
3857 | +end |
3858 | + |
3859 | +Facter.add("ProcessorCount") do |
3860 | + confine :kernel => :aix |
3861 | + setcode do |
3862 | + processor_list = Facter::Util::Processor.enum_lsdev |
3863 | + |
3864 | + processor_list.length.to_s |
3865 | + end |
3866 | +end |
3867 | + |
3868 | +Facter.add("Processor") do |
3869 | + confine :kernel => :openbsd |
3870 | + setcode do |
3871 | + Facter::Util::Resolution.exec("uname -p") |
3872 | + end |
3873 | +end |
3874 | + |
3875 | +Facter.add("ProcessorCount") do |
3876 | + confine :kernel => :openbsd |
3877 | + setcode do |
3878 | + Facter::Util::Resolution.exec("sysctl -n hw.ncpu") |
3879 | + end |
3880 | +end |
3881 | + |
3882 | +Facter.add("ProcessorCount") do |
3883 | + confine :kernel => :Darwin |
3884 | + setcode do |
3885 | + Facter::Util::Resolution.exec("sysctl -n hw.ncpu") |
3886 | + end |
3887 | +end |
3888 | + |
3889 | +## We have to enumerate these outside a Facter.add block to get the processorN descriptions iteratively |
3890 | +## (but we need them inside the Facter.add block above for tests on processorcount to work) |
3891 | +processor_list = Facter::Util::Processor.enum_cpuinfo |
3892 | +processor_list_aix = Facter::Util::Processor.enum_lsdev |
3893 | + |
3894 | +if processor_list.length != 0 |
3895 | + processor_list.each_with_index do |desc, i| |
3896 | + Facter.add("Processor#{i}") do |
3897 | + confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
3898 | + setcode do |
3899 | + desc |
3900 | + end |
3901 | + end |
3902 | + end |
3903 | +elsif processor_list_aix.length != 0 |
3904 | + processor_list_aix.each_with_index do |desc, i| |
3905 | + Facter.add("Processor#{i}") do |
3906 | + confine :kernel => [ :aix ] |
3907 | + setcode do |
3908 | + desc |
3909 | + end |
3910 | + end |
3911 | + end |
3912 | end |
3913 | |
3914 | if Facter.value(:kernel) == "windows" |
3915 | @@ -142,3 +139,25 @@ |
3916 | end |
3917 | end |
3918 | end |
3919 | + |
3920 | +Facter.add("Processor") do |
3921 | + confine :kernel => :dragonfly |
3922 | + setcode do |
3923 | + Facter::Util::Resolution.exec("sysctl -n hw.model") |
3924 | + end |
3925 | +end |
3926 | + |
3927 | +Facter.add("ProcessorCount") do |
3928 | + confine :kernel => :dragonfly |
3929 | + setcode do |
3930 | + Facter::Util::Resolution.exec("sysctl -n hw.ncpu") |
3931 | + end |
3932 | +end |
3933 | + |
3934 | +Facter.add("processorcount") do |
3935 | + confine :kernel => :sunos |
3936 | + setcode do |
3937 | + kstat = Facter::Util::Resolution.exec("/usr/bin/kstat cpu_info") |
3938 | + kstat.scan(/\bcore_id\b\s+\d+/).uniq.length |
3939 | + end |
3940 | +end |
3941 | |
3942 | === modified file 'lib/facter/ps.rb' |
3943 | --- lib/facter/ps.rb 2011-10-06 10:48:30 +0000 |
3944 | +++ lib/facter/ps.rb 2011-11-14 19:37:34 +0000 |
3945 | @@ -11,12 +11,12 @@ |
3946 | # |
3947 | |
3948 | Facter.add(:ps) do |
3949 | - setcode do 'ps -ef' end |
3950 | + setcode do 'ps -ef' end |
3951 | end |
3952 | |
3953 | Facter.add(:ps) do |
3954 | - confine :operatingsystem => %w{FreeBSD NetBSD OpenBSD Darwin} |
3955 | - setcode do 'ps auxwww' end |
3956 | + confine :operatingsystem => %w{FreeBSD NetBSD OpenBSD Darwin DragonFly} |
3957 | + setcode do 'ps auxwww' end |
3958 | end |
3959 | |
3960 | Facter.add(:ps) do |
3961 | |
3962 | === modified file 'lib/facter/puppetversion.rb' |
3963 | --- lib/facter/puppetversion.rb 2011-06-24 10:04:12 +0000 |
3964 | +++ lib/facter/puppetversion.rb 2011-11-14 19:37:34 +0000 |
3965 | @@ -9,12 +9,12 @@ |
3966 | # |
3967 | |
3968 | Facter.add(:puppetversion) do |
3969 | - setcode do |
3970 | - begin |
3971 | - require 'puppet' |
3972 | - Puppet::PUPPETVERSION.to_s |
3973 | - rescue LoadError |
3974 | - nil |
3975 | - end |
3976 | + setcode do |
3977 | + begin |
3978 | + require 'puppet' |
3979 | + Puppet::PUPPETVERSION.to_s |
3980 | + rescue LoadError |
3981 | + nil |
3982 | end |
3983 | + end |
3984 | end |
3985 | |
3986 | === modified file 'lib/facter/rubysitedir.rb' |
3987 | --- lib/facter/rubysitedir.rb 2011-06-24 10:04:12 +0000 |
3988 | +++ lib/facter/rubysitedir.rb 2011-11-14 19:37:34 +0000 |
3989 | @@ -9,10 +9,10 @@ |
3990 | # |
3991 | |
3992 | Facter.add :rubysitedir do |
3993 | - setcode do |
3994 | - version = RUBY_VERSION.to_s.sub(/\.\d+$/, '') |
3995 | - $:.find do |dir| |
3996 | - dir =~ /#{File.join("site_ruby", version)}$/ |
3997 | - end |
3998 | + setcode do |
3999 | + version = RUBY_VERSION.to_s.sub(/\.\d+$/, '') |
4000 | + $:.find do |dir| |
4001 | + dir =~ /#{File.join("site_ruby", version)}$/ |
4002 | end |
4003 | + end |
4004 | end |
4005 | |
4006 | === modified file 'lib/facter/rubyversion.rb' |
4007 | --- lib/facter/rubyversion.rb 2011-06-24 10:04:12 +0000 |
4008 | +++ lib/facter/rubyversion.rb 2011-11-14 19:37:34 +0000 |
4009 | @@ -8,5 +8,5 @@ |
4010 | # |
4011 | |
4012 | Facter.add(:rubyversion) do |
4013 | - setcode { RUBY_VERSION.to_s } |
4014 | + setcode { RUBY_VERSION.to_s } |
4015 | end |
4016 | |
4017 | === modified file 'lib/facter/ssh.rb' |
4018 | --- lib/facter/ssh.rb 2011-06-24 10:04:12 +0000 |
4019 | +++ lib/facter/ssh.rb 2011-11-14 19:37:34 +0000 |
4020 | @@ -12,20 +12,20 @@ |
4021 | ## |
4022 | |
4023 | ["/etc/ssh","/usr/local/etc/ssh","/etc","/usr/local/etc"].each do |dir| |
4024 | - {"SSHDSAKey" => "ssh_host_dsa_key.pub", "SSHRSAKey" => "ssh_host_rsa_key.pub"}.each do |name,file| |
4025 | - Facter.add(name) do |
4026 | - setcode do |
4027 | - value = nil |
4028 | - filepath = File.join(dir,file) |
4029 | - if FileTest.file?(filepath) |
4030 | - begin |
4031 | - File.open(filepath) { |f| value = f.read.chomp.split(/\s+/)[1] } |
4032 | - rescue |
4033 | - value = nil |
4034 | - end |
4035 | - end |
4036 | - value |
4037 | - end # end of proc |
4038 | - end # end of add |
4039 | - end # end of hash each |
4040 | + {"SSHDSAKey" => "ssh_host_dsa_key.pub", "SSHRSAKey" => "ssh_host_rsa_key.pub", "SSHECDSAKey" => "ssh_host_ecdsa_key.pub"}.each do |name,file| |
4041 | + Facter.add(name) do |
4042 | + setcode do |
4043 | + value = nil |
4044 | + filepath = File.join(dir,file) |
4045 | + if FileTest.file?(filepath) |
4046 | + begin |
4047 | + File.open(filepath) { |f| value = f.read.chomp.split(/\s+/)[1] } |
4048 | + rescue |
4049 | + value = nil |
4050 | + end |
4051 | + end |
4052 | + value |
4053 | + end # end of proc |
4054 | + end # end of add |
4055 | + end # end of hash each |
4056 | end # end of dir each |
4057 | |
4058 | === modified file 'lib/facter/timezone.rb' |
4059 | --- lib/facter/timezone.rb 2011-06-24 10:04:12 +0000 |
4060 | +++ lib/facter/timezone.rb 2011-11-14 19:37:34 +0000 |
4061 | @@ -8,7 +8,7 @@ |
4062 | # |
4063 | |
4064 | Facter.add("timezone") do |
4065 | - setcode do |
4066 | - Time.new.zone |
4067 | - end |
4068 | + setcode do |
4069 | + Time.new.zone |
4070 | + end |
4071 | end |
4072 | |
4073 | === modified file 'lib/facter/uniqueid.rb' |
4074 | --- lib/facter/uniqueid.rb 2011-10-06 10:48:30 +0000 |
4075 | +++ lib/facter/uniqueid.rb 2011-11-14 19:37:34 +0000 |
4076 | @@ -1,4 +1,4 @@ |
4077 | Facter.add(:uniqueid) do |
4078 | - setcode 'hostid' |
4079 | - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo AIX OEL OracleLinux OVS GNU/kFreeBSD} |
4080 | + setcode 'hostid' |
4081 | + confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo AIX OEL OracleLinux OVS GNU/kFreeBSD} |
4082 | end |
4083 | |
4084 | === modified file 'lib/facter/util/collection.rb' |
4085 | --- lib/facter/util/collection.rb 2011-06-24 10:04:12 +0000 |
4086 | +++ lib/facter/util/collection.rb 2011-11-14 19:37:34 +0000 |
4087 | @@ -5,126 +5,126 @@ |
4088 | # Manage which facts exist and how we access them. Largely just a wrapper |
4089 | # around a hash of facts. |
4090 | class Facter::Util::Collection |
4091 | - # Return a fact object by name. If you use this, you still have to call |
4092 | - # 'value' on it to retrieve the actual value. |
4093 | - def [](name) |
4094 | - value(name) |
4095 | - end |
4096 | - |
4097 | - # Add a resolution mechanism for a named fact. This does not distinguish |
4098 | - # between adding a new fact and adding a new way to resolve a fact. |
4099 | - def add(name, options = {}, &block) |
4100 | - name = canonize(name) |
4101 | - |
4102 | - unless fact = @facts[name] |
4103 | - fact = Facter::Util::Fact.new(name) |
4104 | - |
4105 | - @facts[name] = fact |
4106 | - end |
4107 | - |
4108 | - # Set any fact-appropriate options. |
4109 | - options.each do |opt, value| |
4110 | - method = opt.to_s + "=" |
4111 | - if fact.respond_to?(method) |
4112 | - fact.send(method, value) |
4113 | - options.delete(opt) |
4114 | - end |
4115 | - end |
4116 | - |
4117 | - if block |
4118 | - resolve = fact.add(&block) |
4119 | - # Set any resolve-appropriate options |
4120 | - options.each do |opt, value| |
4121 | - method = opt.to_s + "=" |
4122 | - if resolve.respond_to?(method) |
4123 | - resolve.send(method, value) |
4124 | - options.delete(opt) |
4125 | - end |
4126 | - end |
4127 | - end |
4128 | - |
4129 | - unless options.empty? |
4130 | - raise ArgumentError, "Invalid facter option(s) %s" % options.keys.collect { |k| k.to_s }.join(",") |
4131 | - end |
4132 | - |
4133 | - return fact |
4134 | - end |
4135 | - |
4136 | - include Enumerable |
4137 | - |
4138 | - # Iterate across all of the facts. |
4139 | - def each |
4140 | - @facts.each do |name, fact| |
4141 | - value = fact.value |
4142 | - unless value.nil? |
4143 | - yield name.to_s, value |
4144 | - end |
4145 | - end |
4146 | - end |
4147 | - |
4148 | - # Return a fact by name. |
4149 | - def fact(name) |
4150 | - name = canonize(name) |
4151 | - |
4152 | - # Try to load the fact if necessary |
4153 | - loader.load(name) unless @facts[name] |
4154 | - |
4155 | - # Try HARDER |
4156 | - loader.load_all unless @facts[name] |
4157 | - |
4158 | - @facts[name] |
4159 | - end |
4160 | - |
4161 | - # Flush all cached values. |
4162 | - def flush |
4163 | - @facts.each { |name, fact| fact.flush } |
4164 | - end |
4165 | - |
4166 | - def initialize |
4167 | - @facts = Hash.new |
4168 | - end |
4169 | - |
4170 | - # Return a list of all of the facts. |
4171 | - def list |
4172 | - return @facts.keys |
4173 | - end |
4174 | - |
4175 | - # Load all known facts. |
4176 | - def load_all |
4177 | - loader.load_all |
4178 | - end |
4179 | - |
4180 | - # The thing that loads facts if we don't have them. |
4181 | - def loader |
4182 | - unless defined?(@loader) |
4183 | - @loader = Facter::Util::Loader.new |
4184 | - end |
4185 | - @loader |
4186 | - end |
4187 | - |
4188 | - # Return a hash of all of our facts. |
4189 | - def to_hash |
4190 | - @facts.inject({}) do |h, ary| |
4191 | - value = ary[1].value |
4192 | - if ! value.nil? |
4193 | - # For backwards compatibility, convert the fact name to a string. |
4194 | - h[ary[0].to_s] = value |
4195 | - end |
4196 | - h |
4197 | - end |
4198 | - end |
4199 | - |
4200 | - def value(name) |
4201 | - if fact = fact(name) |
4202 | - fact.value |
4203 | - end |
4204 | - end |
4205 | - |
4206 | - private |
4207 | - |
4208 | - # Provide a consistent means of getting the exact same fact name |
4209 | - # every time. |
4210 | - def canonize(name) |
4211 | - name.to_s.downcase.to_sym |
4212 | - end |
4213 | + # Return a fact object by name. If you use this, you still have to call |
4214 | + # 'value' on it to retrieve the actual value. |
4215 | + def [](name) |
4216 | + value(name) |
4217 | + end |
4218 | + |
4219 | + # Add a resolution mechanism for a named fact. This does not distinguish |
4220 | + # between adding a new fact and adding a new way to resolve a fact. |
4221 | + def add(name, options = {}, &block) |
4222 | + name = canonize(name) |
4223 | + |
4224 | + unless fact = @facts[name] |
4225 | + fact = Facter::Util::Fact.new(name) |
4226 | + |
4227 | + @facts[name] = fact |
4228 | + end |
4229 | + |
4230 | + # Set any fact-appropriate options. |
4231 | + options.each do |opt, value| |
4232 | + method = opt.to_s + "=" |
4233 | + if fact.respond_to?(method) |
4234 | + fact.send(method, value) |
4235 | + options.delete(opt) |
4236 | + end |
4237 | + end |
4238 | + |
4239 | + if block |
4240 | + resolve = fact.add(&block) |
4241 | + # Set any resolve-appropriate options |
4242 | + options.each do |opt, value| |
4243 | + method = opt.to_s + "=" |
4244 | + if resolve.respond_to?(method) |
4245 | + resolve.send(method, value) |
4246 | + options.delete(opt) |
4247 | + end |
4248 | + end |
4249 | + end |
4250 | + |
4251 | + unless options.empty? |
4252 | + raise ArgumentError, "Invalid facter option(s) %s" % options.keys.collect { |k| k.to_s }.join(",") |
4253 | + end |
4254 | + |
4255 | + return fact |
4256 | + end |
4257 | + |
4258 | + include Enumerable |
4259 | + |
4260 | + # Iterate across all of the facts. |
4261 | + def each |
4262 | + @facts.each do |name, fact| |
4263 | + value = fact.value |
4264 | + unless value.nil? |
4265 | + yield name.to_s, value |
4266 | + end |
4267 | + end |
4268 | + end |
4269 | + |
4270 | + # Return a fact by name. |
4271 | + def fact(name) |
4272 | + name = canonize(name) |
4273 | + |
4274 | + # Try to load the fact if necessary |
4275 | + loader.load(name) unless @facts[name] |
4276 | + |
4277 | + # Try HARDER |
4278 | + loader.load_all unless @facts[name] |
4279 | + |
4280 | + @facts[name] |
4281 | + end |
4282 | + |
4283 | + # Flush all cached values. |
4284 | + def flush |
4285 | + @facts.each { |name, fact| fact.flush } |
4286 | + end |
4287 | + |
4288 | + def initialize |
4289 | + @facts = Hash.new |
4290 | + end |
4291 | + |
4292 | + # Return a list of all of the facts. |
4293 | + def list |
4294 | + return @facts.keys |
4295 | + end |
4296 | + |
4297 | + # Load all known facts. |
4298 | + def load_all |
4299 | + loader.load_all |
4300 | + end |
4301 | + |
4302 | + # The thing that loads facts if we don't have them. |
4303 | + def loader |
4304 | + unless defined?(@loader) |
4305 | + @loader = Facter::Util::Loader.new |
4306 | + end |
4307 | + @loader |
4308 | + end |
4309 | + |
4310 | + # Return a hash of all of our facts. |
4311 | + def to_hash |
4312 | + @facts.inject({}) do |h, ary| |
4313 | + value = ary[1].value |
4314 | + if ! value.nil? |
4315 | + # For backwards compatibility, convert the fact name to a string. |
4316 | + h[ary[0].to_s] = value |
4317 | + end |
4318 | + h |
4319 | + end |
4320 | + end |
4321 | + |
4322 | + def value(name) |
4323 | + if fact = fact(name) |
4324 | + fact.value |
4325 | + end |
4326 | + end |
4327 | + |
4328 | + private |
4329 | + |
4330 | + # Provide a consistent means of getting the exact same fact name |
4331 | + # every time. |
4332 | + def canonize(name) |
4333 | + name.to_s.downcase.to_sym |
4334 | + end |
4335 | end |
4336 | |
4337 | === modified file 'lib/facter/util/confine.rb' |
4338 | --- lib/facter/util/confine.rb 2009-06-30 00:21:23 +0000 |
4339 | +++ lib/facter/util/confine.rb 2011-11-14 19:37:34 +0000 |
4340 | @@ -4,38 +4,38 @@ |
4341 | require 'facter/util/values' |
4342 | |
4343 | class Facter::Util::Confine |
4344 | - attr_accessor :fact, :values |
4345 | - |
4346 | - include Facter::Util::Values |
4347 | - |
4348 | - # Add the restriction. Requires the fact name, an operator, and the value |
4349 | - # we're comparing to. |
4350 | - def initialize(fact, *values) |
4351 | - raise ArgumentError, "The fact name must be provided" unless fact |
4352 | - raise ArgumentError, "One or more values must be provided" if values.empty? |
4353 | - @fact = fact |
4354 | - @values = values |
4355 | - end |
4356 | - |
4357 | - def to_s |
4358 | - return "'%s' '%s'" % [@fact, @values.join(",")] |
4359 | - end |
4360 | - |
4361 | - # Evaluate the fact, returning true or false. |
4362 | - def true? |
4363 | - unless fact = Facter[@fact] |
4364 | - Facter.debug "No fact for %s" % @fact |
4365 | - return false |
4366 | - end |
4367 | - value = convert(fact.value) |
4368 | - |
4369 | - return false if value.nil? |
4370 | - |
4371 | - @values.each do |v| |
4372 | - v = convert(v) |
4373 | - next unless v.class == value.class |
4374 | - return true if value == v |
4375 | - end |
4376 | - return false |
4377 | - end |
4378 | + attr_accessor :fact, :values |
4379 | + |
4380 | + include Facter::Util::Values |
4381 | + |
4382 | + # Add the restriction. Requires the fact name, an operator, and the value |
4383 | + # we're comparing to. |
4384 | + def initialize(fact, *values) |
4385 | + raise ArgumentError, "The fact name must be provided" unless fact |
4386 | + raise ArgumentError, "One or more values must be provided" if values.empty? |
4387 | + @fact = fact |
4388 | + @values = values |
4389 | + end |
4390 | + |
4391 | + def to_s |
4392 | + return "'%s' '%s'" % [@fact, @values.join(",")] |
4393 | + end |
4394 | + |
4395 | + # Evaluate the fact, returning true or false. |
4396 | + def true? |
4397 | + unless fact = Facter[@fact] |
4398 | + Facter.debug "No fact for %s" % @fact |
4399 | + return false |
4400 | + end |
4401 | + value = convert(fact.value) |
4402 | + |
4403 | + return false if value.nil? |
4404 | + |
4405 | + @values.each do |v| |
4406 | + v = convert(v) |
4407 | + next unless v.class == value.class |
4408 | + return true if value == v |
4409 | + end |
4410 | + return false |
4411 | + end |
4412 | end |
4413 | |
4414 | === modified file 'lib/facter/util/fact.rb' |
4415 | --- lib/facter/util/fact.rb 2011-06-24 10:04:12 +0000 |
4416 | +++ lib/facter/util/fact.rb 2011-11-14 19:37:34 +0000 |
4417 | @@ -2,119 +2,119 @@ |
4418 | require 'facter/util/resolution' |
4419 | |
4420 | class Facter::Util::Fact |
4421 | - TIMEOUT = 5 |
4422 | - |
4423 | - attr_accessor :name, :ldapname |
4424 | - |
4425 | - # Create a new fact, with no resolution mechanisms. |
4426 | - def initialize(name, options = {}) |
4427 | - @name = name.to_s.downcase.intern |
4428 | - |
4429 | - # LAK:NOTE: This is slow for many options, but generally we won't have any and at |
4430 | - # worst we'll have one. If we add more, this should be made more efficient. |
4431 | - options.each do |name, value| |
4432 | - case name |
4433 | - when :ldapname; self.ldapname = value |
4434 | - else |
4435 | - raise ArgumentError, "Invalid fact option '%s'" % name |
4436 | - end |
4437 | - end |
4438 | - |
4439 | - @ldapname ||= @name.to_s |
4440 | - |
4441 | - @resolves = [] |
4442 | - @searching = false |
4443 | - |
4444 | - @value = nil |
4445 | - end |
4446 | - |
4447 | - # Add a new resolution mechanism. This requires a block, which will then |
4448 | - # be evaluated in the context of the new mechanism. |
4449 | - def add(&block) |
4450 | - raise ArgumentError, "You must pass a block to Fact<instance>.add" unless block_given? |
4451 | - |
4452 | - resolve = Facter::Util::Resolution.new(@name) |
4453 | - |
4454 | - resolve.instance_eval(&block) |
4455 | - |
4456 | - @resolves << resolve |
4457 | - |
4458 | - # Immediately sort the resolutions, so that we always have |
4459 | - # a sorted list for looking up values. |
4460 | - @resolves.sort! { |a, b| b.weight <=> a.weight } |
4461 | - |
4462 | - return resolve |
4463 | - end |
4464 | - |
4465 | - # Flush any cached values. |
4466 | - def flush |
4467 | - @value = nil |
4468 | - @suitable = nil |
4469 | - end |
4470 | - |
4471 | - # Return the value for a given fact. Searches through all of the mechanisms |
4472 | - # and returns either the first value or nil. |
4473 | - def value |
4474 | - return @value if @value |
4475 | - |
4476 | - if @resolves.length == 0 |
4477 | - Facter.debug "No resolves for %s" % @name |
4478 | - return nil |
4479 | - end |
4480 | - |
4481 | - searching do |
4482 | - @value = nil |
4483 | - |
4484 | - foundsuits = false |
4485 | - @value = @resolves.inject(nil) { |result, resolve| |
4486 | - next unless resolve.suitable? |
4487 | - foundsuits = true |
4488 | - |
4489 | - tmp = resolve.value |
4490 | - |
4491 | - break tmp unless tmp.nil? or tmp == "" |
4492 | - } |
4493 | - |
4494 | - unless foundsuits |
4495 | - Facter.debug "Found no suitable resolves of %s for %s" % [@resolves.length, @name] |
4496 | - end |
4497 | - end |
4498 | - |
4499 | - if @value.nil? |
4500 | - # nothing |
4501 | - Facter.debug("value for %s is still nil" % @name) |
4502 | - return nil |
4503 | - else |
4504 | - return @value |
4505 | - end |
4506 | - end |
4507 | - |
4508 | - private |
4509 | - |
4510 | - # Are we in the midst of a search? |
4511 | - def searching? |
4512 | - @searching |
4513 | - end |
4514 | - |
4515 | - # Lock our searching process, so we never ge stuck in recursion. |
4516 | - def searching |
4517 | - if searching? |
4518 | - Facter.debug "Caught recursion on %s" % @name |
4519 | - |
4520 | - # return a cached value if we've got it |
4521 | - if @value |
4522 | - return @value |
4523 | - else |
4524 | - return nil |
4525 | - end |
4526 | - end |
4527 | - |
4528 | - # If we've gotten this far, we're not already searching, so go ahead and do so. |
4529 | - @searching = true |
4530 | - begin |
4531 | - yield |
4532 | - ensure |
4533 | - @searching = false |
4534 | - end |
4535 | - end |
4536 | + TIMEOUT = 5 |
4537 | + |
4538 | + attr_accessor :name, :ldapname |
4539 | + |
4540 | + # Create a new fact, with no resolution mechanisms. |
4541 | + def initialize(name, options = {}) |
4542 | + @name = name.to_s.downcase.intern |
4543 | + |
4544 | + # LAK:NOTE: This is slow for many options, but generally we won't have any and at |
4545 | + # worst we'll have one. If we add more, this should be made more efficient. |
4546 | + options.each do |name, value| |
4547 | + case name |
4548 | + when :ldapname; self.ldapname = value |
4549 | + else |
4550 | + raise ArgumentError, "Invalid fact option '%s'" % name |
4551 | + end |
4552 | + end |
4553 | + |
4554 | + @ldapname ||= @name.to_s |
4555 | + |
4556 | + @resolves = [] |
4557 | + @searching = false |
4558 | + |
4559 | + @value = nil |
4560 | + end |
4561 | + |
4562 | + # Add a new resolution mechanism. This requires a block, which will then |
4563 | + # be evaluated in the context of the new mechanism. |
4564 | + def add(&block) |
4565 | + raise ArgumentError, "You must pass a block to Fact<instance>.add" unless block_given? |
4566 | + |
4567 | + resolve = Facter::Util::Resolution.new(@name) |
4568 | + |
4569 | + resolve.instance_eval(&block) |
4570 | + |
4571 | + @resolves << resolve |
4572 | + |
4573 | + # Immediately sort the resolutions, so that we always have |
4574 | + # a sorted list for looking up values. |
4575 | + @resolves.sort! { |a, b| b.weight <=> a.weight } |
4576 | + |
4577 | + return resolve |
4578 | + end |
4579 | + |
4580 | + # Flush any cached values. |
4581 | + def flush |
4582 | + @value = nil |
4583 | + @suitable = nil |
4584 | + end |
4585 | + |
4586 | + # Return the value for a given fact. Searches through all of the mechanisms |
4587 | + # and returns either the first value or nil. |
4588 | + def value |
4589 | + return @value if @value |
4590 | + |
4591 | + if @resolves.length == 0 |
4592 | + Facter.debug "No resolves for %s" % @name |
4593 | + return nil |
4594 | + end |
4595 | + |
4596 | + searching do |
4597 | + @value = nil |
4598 | + |
4599 | + foundsuits = false |
4600 | + @value = @resolves.inject(nil) { |result, resolve| |
4601 | + next unless resolve.suitable? |
4602 | + foundsuits = true |
4603 | + |
4604 | + tmp = resolve.value |
4605 | + |
4606 | + break tmp unless tmp.nil? or tmp == "" |
4607 | + } |
4608 | + |
4609 | + unless foundsuits |
4610 | + Facter.debug "Found no suitable resolves of %s for %s" % [@resolves.length, @name] |
4611 | + end |
4612 | + end |
4613 | + |
4614 | + if @value.nil? |
4615 | + # nothing |
4616 | + Facter.debug("value for %s is still nil" % @name) |
4617 | + return nil |
4618 | + else |
4619 | + return @value |
4620 | + end |
4621 | + end |
4622 | + |
4623 | + private |
4624 | + |
4625 | + # Are we in the midst of a search? |
4626 | + def searching? |
4627 | + @searching |
4628 | + end |
4629 | + |
4630 | + # Lock our searching process, so we never ge stuck in recursion. |
4631 | + def searching |
4632 | + if searching? |
4633 | + Facter.debug "Caught recursion on %s" % @name |
4634 | + |
4635 | + # return a cached value if we've got it |
4636 | + if @value |
4637 | + return @value |
4638 | + else |
4639 | + return nil |
4640 | + end |
4641 | + end |
4642 | + |
4643 | + # If we've gotten this far, we're not already searching, so go ahead and do so. |
4644 | + @searching = true |
4645 | + begin |
4646 | + yield |
4647 | + ensure |
4648 | + @searching = false |
4649 | + end |
4650 | + end |
4651 | end |
4652 | |
4653 | === modified file 'lib/facter/util/ip.rb' |
4654 | --- lib/facter/util/ip.rb 2011-10-06 10:48:30 +0000 |
4655 | +++ lib/facter/util/ip.rb 2011-11-14 19:37:34 +0000 |
4656 | @@ -1,202 +1,202 @@ |
4657 | # A base module for collecting IP-related |
4658 | # information from all kinds of platforms. |
4659 | module Facter::Util::IP |
4660 | - # A map of all the different regexes that work for |
4661 | - # a given platform or set of platforms. |
4662 | - REGEX_MAP = { |
4663 | - :linux => { |
4664 | - :ipaddress => /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, |
4665 | - :ipaddress6 => /inet6 addr: ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, |
4666 | - :macaddress => /(?:ether|HWaddr)\s+(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/, |
4667 | - :netmask => /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
4668 | - }, |
4669 | - :bsd => { |
4670 | - :aliases => [:openbsd, :netbsd, :freebsd, :darwin, :"gnu/kfreebsd"], |
4671 | - :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, |
4672 | - :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, |
4673 | - :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/, |
4674 | - :netmask => /netmask\s+0x(\w{8})/ |
4675 | - }, |
4676 | - :sunos => { |
4677 | - :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, |
4678 | - :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, |
4679 | - :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/, |
4680 | - :netmask => /netmask\s+(\w{8})/ |
4681 | - }, |
4682 | - :"hp-ux" => { |
4683 | - :ipaddress => /\s+inet (\S+)\s.*/, |
4684 | - :macaddress => /(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/, |
4685 | - :netmask => /.*\s+netmask (\S+)\s.*/ |
4686 | - }, |
4687 | - :windows => { |
4688 | - :ipaddress => /\s+IP Address:\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, |
4689 | - :ipaddress6 => /Address ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, |
4690 | - :netmask => /\s+Subnet Prefix:\s+\S+\s+\(mask ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\)/ |
4691 | - } |
4692 | + # A map of all the different regexes that work for |
4693 | + # a given platform or set of platforms. |
4694 | + REGEX_MAP = { |
4695 | + :linux => { |
4696 | + :ipaddress => /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, |
4697 | + :ipaddress6 => /inet6 addr: ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, |
4698 | + :macaddress => /(?:ether|HWaddr)\s+(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/, |
4699 | + :netmask => /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ |
4700 | + }, |
4701 | + :bsd => { |
4702 | + :aliases => [:openbsd, :netbsd, :freebsd, :darwin, :"gnu/kfreebsd", :dragonfly], |
4703 | + :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, |
4704 | + :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, |
4705 | + :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/, |
4706 | + :netmask => /netmask\s+0x(\w{8})/ |
4707 | + }, |
4708 | + :sunos => { |
4709 | + :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, |
4710 | + :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, |
4711 | + :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/, |
4712 | + :netmask => /netmask\s+(\w{8})/ |
4713 | + }, |
4714 | + :"hp-ux" => { |
4715 | + :ipaddress => /\s+inet (\S+)\s.*/, |
4716 | + :macaddress => /(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/, |
4717 | + :netmask => /.*\s+netmask (\S+)\s.*/ |
4718 | + }, |
4719 | + :windows => { |
4720 | + :ipaddress => /\s+IP Address:\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/, |
4721 | + :ipaddress6 => /Address ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/, |
4722 | + :netmask => /\s+Subnet Prefix:\s+\S+\s+\(mask ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\)/ |
4723 | } |
4724 | - |
4725 | - # Convert an interface name into purely alphanumeric characters. |
4726 | - def self.alphafy(interface) |
4727 | - interface.gsub(/[^a-z0-9_]/i, '_') |
4728 | - end |
4729 | - |
4730 | - def self.convert_from_hex?(kernel) |
4731 | - kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin, :"hp-ux", :"gnu/kfreebsd"] |
4732 | - kernels_to_convert.include?(kernel) |
4733 | - end |
4734 | - |
4735 | - def self.supported_platforms |
4736 | - REGEX_MAP.inject([]) do |result, tmp| |
4737 | - key, map = tmp |
4738 | - if map[:aliases] |
4739 | - result += map[:aliases] |
4740 | - else |
4741 | - result << key |
4742 | - end |
4743 | - result |
4744 | - end |
4745 | - end |
4746 | - |
4747 | - def self.get_interfaces |
4748 | - return [] unless output = Facter::Util::IP.get_all_interface_output() |
4749 | - |
4750 | - # windows interface names contain spaces and are quoted and can appear multiple |
4751 | - # times as ipv4 and ipv6 |
4752 | - return output.scan(/\s* connected\s*(\S.*)/).flatten.uniq if Facter.value(:kernel) == 'windows' |
4753 | - |
4754 | - # Our regex appears to be stupid, in that it leaves colons sitting |
4755 | - # at the end of interfaces. So, we have to trim those trailing |
4756 | - # characters. I tried making the regex better but supporting all |
4757 | - # platforms with a single regex is probably a bit too much. |
4758 | - output.scan(/^\S+/).collect { |i| i.sub(/:$/, '') }.uniq |
4759 | - end |
4760 | - |
4761 | - def self.get_all_interface_output |
4762 | - case Facter.value(:kernel) |
4763 | - when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD' |
4764 | - output = %x{/sbin/ifconfig -a} |
4765 | - when 'SunOS' |
4766 | - output = %x{/usr/sbin/ifconfig -a} |
4767 | - when 'HP-UX' |
4768 | - output = %x{/bin/netstat -in | sed -e 1d} |
4769 | - when 'windows' |
4770 | - output = %x|#{ENV['SYSTEMROOT']}/system32/netsh interface ip show interface| |
4771 | - output += %x|#{ENV['SYSTEMROOT']}/system32/netsh interface ipv6 show interface| |
4772 | - end |
4773 | - output |
4774 | - end |
4775 | - |
4776 | - def self.get_single_interface_output(interface) |
4777 | - output = "" |
4778 | - case Facter.value(:kernel) |
4779 | - when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD' |
4780 | - output = %x{/sbin/ifconfig #{interface}} |
4781 | - when 'SunOS' |
4782 | - output = %x{/usr/sbin/ifconfig #{interface}} |
4783 | - when 'HP-UX' |
4784 | - mac = "" |
4785 | - ifc = %x{/usr/sbin/ifconfig #{interface}} |
4786 | - %x{/usr/sbin/lanscan}.scan(/(\dx\S+).*UP\s+(\w+\d+)/).each {|i| mac = i[0] if i.include?(interface) } |
4787 | - mac = mac.sub(/0x(\S+)/,'\1').scan(/../).join(":") |
4788 | - output = ifc + "\n" + mac |
4789 | - end |
4790 | - output |
4791 | - end |
4792 | - |
4793 | - def self.get_output_for_interface_and_label(interface, label) |
4794 | - return get_single_interface_output(interface) unless Facter.value(:kernel) == 'windows' |
4795 | - |
4796 | - if label == 'ipaddress6' |
4797 | - output = %x|#{ENV['SYSTEMROOT']}/system32/netsh interface ipv6 show address \"#{interface}\"| |
4798 | - else |
4799 | - output = %x|#{ENV['SYSTEMROOT']}/system32/netsh interface ip show address \"#{interface}\"| |
4800 | - end |
4801 | - output |
4802 | - end |
4803 | - |
4804 | - def self.get_bonding_master(interface) |
4805 | - if Facter.value(:kernel) != 'Linux' |
4806 | - return nil |
4807 | - end |
4808 | - # We need ip instead of ifconfig because it will show us |
4809 | - # the bonding master device. |
4810 | - if not FileTest.executable?("/sbin/ip") |
4811 | - return nil |
4812 | - end |
4813 | - # A bonding interface can never be an alias interface. Alias |
4814 | - # interfaces do have a colon in their name and the ip link show |
4815 | - # command throws an error message when we pass it an alias |
4816 | - # interface. |
4817 | - if interface =~ /:/ |
4818 | - return nil |
4819 | - end |
4820 | - regex = /SLAVE[,>].* (bond[0-9]+)/ |
4821 | - ethbond = regex.match(%x{/sbin/ip link show #{interface}}) |
4822 | - if ethbond |
4823 | - device = ethbond[1] |
4824 | - else |
4825 | - device = nil |
4826 | - end |
4827 | - device |
4828 | - end |
4829 | - |
4830 | - def self.get_interface_value(interface, label) |
4831 | - tmp1 = [] |
4832 | - |
4833 | - kernel = Facter.value(:kernel).downcase.to_sym |
4834 | - |
4835 | - # If it's not directly in the map or aliased in the map, then we don't know how to deal with it. |
4836 | - unless map = REGEX_MAP[kernel] || REGEX_MAP.values.find { |tmp| tmp[:aliases] and tmp[:aliases].include?(kernel) } |
4837 | - return [] |
4838 | - end |
4839 | - |
4840 | - # Pull the correct regex out of the map. |
4841 | - regex = map[label.to_sym] |
4842 | - |
4843 | - # Linux changes the MAC address reported via ifconfig when an ethernet interface |
4844 | - # becomes a slave of a bonding device to the master MAC address. |
4845 | - # We have to dig a bit to get the original/real MAC address of the interface. |
4846 | - bonddev = get_bonding_master(interface) |
4847 | - if label == 'macaddress' and bonddev |
4848 | - bondinfo = IO.readlines("/proc/net/bonding/#{bonddev}") |
4849 | - hwaddrre = /^Slave Interface: #{interface}\n[^\n].+?\nPermanent HW addr: (([0-9a-fA-F]{2}:?)*)$/m |
4850 | - value = hwaddrre.match(bondinfo.to_s)[1].upcase |
4851 | - else |
4852 | - output_int = get_output_for_interface_and_label(interface, label) |
4853 | - |
4854 | - output_int.each_line do |s| |
4855 | - if s =~ regex |
4856 | - value = $1 |
4857 | - if label == 'netmask' && convert_from_hex?(kernel) |
4858 | - value = value.scan(/../).collect do |byte| byte.to_i(16) end.join('.') |
4859 | - end |
4860 | - tmp1.push(value) |
4861 | - end |
4862 | - end |
4863 | - |
4864 | - if tmp1 |
4865 | - value = tmp1.shift |
4866 | - end |
4867 | - end |
4868 | - end |
4869 | - |
4870 | - def self.get_network_value(interface) |
4871 | - require 'ipaddr' |
4872 | - |
4873 | - ipaddress = get_interface_value(interface, "ipaddress") |
4874 | - netmask = get_interface_value(interface, "netmask") |
4875 | - |
4876 | - if ipaddress && netmask |
4877 | - ip = IPAddr.new(ipaddress, Socket::AF_INET) |
4878 | - subnet = IPAddr.new(netmask, Socket::AF_INET) |
4879 | - network = ip.mask(subnet.to_s).to_s |
4880 | - end |
4881 | - end |
4882 | - |
4883 | - def self.get_arp_value(interface) |
4884 | - arp = Facter::Util::Resolution.exec("arp -en -i #{interface} | sed -e 1d") |
4885 | - if arp =~ /^\S+\s+\w+\s+(\S+)\s+\w\s+\S+$/ |
4886 | - return $1 |
4887 | - end |
4888 | - end |
4889 | + } |
4890 | + |
4891 | + # Convert an interface name into purely alphanumeric characters. |
4892 | + def self.alphafy(interface) |
4893 | + interface.gsub(/[^a-z0-9_]/i, '_') |
4894 | + end |
4895 | + |
4896 | + def self.convert_from_hex?(kernel) |
4897 | + kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin, :"hp-ux", :"gnu/kfreebsd", :dragonfly] |
4898 | + kernels_to_convert.include?(kernel) |
4899 | + end |
4900 | + |
4901 | + def self.supported_platforms |
4902 | + REGEX_MAP.inject([]) do |result, tmp| |
4903 | + key, map = tmp |
4904 | + if map[:aliases] |
4905 | + result += map[:aliases] |
4906 | + else |
4907 | + result << key |
4908 | + end |
4909 | + result |
4910 | + end |
4911 | + end |
4912 | + |
4913 | + def self.get_interfaces |
4914 | + return [] unless output = Facter::Util::IP.get_all_interface_output() |
4915 | + |
4916 | + # windows interface names contain spaces and are quoted and can appear multiple |
4917 | + # times as ipv4 and ipv6 |
4918 | + return output.scan(/\s* connected\s*(\S.*)/).flatten.uniq if Facter.value(:kernel) == 'windows' |
4919 | + |
4920 | + # Our regex appears to be stupid, in that it leaves colons sitting |
4921 | + # at the end of interfaces. So, we have to trim those trailing |
4922 | + # characters. I tried making the regex better but supporting all |
4923 | + # platforms with a single regex is probably a bit too much. |
4924 | + output.scan(/^\S+/).collect { |i| i.sub(/:$/, '') }.uniq |
4925 | + end |
4926 | + |
4927 | + def self.get_all_interface_output |
4928 | + case Facter.value(:kernel) |
4929 | + when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD', 'DragonFly' |
4930 | + output = %x{/sbin/ifconfig -a} |
4931 | + when 'SunOS' |
4932 | + output = %x{/usr/sbin/ifconfig -a} |
4933 | + when 'HP-UX' |
4934 | + output = %x{/bin/netstat -in | sed -e 1d} |
4935 | + when 'windows' |
4936 | + output = %x|#{ENV['SYSTEMROOT']}/system32/netsh interface ip show interface| |
4937 | + output += %x|#{ENV['SYSTEMROOT']}/system32/netsh interface ipv6 show interface| |
4938 | + end |
4939 | + output |
4940 | + end |
4941 | + |
4942 | + def self.get_single_interface_output(interface) |
4943 | + output = "" |
4944 | + case Facter.value(:kernel) |
4945 | + when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD', 'DragonFly' |
4946 | + output = %x{/sbin/ifconfig #{interface}} |
4947 | + when 'SunOS' |
4948 | + output = %x{/usr/sbin/ifconfig #{interface}} |
4949 | + when 'HP-UX' |
4950 | + mac = "" |
4951 | + ifc = %x{/usr/sbin/ifconfig #{interface}} |
4952 | + %x{/usr/sbin/lanscan}.scan(/(\dx\S+).*UP\s+(\w+\d+)/).each {|i| mac = i[0] if i.include?(interface) } |
4953 | + mac = mac.sub(/0x(\S+)/,'\1').scan(/../).join(":") |
4954 | + output = ifc + "\n" + mac |
4955 | + end |
4956 | + output |
4957 | + end |
4958 | + |
4959 | + def self.get_output_for_interface_and_label(interface, label) |
4960 | + return get_single_interface_output(interface) unless Facter.value(:kernel) == 'windows' |
4961 | + |
4962 | + if label == 'ipaddress6' |
4963 | + output = %x|#{ENV['SYSTEMROOT']}/system32/netsh interface ipv6 show address \"#{interface}\"| |
4964 | + else |
4965 | + output = %x|#{ENV['SYSTEMROOT']}/system32/netsh interface ip show address \"#{interface}\"| |
4966 | + end |
4967 | + output |
4968 | + end |
4969 | + |
4970 | + def self.get_bonding_master(interface) |
4971 | + if Facter.value(:kernel) != 'Linux' |
4972 | + return nil |
4973 | + end |
4974 | + # We need ip instead of ifconfig because it will show us |
4975 | + # the bonding master device. |
4976 | + if not FileTest.executable?("/sbin/ip") |
4977 | + return nil |
4978 | + end |
4979 | + # A bonding interface can never be an alias interface. Alias |
4980 | + # interfaces do have a colon in their name and the ip link show |
4981 | + # command throws an error message when we pass it an alias |
4982 | + # interface. |
4983 | + if interface =~ /:/ |
4984 | + return nil |
4985 | + end |
4986 | + regex = /SLAVE[,>].* (bond[0-9]+)/ |
4987 | + ethbond = regex.match(%x{/sbin/ip link show #{interface}}) |
4988 | + if ethbond |
4989 | + device = ethbond[1] |
4990 | + else |
4991 | + device = nil |
4992 | + end |
4993 | + device |
4994 | + end |
4995 | + |
4996 | + def self.get_interface_value(interface, label) |
4997 | + tmp1 = [] |
4998 | + |
4999 | + kernel = Facter.value(:kernel).downcase.to_sym |
5000 | + |
Great work, two comments:
Diff from Debian to your merge:
-Build-Depends: debhelper (>= 8), gem2deb (>= 0.2.4~)
+Build-Depends: debhelper (>= 5.0.0), ruby (>= 1.8), libopenssl-ruby
lintian is complaining that we do infact need debhelper (>= 8) /usr/lib/ ruby/1. 8", which will silently break if 1.9 is installed?
I'm also wondering if the ruby depends should be changed to, "ruby (>= 1.8) , ruby (<< 1.9)" - as the Ubuntu delta makes use of "--sitelibdir=
What are your thoughts?
Other things that should probably be looked at: lintian. debian. org/tags/ dh-clean- k-is-deprecated .html
http://
As this is a Ubuntu delta of debian/rules: we should probably add: lintian. debian. org/tags/ debian- rules-missing- recommended- target. html
http://
(Otherwise, looks great!)
Thanks!