lib/ohai/system.rb
#
# Below APIs are from V6.
# Make sure that you are not breaking backwards compatibility
# if you are changing any of the APIs below.
#
Below APIs are from V6.
Make sure that you are not breaking backwards compatibility
if you are changing any of the APIs below.
Below APIs are from V6 . Make sure that you are not breaking backwards compatibility if you are changing any of the APIs below .
def require_plugin(plugin_ref, force=false)
      plugins = [ ]
      if @v6_dependency_solver.has_key? pathify_v6_plugin(plugin_ref)
        plugins << @v6_dependency_solver[pathify_v6_plugin(plugin_ref)]
      else
        attribute = plugin_ref.gsub("::", "/")
        begin
          plugins = @provides_map.find_providers_for([attribute])
        rescue Ohai::Exceptions::AttributeNotFound
          Ohai::Log.debug("Can not find any v7 plugin that provides #{attribute}")
          plugins = [ ]
        end
      end
      if plugins.empty?
        raise Ohai::Exceptions::DependencyNotFound, "Can not find a plugin for dependency #{plugin_ref}"
      else
        plugins.each do |plugin|
          begin
            @runner.run_plugin(plugin)
          rescue SystemExit, Interrupt
            raise
          rescue Ohai::Exceptions::DependencyCycle, Ohai::Exceptions::AttributeNotFound => 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
        end
      end
    end
def require_plugin ( plugin_ref , force = false ) plugins = [ ] if @v6_dependency_solver . has_key? pathify_v6_plugin ( plugin_ref ) plugins << @v6_dependency_solver [ pathify_v6_plugin ( plugin_ref ) ] else attribute = plugin_ref . gsub ( "::" , "/" ) begin plugins = @provides_map . find_providers_for ( [ attribute ] ) rescue Ohai :: Exceptions :: AttributeNotFound Ohai :: Log . debug ( "Can not find any v7 plugin that provides #{attribute}" ) plugins = [ ] end end if plugins . empty? raise Ohai :: Exceptions :: DependencyNotFound , "Can not find a plugin for dependency #{plugin_ref}" else plugins . each do | plugin | begin @runner . run_plugin ( plugin ) rescue SystemExit , Interrupt raise rescue Ohai :: Exceptions :: DependencyCycle , Ohai :: Exceptions :: AttributeNotFound => 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 end end end
Below APIs are from V6.
Below APIs are from V6 .
# This method is only callable by version 6 plugins. # First we check if there exists a v6 plugin that fulfills the dependency. # Note that: partial_path looks like Plugin::Name # keys for @v6_dependency_solver are in form 'plugin/name.rb' # While looking up V7 plugins we need to convert the plugin_ref to an attribute.
plugin_ref
force