summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorClaire McQuin <claire@opscode.com>2013-09-11 11:34:01 -0700
committerClaire McQuin <claire@opscode.com>2013-09-11 11:34:01 -0700
commit1864fe0dd017a2a590ae1678b7b48adafbce780d (patch)
treeb75c8bdcc136c8901c76a13e4cbcfba7c4234426 /lib
parent7d997db6fade0ec471929cd2fa02bf192b8728d3 (diff)
parent865a5b885e91f5fb6a42cad5f78202863cfd6442 (diff)
downloadohai-1864fe0dd017a2a590ae1678b7b48adafbce780d.tar.gz
Merge pull request #196 from opscode/OC-9364
Run v6 plugins that require v7 plugins
Diffstat (limited to 'lib')
-rw-r--r--lib/ohai/system.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb
index 3e73f0eb..13279c12 100644
--- a/lib/ohai/system.rb
+++ b/lib/ohai/system.rb
@@ -42,6 +42,9 @@ module Ohai
@hints = Hash.new
@v6_dependency_solver = Hash.new
@plugin_path = ""
+
+ @loader = Ohai::Loader.new(self)
+ @runner = Ohai::Runner.new(self, true)
end
def [](key)
@@ -49,8 +52,6 @@ module Ohai
end
def load_plugins
- loader = Ohai::Loader.new(self)
-
Ohai::Config[:plugin_path].each do |path|
[
Dir[File.join(path, '*')],
@@ -61,7 +62,7 @@ module Ohai
if md
plugin_name = md[1].gsub(File::SEPARATOR, "::")
unless @v6_dependency_solver.has_key?(plugin_name)
- plugin = loader.load_plugin(file)
+ plugin = @loader.load_plugin(file)
@v6_dependency_solver[plugin_name] = plugin unless plugin.nil?
else
Ohai::Log.debug("Already loaded plugin at #{file}")
@@ -73,8 +74,6 @@ module Ohai
end
def run_plugins(safe = false, force = false)
- runner = Ohai::Runner.new(self, safe)
-
# collect and run version 6 plugins
v6plugins = []
@v6_dependency_solver.each { |plugin_name, plugin| v6plugins << plugin if plugin.version.eql?(:version6) }
@@ -87,7 +86,7 @@ module Ohai
# collect and run version 7 plugins
plugins = collect_providers(@attributes)
begin
- plugins.each { |plugin| runner.run_plugin(plugin, force) }
+ plugins.each { |plugin| @runner.run_plugin(plugin, force) }
rescue DependencyCycleError, NoAttributeError => e
Ohai::Log.error("Encountered error while running plugins: #{e.inspect}")
raise
@@ -157,10 +156,13 @@ module Ohai
if plugin = @v6_dependency_solver[plugin_name] or plugin = plugin_for(plugin_name)
begin
- plugin.safe_run
+ plugin.version.eql?(:version7) ? @runner.run_plugin(plugin, force) : plugin.safe_run
true
rescue SystemExit, Interrupt
raise
+ rescue DependencyCycleError, NoAttributeError => e
+ Ohai::Log.error("Encountered error while running plugins: #{e.inspect}")
+ raise
rescue Exception,Errno::ENOENT => e
Ohai::Log.debug("Plugin #{plugin_name} threw exception #{e.inspect} #{e.backtrace.join("\n")}")
end
@@ -173,11 +175,10 @@ module Ohai
filename = "#{plugin_name.gsub("::", File::SEPARATOR)}.rb"
plugin = nil
- loader = Ohai::Loader.new(self)
Ohai::Config[:plugin_path].each do |path|
check_path = File.expand_path(File.join(path, filename))
if File.exist?(check_path)
- plugin = loader.load_plugin(check_path)
+ plugin = @loader.load_plugin(check_path)
@v6_dependency_solver[plugin_name] = plugin
break
else