Update version according to OSCI-883
[packages/precise/mcollective.git] / doc / MCollective / Agents.html
diff --git a/doc/MCollective/Agents.html b/doc/MCollective/Agents.html
new file mode 100644 (file)
index 0000000..92e274d
--- /dev/null
@@ -0,0 +1,824 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+       <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+
+       <title>Class: MCollective::Agents</title>
+
+       <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
+
+       <script src="../js/jquery.js" type="text/javascript"
+               charset="utf-8"></script>
+       <script src="../js/thickbox-compressed.js" type="text/javascript"
+               charset="utf-8"></script>
+       <script src="../js/quicksearch.js" type="text/javascript"
+               charset="utf-8"></script>
+       <script src="../js/darkfish.js" type="text/javascript"
+               charset="utf-8"></script>
+
+</head>
+<body class="class">
+
+       <div id="metadata">
+               <div id="file-metadata">
+                       <div id="file-list-section" class="section">
+                               <h3 class="section-header">In Files</h3>
+                               <div class="section-body">
+                                       <ul>
+                                       
+                                               <li><a href="../lib/mcollective/agents_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
+                                                       class="thickbox" title="lib/mcollective/agents.rb">lib/mcollective/agents.rb</a></li>
+                                       
+                                       </ul>
+                               </div>
+                       </div>
+
+                       
+               </div>
+
+               <div id="class-metadata">
+
+                       <!-- Parent Class -->
+                       
+                       <div id="parent-class-section" class="section">
+                               <h3 class="section-header">Parent</h3>
+                               
+                               <p class="link"><a href="../Object.html">Object</a></p>
+                               
+                       </div>
+                       
+
+                       <!-- Namespace Contents -->
+                       
+
+                       <!-- Method Quickref -->
+                       
+                       <div id="method-list-section" class="section">
+                               <h3 class="section-header">Methods</h3>
+                               <ul class="link-list">
+                                       
+                                       <li><a href="#M000112">::agentlist</a></li>
+                                       
+                                       <li><a href="#M000101">::new</a></li>
+                                       
+                                       <li><a href="#M000106">#activate_agent?</a></li>
+                                       
+                                       <li><a href="#M000105">#class_for_agent</a></li>
+                                       
+                                       <li><a href="#M000102">#clear!</a></li>
+                                       
+                                       <li><a href="#M000109">#dispatch</a></li>
+                                       
+                                       <li><a href="#M000107">#findagentfile</a></li>
+                                       
+                                       <li><a href="#M000108">#include?</a></li>
+                                       
+                                       <li><a href="#M000104">#loadagent</a></li>
+                                       
+                                       <li><a href="#M000103">#loadagents</a></li>
+                                       
+                               </ul>
+                       </div>
+                       
+
+                       <!-- Included Modules -->
+                       
+               </div>
+
+               <div id="project-metadata">
+                       
+                       
+                       <div id="fileindex-section" class="section project-section">
+                               <h3 class="section-header">Files</h3>
+                               <ul>
+                               
+                                       <li class="file"><a href="../COPYING.html">COPYING</a></li>
+                               
+                                       <li class="file"><a href="../Gemfile.html">Gemfile</a></li>
+                               
+                                       <li class="file"><a href="../README.html">README</a></li>
+                               
+                                       <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
+                               
+                                       <li class="file"><a href="../etc/client_cfg_dist.html">client.cfg.dist</a></li>
+                               
+                                       <li class="file"><a href="../etc/data-help_erb.html">data-help.erb</a></li>
+                               
+                                       <li class="file"><a href="../etc/discovery-help_erb.html">discovery-help.erb</a></li>
+                               
+                                       <li class="file"><a href="../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
+                               
+                                       <li class="file"><a href="../etc/metadata-help_erb.html">metadata-help.erb</a></li>
+                               
+                                       <li class="file"><a href="../etc/msg-help_erb.html">msg-help.erb</a></li>
+                               
+                                       <li class="file"><a href="../etc/rpc-help_erb.html">rpc-help.erb</a></li>
+                               
+                                       <li class="file"><a href="../etc/server_cfg_dist.html">server.cfg.dist</a></li>
+                               
+                                       <li class="file"><a href="../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
+                               
+                                       <li class="file"><a href="../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
+                               
+                                       <li class="file"><a href="../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
+                               
+                                       <li class="file"><a href="../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
+                               
+                                       <li class="file"><a href="../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
+                               
+                                       <li class="file"><a href="../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
+                               
+                                       <li class="file"><a href="../lib/mcollective/locales/en_yml.html">en.yml</a></li>
+                               
+                                       <li class="file"><a href="../mcollective_init.html">mcollective.init</a></li>
+                               
+                               </ul>
+                       </div>
+                       
+
+                       <div id="classindex-section" class="section project-section">
+                               <h3 class="section-header">Class Index
+                                       <span class="search-toggle"><img src="../images/find.png"
+                                               height="16" width="16" alt="[+]"
+                                               title="show/hide quicksearch" /></span></h3>
+                               <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
+                               <fieldset>
+                                       <legend>Quicksearch</legend>
+                                       <input type="text" name="quicksearch" value=""
+                                               class="quicksearch-field" />
+                               </fieldset>
+                               </form>
+
+                               <ul class="link-list">
+                               
+                                       <li><a href="../MCollective.html">MCollective</a></li>
+                               
+                                       <li><a href="../MCollective/Agent.html">MCollective::Agent</a></li>
+                               
+                                       <li><a href="../MCollective/Agents.html">MCollective::Agents</a></li>
+                               
+                                       <li><a href="../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
+                               
+                                       <li><a href="../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
+                               
+                                       <li><a href="../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
+                               
+                                       <li><a href="../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
+                               
+                                       <li><a href="../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
+                               
+                                       <li><a href="../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
+                               
+                                       <li><a href="../MCollective/Application.html">MCollective::Application</a></li>
+                               
+                                       <li><a href="../MCollective/Applications.html">MCollective::Applications</a></li>
+                               
+                                       <li><a href="../MCollective/Cache.html">MCollective::Cache</a></li>
+                               
+                                       <li><a href="../MCollective/Client.html">MCollective::Client</a></li>
+                               
+                                       <li><a href="../MCollective/CodedError.html">MCollective::CodedError</a></li>
+                               
+                                       <li><a href="../MCollective/Config.html">MCollective::Config</a></li>
+                               
+                                       <li><a href="../MCollective/Connector.html">MCollective::Connector</a></li>
+                               
+                                       <li><a href="../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
+                               
+                                       <li><a href="../MCollective/DDL.html">MCollective::DDL</a></li>
+                               
+                                       <li><a href="../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
+                               
+                                       <li><a href="../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
+                               
+                                       <li><a href="../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
+                               
+                                       <li><a href="../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
+                               
+                                       <li><a href="../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
+                               
+                                       <li><a href="../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
+                               
+                                       <li><a href="../MCollective/Data.html">MCollective::Data</a></li>
+                               
+                                       <li><a href="../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
+                               
+                                       <li><a href="../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
+                               
+                                       <li><a href="../MCollective/Discovery.html">MCollective::Discovery</a></li>
+                               
+                                       <li><a href="../MCollective/Facts.html">MCollective::Facts</a></li>
+                               
+                                       <li><a href="../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
+                               
+                                       <li><a href="../MCollective/Generators.html">MCollective::Generators</a></li>
+                               
+                                       <li><a href="../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
+                               
+                                       <li><a href="../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
+                               
+                                       <li><a href="../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
+                               
+                                       <li><a href="../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
+                               
+                                       <li><a href="../MCollective/Log.html">MCollective::Log</a></li>
+                               
+                                       <li><a href="../MCollective/Logger.html">MCollective::Logger</a></li>
+                               
+                                       <li><a href="../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
+                               
+                                       <li><a href="../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
+                               
+                                       <li><a href="../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
+                               
+                                       <li><a href="../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
+                               
+                                       <li><a href="../MCollective/Matcher.html">MCollective::Matcher</a></li>
+                               
+                                       <li><a href="../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
+                               
+                                       <li><a href="../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
+                               
+                                       <li><a href="../MCollective/Message.html">MCollective::Message</a></li>
+                               
+                                       <li><a href="../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
+                               
+                                       <li><a href="../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
+                               
+                                       <li><a href="../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
+                               
+                                       <li><a href="../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
+                               
+                                       <li><a href="../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
+                               
+                                       <li><a href="../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
+                               
+                                       <li><a href="../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
+                               
+                                       <li><a href="../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
+                               
+                                       <li><a href="../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
+                               
+                                       <li><a href="../MCollective/RPC.html">MCollective::RPC</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
+                               
+                                       <li><a href="../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
+                               
+                                       <li><a href="../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
+                               
+                                       <li><a href="../MCollective/RPCError.html">MCollective::RPCError</a></li>
+                               
+                                       <li><a href="../MCollective/Registration.html">MCollective::Registration</a></li>
+                               
+                                       <li><a href="../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
+                               
+                                       <li><a href="../MCollective/Runner.html">MCollective::Runner</a></li>
+                               
+                                       <li><a href="../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
+                               
+                                       <li><a href="../MCollective/SSL.html">MCollective::SSL</a></li>
+                               
+                                       <li><a href="../MCollective/Security.html">MCollective::Security</a></li>
+                               
+                                       <li><a href="../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
+                               
+                                       <li><a href="../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
+                               
+                                       <li><a href="../MCollective/Shell.html">MCollective::Shell</a></li>
+                               
+                                       <li><a href="../MCollective/Translatable.html">MCollective::Translatable</a></li>
+                               
+                                       <li><a href="../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
+                               
+                                       <li><a href="../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
+                               
+                                       <li><a href="../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
+                               
+                                       <li><a href="../MCollective/Util.html">MCollective::Util</a></li>
+                               
+                                       <li><a href="../MCollective/Validator.html">MCollective::Validator</a></li>
+                               
+                                       <li><a href="../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
+                               
+                                       <li><a href="../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
+                               
+                                       <li><a href="../Array.html">Array</a></li>
+                               
+                                       <li><a href="../Dir.html">Dir</a></li>
+                               
+                                       <li><a href="../Object.html">Object</a></li>
+                               
+                                       <li><a href="../String.html">String</a></li>
+                               
+                                       <li><a href="../Symbol.html">Symbol</a></li>
+                               
+                               </ul>
+                               <div id="no-class-search-results" style="display: none;">No matching classes.</div>
+                       </div>
+
+                       
+               </div>
+       </div>
+
+       <div id="documentation">
+               <h1 class="class">MCollective::Agents</h1>
+
+               <div id="description">
+                       <p>
+A collection of agents, loads them, reloads them and dispatches messages to
+them. It uses the <a href="PluginManager.html">PluginManager</a> to store,
+load and manage instances of plugins.
+</p>
+
+               </div>
+
+               <!-- Constants -->
+               
+
+               <!-- Attributes -->
+               
+
+               <!-- Methods -->
+               
+               <div id="public-class-method-details" class="method-section section">
+                       <h3 class="section-header">Public Class Methods</h3>
+
+               
+                       <div id="agentlist-method" class="method-detail ">
+                               <a name="M000112"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">agentlist</span><span
+                                               class="method-args">()</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Get a list of agents that we have
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="agentlist-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 145</span>
+145:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">agentlist</span>
+146:       <span class="ruby-ivar">@@agents</span>.<span class="ruby-identifier">keys</span>
+147:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="new-method" class="method-detail ">
+                               <a name="M000101"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">new</span><span
+                                               class="method-args">(agents = {})</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p class="missing-docs">(Not documented)</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="new-source">
+<pre>
+    <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 5</span>
+ 5:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">agents</span> = {})
+ 6:       <span class="ruby-ivar">@config</span> = <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>
+ 7:       <span class="ruby-identifier">raise</span> (<span class="ruby-value str">&quot;Configuration has not been loaded, can't load agents&quot;</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">configured</span>
+ 8: 
+ 9:       <span class="ruby-ivar">@@agents</span> = <span class="ruby-identifier">agents</span>
+10: 
+11:       <span class="ruby-identifier">loadagents</span>
+12:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+               </div>
+       
+               <div id="public-instance-method-details" class="method-section section">
+                       <h3 class="section-header">Public Instance Methods</h3>
+
+               
+                       <div id="activate-agent--method" class="method-detail ">
+                               <a name="M000106"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">activate_agent?</span><span
+                                               class="method-args">(agent)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Checks if a plugin should be activated by calling activate? on it if it
+responds to that method else always activate it
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="activate-agent--source">
+<pre>
+    <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 85</span>
+85:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">activate_agent?</span>(<span class="ruby-identifier">agent</span>)
+86:       <span class="ruby-identifier">klass</span> = <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-value str">&quot;MCollective&quot;</span>).<span class="ruby-identifier">const_get</span>(<span class="ruby-value str">&quot;Agent&quot;</span>).<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">agent</span>.<span class="ruby-identifier">capitalize</span>)
+87: 
+88:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">&quot;activate?&quot;</span>)
+89:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">activate?</span>
+90:       <span class="ruby-keyword kw">else</span>
+91:         <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;#{klass} does not have an activate? method, activating as default&quot;</span>)
+92:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
+93:       <span class="ruby-keyword kw">end</span>
+94:     <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+95:       <span class="ruby-constant">Log</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-node">&quot;Agent activation check for #{agent} failed: #{e.class}: #{e}&quot;</span>)
+96:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
+97:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="class-for-agent-method" class="method-detail ">
+                               <a name="M000105"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">class_for_agent</span><span
+                                               class="method-args">(agent)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Builds a class name string given a <a href="Agent.html">Agent</a> name
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="class-for-agent-source">
+<pre>
+    <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 78</span>
+78:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">class_for_agent</span>(<span class="ruby-identifier">agent</span>)
+79:       <span class="ruby-node">&quot;MCollective::Agent::#{agent.capitalize}&quot;</span>
+80:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="clear--method" class="method-detail ">
+                               <a name="M000102"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">clear!</span><span
+                                               class="method-args">()</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Deletes all agents
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="clear--source">
+<pre>
+    <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 15</span>
+15:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear!</span>
+16:       <span class="ruby-ivar">@@agents</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">agent</span><span class="ruby-operator">|</span>
+17:         <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">delete</span> <span class="ruby-node">&quot;#{agent}_agent&quot;</span>
+18:         <span class="ruby-constant">Util</span>.<span class="ruby-identifier">unsubscribe</span>(<span class="ruby-constant">Util</span>.<span class="ruby-identifier">make_subscriptions</span>(<span class="ruby-identifier">agent</span>, <span class="ruby-identifier">:broadcast</span>))
+19:       <span class="ruby-keyword kw">end</span>
+20: 
+21:       <span class="ruby-ivar">@@agents</span> = {}
+22:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="dispatch-method" class="method-detail ">
+                               <a name="M000109"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">dispatch</span><span
+                                               class="method-args">(request, connection)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Dispatches a message to an agent, accepts a block that will get run if
+there are any replies to process from the agent
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="dispatch-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 118</span>
+118:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dispatch</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">connection</span>)
+119:       <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Dispatching a message to agent #{request.agent}&quot;</span>)
+120: 
+121:       <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
+122:         <span class="ruby-keyword kw">begin</span>
+123:           <span class="ruby-identifier">agent</span> = <span class="ruby-constant">PluginManager</span>[<span class="ruby-node">&quot;#{request.agent}_agent&quot;</span>]
+124: 
+125:           <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-identifier">timeout</span>(<span class="ruby-identifier">agent</span>.<span class="ruby-identifier">timeout</span>) <span class="ruby-keyword kw">do</span>
+126:             <span class="ruby-identifier">replies</span> = <span class="ruby-identifier">agent</span>.<span class="ruby-identifier">handlemsg</span>(<span class="ruby-identifier">request</span>.<span class="ruby-identifier">payload</span>, <span class="ruby-identifier">connection</span>)
+127: 
+128:             <span class="ruby-comment cmt"># Agents can decide if they wish to reply or not,</span>
+129:             <span class="ruby-comment cmt"># returning nil will mean nothing goes back to the</span>
+130:             <span class="ruby-comment cmt"># requestor</span>
+131:             <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">replies</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
+132:               <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">replies</span>)
+133:             <span class="ruby-keyword kw">end</span>
+134:           <span class="ruby-keyword kw">end</span>
+135:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+136:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-node">&quot;Timeout while handling message for #{request.agent}&quot;</span>)
+137:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+138:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;Execution of #{request.agent} failed: #{e}&quot;</span>)
+139:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n\t\t&quot;</span>))
+140:         <span class="ruby-keyword kw">end</span>
+141:       <span class="ruby-keyword kw">end</span>
+142:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="findagentfile-method" class="method-detail ">
+                               <a name="M000107"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">findagentfile</span><span
+                                               class="method-args">(agentname)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+searches the libdirs for agents
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="findagentfile-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 100</span>
+100:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">findagentfile</span>(<span class="ruby-identifier">agentname</span>)
+101:       <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">libdir</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">libdir</span><span class="ruby-operator">|</span>
+102:         <span class="ruby-identifier">agentfile</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>([<span class="ruby-identifier">libdir</span>, <span class="ruby-value str">&quot;mcollective&quot;</span>, <span class="ruby-value str">&quot;agent&quot;</span>, <span class="ruby-node">&quot;#{agentname}.rb&quot;</span>])
+103:         <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">agentfile</span>)
+104:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Found #{agentname} at #{agentfile}&quot;</span>)
+105:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">agentfile</span>
+106:         <span class="ruby-keyword kw">end</span>
+107:       <span class="ruby-keyword kw">end</span>
+108:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
+109:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="include--method" class="method-detail ">
+                               <a name="M000108"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">include?</span><span
+                                               class="method-args">(agentname)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Determines if we have an agent with a certain name
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="include--source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 112</span>
+112:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include?</span>(<span class="ruby-identifier">agentname</span>)
+113:       <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-node">&quot;#{agentname}_agent&quot;</span>)
+114:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="loadagent-method" class="method-detail ">
+                               <a name="M000104"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">loadagent</span><span
+                                               class="method-args">(agentname)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Loads a specified agent from disk if available
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="loadagent-source">
+<pre>
+    <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 42</span>
+42:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">loadagent</span>(<span class="ruby-identifier">agentname</span>)
+43:       <span class="ruby-identifier">agentfile</span> = <span class="ruby-identifier">findagentfile</span>(<span class="ruby-identifier">agentname</span>)
+44:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">agentfile</span>
+45:       <span class="ruby-identifier">classname</span> = <span class="ruby-identifier">class_for_agent</span>(<span class="ruby-identifier">agentname</span>)
+46: 
+47:       <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-node">&quot;#{agentname}_agent&quot;</span>)
+48: 
+49:       <span class="ruby-keyword kw">begin</span>
+50:         <span class="ruby-identifier">single_instance</span> = [<span class="ruby-value str">&quot;registration&quot;</span>, <span class="ruby-value str">&quot;discovery&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">agentname</span>)
+51: 
+52:         <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">loadclass</span>(<span class="ruby-identifier">classname</span>)
+53: 
+54:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">activate_agent?</span>(<span class="ruby-identifier">agentname</span>)
+55:           <span class="ruby-constant">PluginManager</span> <span class="ruby-operator">&lt;&lt;</span> {<span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{agentname}_agent&quot;</span>, <span class="ruby-identifier">:class</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">classname</span>, <span class="ruby-identifier">:single_instance</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">single_instance</span>}
+56: 
+57:           <span class="ruby-comment cmt"># Attempt to instantiate the agent once so any validation and hooks get run</span>
+58:           <span class="ruby-comment cmt"># this does a basic sanity check on the agent as a whole, if this fails it</span>
+59:           <span class="ruby-comment cmt"># will be removed from the plugin list</span>
+60:           <span class="ruby-constant">PluginManager</span>[<span class="ruby-node">&quot;#{agentname}_agent&quot;</span>]
+61: 
+62:           <span class="ruby-constant">Util</span>.<span class="ruby-identifier">subscribe</span>(<span class="ruby-constant">Util</span>.<span class="ruby-identifier">make_subscriptions</span>(<span class="ruby-identifier">agentname</span>, <span class="ruby-identifier">:broadcast</span>)) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@@agents</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">agentname</span>)
+63: 
+64:           <span class="ruby-ivar">@@agents</span>[<span class="ruby-identifier">agentname</span>] = {<span class="ruby-identifier">:file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">agentfile</span>}
+65:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
+66:         <span class="ruby-keyword kw">else</span>
+67:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Not activating agent #{agentname} due to agent policy in activate? method&quot;</span>)
+68:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
+69:         <span class="ruby-keyword kw">end</span>
+70:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+71:         <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;Loading agent #{agentname} failed: #{e}&quot;</span>)
+72:         <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-node">&quot;#{agentname}_agent&quot;</span>)
+73:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
+74:       <span class="ruby-keyword kw">end</span>
+75:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="loadagents-method" class="method-detail ">
+                               <a name="M000103"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">loadagents</span><span
+                                               class="method-args">()</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Loads all agents from disk
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="loadagents-source">
+<pre>
+    <span class="ruby-comment cmt"># File lib/mcollective/agents.rb, line 25</span>
+25:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">loadagents</span>
+26:       <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-value str">&quot;Reloading all agents from disk&quot;</span>)
+27: 
+28:       <span class="ruby-identifier">clear!</span>
+29: 
+30:       <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">libdir</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">libdir</span><span class="ruby-operator">|</span>
+31:         <span class="ruby-identifier">agentdir</span> = <span class="ruby-node">&quot;#{libdir}/mcollective/agent&quot;</span>
+32:         <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">agentdir</span>)
+33: 
+34:         <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">agentdir</span>).<span class="ruby-identifier">grep</span>(<span class="ruby-regexp re">/\.rb$/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">agent</span><span class="ruby-operator">|</span>
+35:           <span class="ruby-identifier">agentname</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">agent</span>, <span class="ruby-value str">&quot;.rb&quot;</span>)
+36:           <span class="ruby-identifier">loadagent</span>(<span class="ruby-identifier">agentname</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-node">&quot;#{agentname}_agent&quot;</span>)
+37:         <span class="ruby-keyword kw">end</span>
+38:       <span class="ruby-keyword kw">end</span>
+39:     <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+               </div>
+       
+
+       </div>
+
+
+       <div id="rdoc-debugging-section-dump" class="debugging-section">
+       
+               <p>Disabled; run with --debug to generate this.</p>
+       
+       </div>
+
+       <div id="validator-badges">
+               <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+               <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
+                       Rdoc Generator</a> 1.1.6</small>.</p>
+       </div>
+
+</body>
+</html>
+