Module MCollective::PluginManager
In: lib/mcollective/pluginmanager.rb

A simple plugin manager, it stores one plugin each of a specific type the idea is that we can only have one security provider, one connector etc.

Methods

<<   []   clear   create_instance   delete   find   find_and_load   grep   include?   loadclass   pluginlist  

Public Class methods

Adds a plugin to the list of plugins, we expect a hash like:

   {:type => "base",
    :class => foo.new}

or like:

   {:type => "base",
    :class => "Foo::Bar"}

In the event that we already have a class with the given type an exception will be raised.

If the :class passed is a String then we will delay instantiation till the first time someone asks for the plugin, this is because most likely the registration gets done by inherited() hooks, at which point the plugin class is not final.

If we were to do a .new here the Class initialize method would get called and not the plugins, we there for only initialize the classes when they get requested via []

By default all plugin instances are cached and returned later so there‘s always a single instance. You can pass :single_instance => false when calling this to instruct it to always return a new instance when a copy is requested. This only works with sending a String for :class.

Gets a plugin by type

deletes all registered plugins

use eval to create an instance of a class

Removes a plugim the list

Finds plugins in all configured libdirs

  find("agent")

will return an array of just agent names, for example:

  ["puppetd", "package"]

Can also be used to find files of other extensions:

  find("agent", "ddl")

Will return the same list but only of files with extension .ddl in the agent subdirectory

Finds and loads from disk all plugins from all libdirs that match certain criteria.

   find_and_load("pluginpackager")

Will find all .rb files in the libdir/mcollective/pluginpackager/ directory in all libdirs and load them from disk.

You can influence what plugins get loaded using a block notation:

   find_and_load("pluginpackager") do |plugin|
      plugin.match(/puppet/)
   end

This will load only plugins matching /puppet/

Grep‘s over the plugin list and returns the list found

Finds out if we have a plugin with the given name

Loads a class from file by doing some simple search/replace on class names and then doing a require.

Provides a list of plugins we know about

[Validate]