diff options
author | danielsdeleo <dan@opscode.com> | 2014-01-06 16:43:11 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2014-01-09 13:35:28 -0800 |
commit | 20389f1ca130fbde8c6e6be70803a443a4bead54 (patch) | |
tree | 15f028b32c7c979c49239d8ebdf2fd9762e4cf89 | |
parent | 90988200ccb18d8e68e5467777bcf5112eb65f03 (diff) | |
download | ohai-20389f1ca130fbde8c6e6be70803a443a4bead54.tar.gz |
Update refresh plugin logic for 7.0 architecture
-rw-r--r-- | lib/ohai/dsl/plugin.rb | 4 | ||||
-rw-r--r-- | lib/ohai/system.rb | 37 |
2 files changed, 17 insertions, 24 deletions
diff --git a/lib/ohai/dsl/plugin.rb b/lib/ohai/dsl/plugin.rb index 177c6455..86295676 100644 --- a/lib/ohai/dsl/plugin.rb +++ b/lib/ohai/dsl/plugin.rb @@ -98,6 +98,10 @@ module Ohai @has_run end + def reset! + @has_run = false + end + def [](key) @data[key] end diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb index 476586e9..0c3d7d76 100644 --- a/lib/ohai/system.rb +++ b/lib/ohai/system.rb @@ -127,32 +127,21 @@ module Ohai end end - # TODO: fix for running w/new internals - # add updated function to v7? - def refresh_plugins(path = '/') + # Re-runs plugins that provide the attributes specified by + # +attribute_filter+. If +attribute_filter+ is not given, re-runs all + # plugins. + # + # Note that dependencies will not be re-run, so you must specify all of the + # attributes you want refreshed in the +attribute_filter+ + # + # This method takes a naive approach to v6 plugins: it simply re-runs all + # of them whenever called. + def refresh_plugins(attribute_filter=nil) Ohai::Hints.refresh_hints() - - parts = path.split('/') - if parts.length == 0 - h = @metadata - else - parts.shift if parts[0].length == 0 - h = @metadata - parts.each do |part| - break unless h.has_key?(part) - h = h[part] - end - end - - refreshments = collect_plugins(h) - Ohai::Log.debug("Refreshing plugins: #{refreshments.join(", ")}") - - refreshments.each do |r| - @seen_plugins.delete(r) if @seen_plugins.has_key?(r) - end - refreshments.each do |r| - require_plugin(r) unless @seen_plugins.has_key?(r) + @provides_map.all_plugins(Array(attribute_filter)).each do |plugin| + plugin.reset! end + run_plugins(true, false, Array(attribute_filter)) end # |