ohai 13.12.6 → 14.0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -12
  3. data/README.md +7 -12
  4. data/Rakefile +16 -23
  5. data/docs/man/man1/ohai.1 +97 -0
  6. data/lib/ohai/application.rb +9 -4
  7. data/lib/ohai/common/dmi.rb +4 -16
  8. data/lib/ohai/config.rb +5 -1
  9. data/lib/ohai/dsl.rb +0 -1
  10. data/lib/ohai/dsl/plugin.rb +12 -16
  11. data/lib/ohai/dsl/plugin/versionvii.rb +17 -5
  12. data/lib/ohai/hints.rb +2 -2
  13. data/lib/ohai/loader.rb +21 -70
  14. data/lib/ohai/log.rb +1 -1
  15. data/lib/ohai/mixin/azure_metadata.rb +4 -4
  16. data/lib/ohai/mixin/command.rb +3 -3
  17. data/lib/ohai/mixin/dmi_decode.rb +0 -2
  18. data/lib/ohai/mixin/do_metadata.rb +1 -1
  19. data/lib/ohai/mixin/ec2_metadata.rb +8 -8
  20. data/lib/ohai/mixin/gce_metadata.rb +1 -5
  21. data/lib/ohai/mixin/http_helper.rb +3 -3
  22. data/lib/ohai/mixin/scaleway_metadata.rb +46 -0
  23. data/lib/ohai/mixin/softlayer_metadata.rb +3 -3
  24. data/lib/ohai/plugins/aix/filesystem.rb +1 -1
  25. data/lib/ohai/plugins/aix/memory.rb +1 -1
  26. data/lib/ohai/plugins/aix/network.rb +2 -2
  27. data/lib/ohai/plugins/aix/virtualization.rb +1 -1
  28. data/lib/ohai/plugins/azure.rb +5 -5
  29. data/lib/ohai/plugins/bsd/virtualization.rb +11 -11
  30. data/lib/ohai/plugins/c.rb +8 -8
  31. data/lib/ohai/plugins/chef.rb +2 -1
  32. data/lib/ohai/plugins/cloud.rb +0 -3
  33. data/lib/ohai/plugins/darwin/cpu.rb +2 -2
  34. data/lib/ohai/plugins/darwin/filesystem.rb +0 -2
  35. data/lib/ohai/plugins/darwin/hardware.rb +9 -3
  36. data/lib/ohai/plugins/darwin/network.rb +2 -2
  37. data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
  38. data/lib/ohai/plugins/darwin/virtualization.rb +10 -0
  39. data/lib/ohai/plugins/digital_ocean.rb +4 -4
  40. data/lib/ohai/plugins/dmi.rb +15 -14
  41. data/lib/ohai/plugins/docker.rb +57 -0
  42. data/lib/ohai/plugins/ec2.rb +11 -11
  43. data/lib/ohai/plugins/elixir.rb +1 -1
  44. data/lib/ohai/plugins/erlang.rb +2 -2
  45. data/lib/ohai/plugins/eucalyptus.rb +5 -5
  46. data/lib/ohai/plugins/gce.rb +2 -2
  47. data/lib/ohai/plugins/go.rb +1 -1
  48. data/lib/ohai/plugins/groovy.rb +1 -1
  49. data/lib/ohai/plugins/haskell.rb +4 -4
  50. data/lib/ohai/plugins/hostname.rb +6 -6
  51. data/lib/ohai/plugins/init_package.rb +1 -1
  52. data/lib/ohai/plugins/java.rb +1 -1
  53. data/lib/ohai/plugins/kernel.rb +109 -40
  54. data/lib/ohai/plugins/libvirt.rb +113 -0
  55. data/lib/ohai/plugins/linode.rb +4 -4
  56. data/lib/ohai/plugins/linux/block_device.rb +4 -4
  57. data/lib/ohai/plugins/linux/cpu.rb +3 -3
  58. data/lib/ohai/plugins/linux/filesystem.rb +4 -6
  59. data/lib/ohai/plugins/linux/lsb.rb +3 -3
  60. data/lib/ohai/plugins/linux/lspci.rb +2 -1
  61. data/lib/ohai/plugins/linux/machineid.rb +4 -4
  62. data/lib/ohai/plugins/linux/network.rb +16 -16
  63. data/lib/ohai/plugins/linux/platform.rb +4 -10
  64. data/lib/ohai/plugins/linux/sessions.rb +2 -1
  65. data/lib/ohai/plugins/linux/virtualization.rb +53 -31
  66. data/lib/ohai/plugins/lua.rb +1 -1
  67. data/lib/ohai/plugins/mono.rb +2 -2
  68. data/lib/ohai/plugins/network.rb +11 -11
  69. data/lib/ohai/plugins/nodejs.rb +1 -1
  70. data/lib/ohai/plugins/ohai.rb +0 -2
  71. data/lib/ohai/plugins/openstack.rb +7 -10
  72. data/lib/ohai/plugins/packages.rb +1 -1
  73. data/lib/ohai/plugins/passwd.rb +1 -0
  74. data/lib/ohai/plugins/perl.rb +1 -1
  75. data/lib/ohai/plugins/php.rb +1 -1
  76. data/lib/ohai/plugins/powershell.rb +1 -1
  77. data/lib/ohai/plugins/python.rb +1 -1
  78. data/lib/ohai/plugins/rackspace.rb +5 -5
  79. data/lib/ohai/plugins/root_group.rb +6 -9
  80. data/lib/ohai/plugins/ruby.rb +2 -2
  81. data/lib/ohai/plugins/rust.rb +1 -1
  82. data/lib/ohai/plugins/scala.rb +1 -1
  83. data/lib/ohai/plugins/scaleway.rb +56 -0
  84. data/lib/ohai/plugins/shard.rb +1 -0
  85. data/lib/ohai/plugins/softlayer.rb +2 -2
  86. data/lib/ohai/plugins/solaris2/cpu.rb +1 -1
  87. data/lib/ohai/plugins/solaris2/dmi.rb +13 -13
  88. data/lib/ohai/plugins/solaris2/network.rb +6 -6
  89. data/lib/ohai/plugins/solaris2/platform.rb +2 -2
  90. data/lib/ohai/plugins/ssh_host_key.rb +7 -7
  91. data/lib/ohai/plugins/uptime.rb +2 -7
  92. data/lib/ohai/plugins/virtualbox.rb +1 -1
  93. data/lib/ohai/plugins/vmware.rb +2 -2
  94. data/lib/ohai/plugins/windows/cpu.rb +2 -16
  95. data/lib/ohai/plugins/windows/network.rb +4 -2
  96. data/lib/ohai/plugins/zpools.rb +3 -3
  97. data/lib/ohai/provides_map.rb +1 -1
  98. data/lib/ohai/runner.rb +11 -14
  99. data/lib/ohai/system.rb +8 -71
  100. data/lib/ohai/util/file_helper.rb +2 -2
  101. data/lib/ohai/util/win32/group_helper.rb +0 -2
  102. data/lib/ohai/version.rb +1 -1
  103. data/ohai.gemspec +6 -5
  104. data/spec/functional/plugins/root_group_spec.rb +2 -2
  105. data/spec/functional/plugins/windows/uptime_spec.rb +0 -29
  106. data/spec/unit/dsl/plugin_spec.rb +14 -46
  107. data/spec/unit/loader_spec.rb +8 -70
  108. data/spec/unit/mixin/azure_metadata_spec.rb +9 -4
  109. data/spec/unit/mixin/command_spec.rb +11 -8
  110. data/spec/unit/mixin/ec2_metadata_spec.rb +5 -0
  111. data/spec/unit/mixin/softlayer_metadata_spec.rb +6 -1
  112. data/spec/unit/plugins/aix/filesystem_spec.rb +10 -10
  113. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  114. data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
  115. data/spec/unit/plugins/cloud_spec.rb +0 -12
  116. data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
  117. data/spec/unit/plugins/darwin/filesystem_spec.rb +1 -6
  118. data/spec/unit/plugins/darwin/hardware_spec.rb +1 -1
  119. data/spec/unit/plugins/darwin/virtualization_spec.rb +8 -0
  120. data/spec/unit/plugins/dmi_spec.rb +17 -25
  121. data/spec/unit/plugins/docker_spec.rb +100 -0
  122. data/spec/unit/plugins/fail_spec.rb +3 -58
  123. data/spec/unit/plugins/haskell_spec.rb +1 -1
  124. data/spec/unit/plugins/init_package_spec.rb +1 -1
  125. data/spec/unit/plugins/kernel_spec.rb +0 -52
  126. data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
  127. data/spec/unit/plugins/linux/filesystem_spec.rb +2 -7
  128. data/spec/unit/plugins/linux/lsb_spec.rb +5 -5
  129. data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
  130. data/spec/unit/plugins/linux/machineid_spec.rb +5 -5
  131. data/spec/unit/plugins/linux/network_spec.rb +16 -16
  132. data/spec/unit/plugins/linux/platform_spec.rb +1 -17
  133. data/spec/unit/plugins/linux/virtualization_spec.rb +21 -1
  134. data/spec/unit/plugins/network_spec.rb +58 -58
  135. data/spec/unit/plugins/openstack_spec.rb +5 -24
  136. data/spec/unit/plugins/rackspace_spec.rb +6 -6
  137. data/spec/unit/plugins/root_group_spec.rb +1 -1
  138. data/spec/unit/plugins/ruby_spec.rb +1 -1
  139. data/spec/unit/plugins/rust_spec.rb +1 -1
  140. data/spec/unit/plugins/scala_spec.rb +1 -1
  141. data/spec/unit/plugins/scaleway_spec.rb +91 -0
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
  143. data/spec/unit/plugins/solaris2/platform_spec.rb +2 -2
  144. data/spec/unit/plugins/ssh_host_keys_spec.rb +8 -8
  145. data/spec/unit/plugins/sysconf_spec.rb +1 -0
  146. data/spec/unit/plugins/windows/kernel_spec.rb +79 -0
  147. data/spec/unit/plugins/windows/uptime_spec.rb +8 -58
  148. data/spec/unit/provides_map_spec.rb +4 -4
  149. data/spec/unit/runner_spec.rb +15 -54
  150. data/spec/unit/system_spec.rb +35 -348
  151. data/spec/unit/util/file_helper_spec.rb +2 -0
  152. metadata +28 -28
  153. data/lib/ohai/dsl/plugin/versionvi.rb +0 -61
  154. data/lib/ohai/plugins/bsd/filesystem2.rb +0 -121
  155. data/lib/ohai/plugins/ip_scopes.rb +0 -67
  156. data/lib/ohai/plugins/virtualization.rb +0 -83
  157. data/spec/data/plugins/messages.rb +0 -8
  158. data/spec/data/plugins/v6message.rb +0 -2
  159. data/spec/unit/plugins/bsd/filesystem2_spec.rb +0 -126
  160. data/spec/unit/plugins/ip_scopes_spec.rb +0 -139
@@ -28,6 +28,8 @@ describe "Ohai::Util::FileHelper" do
28
28
 
29
29
  before(:each) do
30
30
  allow(file_helper).to receive(:name).and_return("Fakeclass")
31
+ logger = instance_double("Mixlib::Log::Child", trace: nil, debug: nil, warn: nil)
32
+ allow(file_helper).to receive(:logger).and_return(logger)
31
33
  allow(File).to receive(:executable?).and_return(false)
32
34
  end
33
35
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.12.6
4
+ version: 14.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-07 00:00:00.000000000 Z
11
+ date: 2018-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: mixlib-cli
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "<"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '2.0'
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "<"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '2.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mixlib-config
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,22 +70,22 @@ dependencies:
70
70
  name: mixlib-log
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 1.7.1
76
- - - "<"
73
+ - - "~>"
77
74
  - !ruby/object:Gem::Version
78
75
  version: '2.0'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 2.0.1
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: 1.7.1
86
- - - "<"
83
+ - - "~>"
87
84
  - !ruby/object:Gem::Version
88
85
  version: '2.0'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 2.0.1
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: mixlib-shellout
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -162,20 +162,20 @@ dependencies:
162
162
  requirements:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: 12.5.0.alpha.1
165
+ version: '12.8'
166
166
  - - "<"
167
167
  - !ruby/object:Gem::Version
168
- version: '14'
168
+ version: '15'
169
169
  type: :runtime
170
170
  prerelease: false
171
171
  version_requirements: !ruby/object:Gem::Requirement
172
172
  requirements:
173
173
  - - ">="
174
174
  - !ruby/object:Gem::Version
175
- version: 12.5.0.alpha.1
175
+ version: '12.8'
176
176
  - - "<"
177
177
  - !ruby/object:Gem::Version
178
- version: '14'
178
+ version: '15'
179
179
  description: Ohai profiles your system and emits JSON
180
180
  email: adam@chef.io
181
181
  executables:
@@ -188,13 +188,13 @@ files:
188
188
  - README.md
189
189
  - Rakefile
190
190
  - bin/ohai
191
+ - docs/man/man1/ohai.1
191
192
  - lib/ohai.rb
192
193
  - lib/ohai/application.rb
193
194
  - lib/ohai/common/dmi.rb
194
195
  - lib/ohai/config.rb
195
196
  - lib/ohai/dsl.rb
196
197
  - lib/ohai/dsl/plugin.rb
197
- - lib/ohai/dsl/plugin/versionvi.rb
198
198
  - lib/ohai/dsl/plugin/versionvii.rb
199
199
  - lib/ohai/exception.rb
200
200
  - lib/ohai/hints.rb
@@ -211,6 +211,7 @@ files:
211
211
  - lib/ohai/mixin/http_helper.rb
212
212
  - lib/ohai/mixin/network_constants.rb
213
213
  - lib/ohai/mixin/os.rb
214
+ - lib/ohai/mixin/scaleway_metadata.rb
214
215
  - lib/ohai/mixin/seconds_to_human.rb
215
216
  - lib/ohai/mixin/softlayer_metadata.rb
216
217
  - lib/ohai/mixin/string.rb
@@ -226,7 +227,6 @@ files:
226
227
  - lib/ohai/plugins/aix/virtualization.rb
227
228
  - lib/ohai/plugins/azure.rb
228
229
  - lib/ohai/plugins/bsd/filesystem.rb
229
- - lib/ohai/plugins/bsd/filesystem2.rb
230
230
  - lib/ohai/plugins/bsd/virtualization.rb
231
231
  - lib/ohai/plugins/c.rb
232
232
  - lib/ohai/plugins/chef.rb
@@ -242,6 +242,7 @@ files:
242
242
  - lib/ohai/plugins/darwin/virtualization.rb
243
243
  - lib/ohai/plugins/digital_ocean.rb
244
244
  - lib/ohai/plugins/dmi.rb
245
+ - lib/ohai/plugins/docker.rb
245
246
  - lib/ohai/plugins/dragonflybsd/cpu.rb
246
247
  - lib/ohai/plugins/dragonflybsd/memory.rb
247
248
  - lib/ohai/plugins/dragonflybsd/network.rb
@@ -262,12 +263,12 @@ files:
262
263
  - lib/ohai/plugins/haskell.rb
263
264
  - lib/ohai/plugins/hostname.rb
264
265
  - lib/ohai/plugins/init_package.rb
265
- - lib/ohai/plugins/ip_scopes.rb
266
266
  - lib/ohai/plugins/java.rb
267
267
  - lib/ohai/plugins/joyent.rb
268
268
  - lib/ohai/plugins/kernel.rb
269
269
  - lib/ohai/plugins/keys.rb
270
270
  - lib/ohai/plugins/languages.rb
271
+ - lib/ohai/plugins/libvirt.rb
271
272
  - lib/ohai/plugins/linode.rb
272
273
  - lib/ohai/plugins/linux/block_device.rb
273
274
  - lib/ohai/plugins/linux/cpu.rb
@@ -313,6 +314,7 @@ files:
313
314
  - lib/ohai/plugins/ruby.rb
314
315
  - lib/ohai/plugins/rust.rb
315
316
  - lib/ohai/plugins/scala.rb
317
+ - lib/ohai/plugins/scaleway.rb
316
318
  - lib/ohai/plugins/shard.rb
317
319
  - lib/ohai/plugins/shells.rb
318
320
  - lib/ohai/plugins/softlayer.rb
@@ -328,7 +330,6 @@ files:
328
330
  - lib/ohai/plugins/timezone.rb
329
331
  - lib/ohai/plugins/uptime.rb
330
332
  - lib/ohai/plugins/virtualbox.rb
331
- - lib/ohai/plugins/virtualization.rb
332
333
  - lib/ohai/plugins/vmware.rb
333
334
  - lib/ohai/plugins/windows/cpu.rb
334
335
  - lib/ohai/plugins/windows/drivers.rb
@@ -361,7 +362,6 @@ files:
361
362
  - spec/data/plugins/java.output
362
363
  - spec/data/plugins/lslpp.output
363
364
  - spec/data/plugins/lua.output
364
- - spec/data/plugins/messages.rb
365
365
  - spec/data/plugins/node.output
366
366
  - spec/data/plugins/pacman.output
367
367
  - spec/data/plugins/perl.output
@@ -372,7 +372,6 @@ files:
372
372
  - spec/data/plugins/python.output
373
373
  - spec/data/plugins/rpmquery.output
374
374
  - spec/data/plugins/uname.output
375
- - spec/data/plugins/v6message.rb
376
375
  - spec/data/plugins/v7message.rb
377
376
  - spec/data/plugins/what.output
378
377
  - spec/data/plugins/xlc.output
@@ -409,7 +408,6 @@ files:
409
408
  - spec/unit/plugins/aix/uptime_spec.rb
410
409
  - spec/unit/plugins/aix/virtualization_spec.rb
411
410
  - spec/unit/plugins/azure_spec.rb
412
- - spec/unit/plugins/bsd/filesystem2_spec.rb
413
411
  - spec/unit/plugins/bsd/filesystem_spec.rb
414
412
  - spec/unit/plugins/bsd/virtualization_spec.rb
415
413
  - spec/unit/plugins/c_spec.rb
@@ -429,6 +427,7 @@ files:
429
427
  - spec/unit/plugins/darwin/virtualization_spec.rb
430
428
  - spec/unit/plugins/digital_ocean_spec.rb
431
429
  - spec/unit/plugins/dmi_spec.rb
430
+ - spec/unit/plugins/docker_spec.rb
432
431
  - spec/unit/plugins/ec2_spec.rb
433
432
  - spec/unit/plugins/elixir_spec.rb
434
433
  - spec/unit/plugins/erlang_spec.rb
@@ -445,7 +444,6 @@ files:
445
444
  - spec/unit/plugins/haskell_spec.rb
446
445
  - spec/unit/plugins/hostname_spec.rb
447
446
  - spec/unit/plugins/init_package_spec.rb
448
- - spec/unit/plugins/ip_scopes_spec.rb
449
447
  - spec/unit/plugins/java_spec.rb
450
448
  - spec/unit/plugins/joyent_spec.rb
451
449
  - spec/unit/plugins/kernel_spec.rb
@@ -494,6 +492,7 @@ files:
494
492
  - spec/unit/plugins/ruby_spec.rb
495
493
  - spec/unit/plugins/rust_spec.rb
496
494
  - spec/unit/plugins/scala_spec.rb
495
+ - spec/unit/plugins/scaleway_spec.rb
497
496
  - spec/unit/plugins/shard_spec.rb
498
497
  - spec/unit/plugins/shells_spec.rb
499
498
  - spec/unit/plugins/softlayer_spec.rb
@@ -513,6 +512,7 @@ files:
513
512
  - spec/unit/plugins/vmware_spec.rb
514
513
  - spec/unit/plugins/windows/cpu_spec.rb
515
514
  - spec/unit/plugins/windows/fips_spec.rb
515
+ - spec/unit/plugins/windows/kernel_spec.rb
516
516
  - spec/unit/plugins/windows/memory_spec.rb
517
517
  - spec/unit/plugins/windows/uptime_spec.rb
518
518
  - spec/unit/plugins/windows/virtualization_spec.rb
@@ -534,7 +534,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
534
534
  requirements:
535
535
  - - ">="
536
536
  - !ruby/object:Gem::Version
537
- version: '2.3'
537
+ version: '2.4'
538
538
  required_rubygems_version: !ruby/object:Gem::Requirement
539
539
  requirements:
540
540
  - - ">="
@@ -542,7 +542,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
542
542
  version: '0'
543
543
  requirements: []
544
544
  rubyforge_project:
545
- rubygems_version: 2.7.6
545
+ rubygems_version: 2.7.4
546
546
  signing_key:
547
547
  specification_version: 4
548
548
  summary: Ohai profiles your system and emits JSON
@@ -1,61 +0,0 @@
1
- #
2
- # Author:: Serdar Sutay (<serdar@chef.io>)
3
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15
- # implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- module Ohai
21
- module DSL
22
- class Plugin
23
- class VersionVI < Plugin
24
- attr_reader :version
25
- attr_reader :source
26
-
27
- def initialize(controller, plugin_path, plugin_dir_path)
28
- super(controller.data)
29
- @controller = controller
30
- @version = :version6
31
- @source = plugin_path
32
- @plugin_dir_path = plugin_dir_path
33
- end
34
-
35
- def name
36
- # Ohai V6 doesn't have any name specification for plugins.
37
- # So we are using the partial path to infer the name of the plugin
38
- partial_path = Pathname.new(@source).relative_path_from(Pathname.new(@plugin_dir_path)).to_s
39
- partial_path.chomp(".rb").gsub("/", "::")
40
- end
41
-
42
- def self.version
43
- :version6
44
- end
45
-
46
- def self.collect_contents(contents)
47
- define_method(:run_plugin) { instance_eval(contents) }
48
- end
49
-
50
- def provides(*paths)
51
- Ohai::Log.debug("Skipping provides '#{paths.join(",")}' for plugin '#{name}'")
52
- end
53
-
54
- def require_plugin(plugin_ref)
55
- @controller.require_plugin(plugin_ref)
56
- end
57
-
58
- end
59
- end
60
- end
61
- end
@@ -1,121 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Author:: Tim Smith (<tsmith@chef.io>)
4
- # Author:: Phil Dibowitz (<phil@ipom.com>)
5
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
6
- # License:: Apache License, Version 2.0
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- Ohai.plugin(:Filesystem2) do
22
- provides "filesystem2"
23
-
24
- def generate_device_view(fs)
25
- view = {}
26
- fs.each_value do |entry|
27
- view[entry[:device]] = Mash.new unless view[entry[:device]]
28
- entry.each do |key, val|
29
- next if %w{device mount}.include?(key)
30
- view[entry[:device]][key] = val
31
- end
32
- view[entry[:device]][:mounts] ||= []
33
- if entry[:mount]
34
- view[entry[:device]][:mounts] << entry[:mount]
35
- end
36
- end
37
- view
38
- end
39
-
40
- def generate_mountpoint_view(fs)
41
- view = {}
42
- fs.each_value do |entry|
43
- next unless entry[:mount]
44
- view[entry[:mount]] = Mash.new unless view[entry[:mount]]
45
- entry.each do |key, val|
46
- next if %w{mount device}.include?(key)
47
- view[entry[:mount]][key] = val
48
- end
49
- view[entry[:mount]][:devices] ||= []
50
- if entry[:device]
51
- view[entry[:mount]][:devices] << entry[:device]
52
- end
53
- end
54
- view
55
- end
56
-
57
- collect_data(:freebsd, :openbsd, :netbsd, :dragonflybsd) do
58
- fs = Mash.new
59
-
60
- # Grab filesystem data from df
61
- so = shell_out("df")
62
- so.stdout.lines do |line|
63
- case line
64
- when /^Filesystem/
65
- next
66
- when /^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(\S+)$/
67
- key = "#{$1},#{$6}"
68
- fs[key] = Mash.new
69
- fs[key][:device] = $1
70
- fs[key][:kb_size] = $2
71
- fs[key][:kb_used] = $3
72
- fs[key][:kb_available] = $4
73
- fs[key][:percent_used] = $5
74
- fs[key][:mount] = $6
75
- end
76
- end
77
-
78
- # inode parsing from 'df -iP'
79
- so = shell_out("df -iP")
80
- so.stdout.lines do |line|
81
- case line
82
- when /^Filesystem/ # skip the header
83
- next
84
- when /^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(\d+)\s+(\d+)\s+(\d+)%\s+(\S+)$/
85
- key = "#{$1},#{$9}"
86
- fs[key] ||= Mash.new
87
- fs[key][:device] = $1
88
- fs[key][:inodes_used] = $6
89
- fs[key][:inodes_available] = $7
90
- fs[key][:total_inodes] = ($6.to_i + $7.to_i).to_s
91
- fs[key][:inodes_percent_used] = $8
92
- fs[key][:mount] = $9
93
- end
94
- end
95
-
96
- # Grab mount information from mount
97
- so = shell_out("mount -l")
98
- so.stdout.lines do |line|
99
- if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
100
- key = "#{$1},#{$2}"
101
- fs[key] ||= Mash.new
102
- fs[key][:device] = $1
103
- fs[key][:mount] = $2
104
- fs[key][:fs_type] = $3
105
- fs[key][:mount_options] = $4.split(/,\s*/)
106
- end
107
- end
108
-
109
- # create views
110
- by_pair = fs
111
- by_device = generate_device_view(fs)
112
- by_mountpoint = generate_mountpoint_view(fs)
113
-
114
- fs_data = Mash.new
115
- fs_data["by_device"] = by_device
116
- fs_data["by_mountpoint"] = by_mountpoint
117
- fs_data["by_pair"] = by_pair
118
-
119
- filesystem2 fs_data
120
- end
121
- end
@@ -1,67 +0,0 @@
1
- #
2
- # Author:: James Harton (<james@sociable.co.nz>)
3
- # Copyright:: Copyright (c) 2010 Sociable Limited.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- Ohai.plugin(:IpScopes) do
19
- provides "network_ip_scope", "privateaddress"
20
-
21
- depends "network/interfaces"
22
-
23
- collect_data do
24
- begin
25
- require "ipaddr_extensions"
26
-
27
- Ohai::Log.warn("The IpScopes Ohai plugin has been deprecated and will be removed from Ohai 14 (April 2018).")
28
-
29
- network["interfaces"].keys.sort.each do |if_name|
30
- next if network["interfaces"][if_name]["addresses"].nil?
31
-
32
- interface = network["interfaces"][if_name]
33
- interface["addresses"].each do |address, attrs|
34
- begin
35
- attrs["ip_scope"] = address.to_ip.scope
36
-
37
- if private_addr?(address) && !tunnel_iface?(interface) && !ppp_iface?(interface) && !docker_iface?(interface)
38
- privateaddress(address)
39
- end
40
- rescue ArgumentError
41
- # Just silently fail if we can't create an IP from the string.
42
- end
43
- end
44
- end
45
-
46
- rescue LoadError => e
47
- # our favourite gem is not installed. Boohoo.
48
- Ohai::Log.debug("Plugin IpScopes: cannot load gem, plugin disabled: #{e}")
49
- end
50
- end
51
-
52
- def private_addr?(address)
53
- address.to_ip.scope =~ /PRIVATE/
54
- end
55
-
56
- def ppp_iface?(interface)
57
- interface["type"] == "ppp"
58
- end
59
-
60
- def tunnel_iface?(interface)
61
- interface["type"] == "tunl"
62
- end
63
-
64
- def docker_iface?(interface)
65
- interface["type"] == "docker"
66
- end
67
- end