ohai 8.24.1 → 8.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d81b8e833f11f3e06f70cb35f22e0947adf105b
4
- data.tar.gz: b427c451be6b57ff867e1b43363ae52f7a1d1909
3
+ metadata.gz: 58c6a195abed88b1939ee4a307af1ee95d93a3c7
4
+ data.tar.gz: 6772104fe5375365f284283dec75aef36e6c185b
5
5
  SHA512:
6
- metadata.gz: 36218913be0e9098697f9fe7369159233cac391b15171288a1d90245d498333477d4a3f1343624c57209c50307cda429c67b798e996c896e0765443266e3fb7b
7
- data.tar.gz: 6ec1424381a75fd724f6e69ffd4c54be18efeb60059a6bae5129ea1720ac8bbd77bbff7df497b4bdd89da5b8662fc2a4f0bd7475430c533911a67793599a188a
6
+ metadata.gz: 4800a4c9c26c0b5aa02279009c73c85b4e5697c1b52183391c190531508a890100deeaa23e9d09874cca53c6b008b694e7da6bc6642f14c977edfb6de9ff3dce
7
+ data.tar.gz: dd2ea9399d4a1a416cdda93f3280a41df665654d83eda6fb119a3b6db2e3dd17a5364ca41e1ca9e955eaabdc672968466228f92cef40412a1c83eaff109b6f69
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gemspec
5
5
  group :development do
6
6
  gem "sigar", :platform => "ruby"
7
7
 
8
- gem "chefstyle", "0.5.0"
8
+ gem "chefstyle", "0.4.0"
9
9
  gem "overcommit", ">= 0.34.1"
10
10
  gem "pry-byebug"
11
11
  gem "pry-stack_explorer"
@@ -16,6 +16,5 @@ group :development do
16
16
  gem "rspec-mocks", "~> 3.0"
17
17
  gem "rspec-collection_matchers", "~> 1.0"
18
18
  gem "rspec_junit_formatter"
19
- gem "github_changelog_generator", git: "https://github.com/chef/github-changelog-generator"
20
19
  gem "activesupport", "< 5.0" if RUBY_VERSION <= "2.2.2" # github_changelog_generator dep
21
20
  end
data/Rakefile CHANGED
@@ -22,14 +22,3 @@ require "rubocop/rake_task"
22
22
  RuboCop::RakeTask.new(:style) do |task|
23
23
  task.options += ["--display-cop-names", "--no-color"]
24
24
  end
25
-
26
- require "github_changelog_generator/task"
27
-
28
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
29
- config.future_release = Ohai::VERSION
30
- config.max_issues = 0
31
- config.add_issues_wo_labels = false
32
- config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature".split(",")
33
- config.bug_labels = "bug,Bug,Improvement,Upstream Bug".split(",")
34
- config.exclude_labels = "duplicate,question,invalid,wontfix,no_changelog,Exclude From Changelog,Question,Discussion".split(",")
35
- end
data/lib/ohai/config.rb CHANGED
@@ -102,6 +102,7 @@ module Ohai
102
102
  default :log_location, STDERR
103
103
  default :plugin, Ohai::PluginConfig.new { |h, k| h[k] = Ohai::PluginConfig.new }
104
104
  default :plugin_path, Ohai::Config.default_plugin_path
105
+ default :critical_plugins, []
105
106
  end
106
107
 
107
108
  class << self
@@ -85,10 +85,12 @@ module Ohai
85
85
  include Ohai::Util::FileHelper
86
86
 
87
87
  attr_reader :data
88
+ attr_reader :failed
88
89
 
89
90
  def initialize(data)
90
91
  @data = data
91
92
  @has_run = false
93
+ @failed = false
92
94
  end
93
95
 
94
96
  def run
@@ -183,8 +185,10 @@ module Ohai
183
185
  begin
184
186
  self.run
185
187
  rescue Ohai::Exceptions::Error => e
188
+ @failed = true
186
189
  raise e
187
190
  rescue => e
191
+ @failed = true
188
192
  Ohai::Log.debug("Plugin #{self.name} threw #{e.inspect}")
189
193
  e.backtrace.each { |line| Ohai::Log.debug( line ) }
190
194
  end
@@ -29,5 +29,6 @@ module Ohai
29
29
  class DependencyNotFound < Error; end
30
30
  class AttributeSyntaxError < Error; end
31
31
  class PluginConfigError < Error; end
32
+ class CriticalPluginFailure < Error; end
32
33
  end
33
34
  end
@@ -103,7 +103,8 @@ Ohai.plugin(:Network) do
103
103
  cint = nil
104
104
 
105
105
  so.stdout.lines do |line|
106
- if line =~ /^([0-9a-zA-Z\.\:\-]+)\S/
106
+ # regex: http://rubular.com/r/Iag7JLVTVe
107
+ if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+) index (\d+)/
107
108
  cint = $1
108
109
  iface[cint] = Mash.new unless iface[cint]
109
110
  iface[cint][:mtu] = $2
data/lib/ohai/runner.rb CHANGED
@@ -22,11 +22,13 @@ require "ohai/dsl"
22
22
  module Ohai
23
23
  class Runner
24
24
 
25
+ attr_reader :failed_plugins
25
26
  # safe_run: set to true if this runner will run plugins in
26
27
  # safe-mode. default false.
27
28
  def initialize(controller, safe_run = false)
28
29
  @provides_map = controller.provides_map
29
30
  @safe_run = safe_run
31
+ @failed_plugins = []
30
32
  end
31
33
 
32
34
  # Runs plugins and any un-run dependencies.
@@ -82,6 +84,9 @@ module Ohai
82
84
 
83
85
  if dependency_providers.empty?
84
86
  @safe_run ? next_plugin.safe_run : next_plugin.run
87
+ if next_plugin.failed
88
+ @failed_plugins << next_plugin.name
89
+ end
85
90
  else
86
91
  visited << next_plugin << dependency_providers.first
87
92
  end
data/lib/ohai/system.rb CHANGED
@@ -42,6 +42,7 @@ module Ohai
42
42
  def initialize(config = {})
43
43
  @plugin_path = ""
44
44
  @config = config
45
+ @failed_plugins = []
45
46
  reset_system
46
47
  end
47
48
 
@@ -102,6 +103,11 @@ module Ohai
102
103
  Ohai::Log.error("Encountered error while running plugins: #{e.inspect}")
103
104
  raise
104
105
  end
106
+ critical_failed = Ohai::Config.ohai[:critical_plugins] & @runner.failed_plugins
107
+ unless critical_failed.empty?
108
+ msg = "The following Ohai plugins marked as critical failed: #{critical_failed}. Exiting."
109
+ raise Ohai::Exceptions::CriticalPluginFailure, msg
110
+ end
105
111
  end
106
112
 
107
113
  def have_v6_plugin?(name)
data/lib/ohai/version.rb CHANGED
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = "8.24.1"
21
+ VERSION = "8.25.0"
22
22
  end
@@ -69,9 +69,7 @@ lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
69
69
  eri0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 \
70
70
  index 2
71
71
  inet 172.17.128.208 netmask ffffff00 broadcast 172.17.128.255
72
- ip6.tun0: flags=10008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4> \
73
- mtu 1460
74
- index 3
72
+ ip6.tun0: flags=10008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4> mtu 1460 index 3
75
73
  inet6 tunnel src fe80::1 tunnel dst fe80::2
76
74
  tunnel security settings --> use 'ipsecconf -ln -i ip.tun1'
77
75
  tunnel hop limit 60 tunnel encapsulation limit 4
@@ -80,8 +78,7 @@ qfe1: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 3
80
78
  usesrc vni0
81
79
  inet6 fe80::203:baff:fe17:4be0/10
82
80
  ether 0:3:ba:17:4b:e0
83
- vni0: flags=2002210041<UP,RUNNING,NOXMIT,NONUD,IPv6,VIRTUAL> mtu 0
84
- index 5
81
+ vni0: flags=2002210041<UP,RUNNING,NOXMIT,NONUD,IPv6,VIRTUAL> mtu 1460 index 5
85
82
  srcof qfe1
86
83
  inet6 fe80::203:baff:fe17:4444/128
87
84
  ENDIFCONFIG
@@ -176,7 +173,7 @@ ROUTE_GET
176
173
  end
177
174
 
178
175
  it "finds the default interface for a solaris 11 zone" do
179
- expect(@plugin[:network][:default_interface]).to eq("net1")
176
+ expect(@plugin[:network][:default_interface]).to eq("net1:1")
180
177
  end
181
178
  end
182
179
 
@@ -52,6 +52,7 @@ describe "Ohai::System" do
52
52
  config = {
53
53
  disabled_plugins: [ :Foo, :Baz ],
54
54
  directory: "/some/extra/plugins",
55
+ critical_plugins: [ :Foo, :Bar ],
55
56
  }
56
57
  allow(Ohai::Config).to receive(:merge_deprecated_config)
57
58
  expect(Ohai.config).to receive(:merge!).with(config).and_call_original
@@ -337,6 +338,15 @@ Ohai.plugin(:Park) do
337
338
  park("plants")
338
339
  end
339
340
  end
341
+ EOF
342
+
343
+ with_plugin("fails.rb", <<EOF)
344
+ Ohai.plugin(:Fails) do
345
+ provides 'fails'
346
+ collect_data(:default) do
347
+ fail 'thing'
348
+ end
349
+ end
340
350
  EOF
341
351
 
342
352
  it "should collect data from all the plugins" do
@@ -371,6 +381,21 @@ EOF
371
381
  expect(ohai.data[:park]).to eq("plants")
372
382
  end
373
383
  end
384
+
385
+ describe "when using :critical_plugins" do
386
+ before do
387
+ Ohai.config[:critical_plugins] = [ :Fails ]
388
+ end
389
+ after do
390
+ Ohai.config[:critical_plugins] = []
391
+ end
392
+
393
+ it "should fail when critical plugins fail" do
394
+ Ohai.config[:plugin_path] = [ path_to(".") ]
395
+ expect { ohai.all_plugins }.to raise_error(Ohai::Exceptions::CriticalPluginFailure)
396
+ end
397
+
398
+ end
374
399
  end
375
400
 
376
401
  when_plugins_directory "contains v6 & v7 plugins in different directories" do
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: 8.24.1
4
+ version: 8.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-21 00:00:00.000000000 Z
11
+ date: 2017-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -546,7 +546,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
546
546
  version: '0'
547
547
  requirements: []
548
548
  rubyforge_project:
549
- rubygems_version: 2.6.11
549
+ rubygems_version: 2.6.13
550
550
  signing_key:
551
551
  specification_version: 4
552
552
  summary: Ohai profiles your system and emits JSON