Update version according to OSCI-883
[packages/precise/mcollective.git] / doc / MCollective / RPC / Agent.html
diff --git a/doc/MCollective/RPC/Agent.html b/doc/MCollective/RPC/Agent.html
new file mode 100644 (file)
index 0000000..77d1cd5
--- /dev/null
@@ -0,0 +1,1457 @@
+<?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::RPC::Agent</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/rpc/agent_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
+                                                       class="thickbox" title="lib/mcollective/rpc/agent.rb">lib/mcollective/rpc/agent.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="#M000411">::action</a></li>
+                                       
+                                       <li><a href="#M000405">::actions</a></li>
+                                       
+                                       <li><a href="#M000404">::activate?</a></li>
+                                       
+                                       <li><a href="#M000410">::activate_when</a></li>
+                                       
+                                       <li><a href="#M000412">::authorized_by</a></li>
+                                       
+                                       <li><a href="#M000407">::metadata</a></li>
+                                       
+                                       <li><a href="#M000393">::new</a></li>
+                                       
+                                       <li><a href="#M000418">#after_processing_hook</a></li>
+                                       
+                                       <li><a href="#M000419">#audit_request</a></li>
+                                       
+                                       <li><a href="#M000417">#before_processing_hook</a></li>
+                                       
+                                       <li><a href="#M000395">#handlemsg</a></li>
+                                       
+                                       <li><a href="#M000415">#implemented_by</a></li>
+                                       
+                                       <li><a href="#M000394">#load_ddl</a></li>
+                                       
+                                       <li><a href="#M000406">#run</a></li>
+                                       
+                                       <li><a href="#M000414">#shellescape</a></li>
+                                       
+                                       <li><a href="#M000416">#startup_hook</a></li>
+                                       
+                                       <li><a href="#M000413">#validate</a></li>
+                                       
+                               </ul>
+                       </div>
+                       
+
+                       <!-- Included Modules -->
+                       
+                       <div id="includes-section" class="section">
+                               <h3 class="section-header">Included Modules</h3>
+                               <ul class="link-list">
+                               
+                               
+                                       <li><a class="include" href="../Validator.html">MCollective::Validator</a></li>
+                               
+                               
+                               </ul>
+                       </div>
+                       
+               </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::RPC::Agent</h1>
+
+               <div id="description">
+                       <p>
+A wrapper around the traditional agent, it takes care of a lot of the
+tedious setup you would do for each agent allowing you to just create
+methods following a naming standard leaving the heavy lifting up to this
+clas.
+</p>
+<p>
+See <a
+href="http://marionette-collective.org/simplerpc/agents.html">marionette-collective.org/simplerpc/agents.html</a>
+</p>
+<p>
+It only really makes sense to use this with a Simple <a
+href="../RPC.html">RPC</a> client on the other end, basic usage would be:
+</p>
+<pre>
+   module MCollective
+     module Agent
+       class Helloworld&lt;RPC::Agent
+         action &quot;hello&quot; do
+           reply[:msg] = &quot;Hello #{request[:name]}&quot;
+         end
+
+         action &quot;foo&quot; do
+           implemented_by &quot;/some/script.sh&quot;
+         end
+       end
+     end
+   end
+</pre>
+<p>
+If you wish to implement the logic for an action using an external script
+use the <a href="Agent.html#M000415">implemented_by</a> method that will
+cause your script to be run with 2 arguments.
+</p>
+<p>
+The first argument is a file containing JSON with the request and the 2nd
+argument is where the script should save its output as a JSON hash.
+</p>
+<p>
+We also currently have the validation code in here, this will be moved to
+plugins soon.
+</p>
+
+               </div>
+
+               <!-- Constants -->
+               
+
+               <!-- Attributes -->
+               
+               <div id="attribute-method-details" class="method-section section">
+                       <h3 class="section-header">Attributes</h3>
+
+                       
+                       <div id="reply-attribute-method" class="method-detail">
+                               <a name="reply"></a>
+                               
+                               <a name="reply="></a>
+                               
+                               <div class="method-heading attribute-method-heading">
+                                       <span class="method-name">reply</span><span
+                                               class="attribute-access-type">[RW]</span>
+                               </div>
+
+                               <div class="method-description">
+                               
+                               <p class="missing-docs">(Not documented)</p>
+                               
+                               </div>
+                       </div>
+                       
+                       <div id="request-attribute-method" class="method-detail">
+                               <a name="request"></a>
+                               
+                               <a name="request="></a>
+                               
+                               <div class="method-heading attribute-method-heading">
+                                       <span class="method-name">request</span><span
+                                               class="attribute-access-type">[RW]</span>
+                               </div>
+
+                               <div class="method-description">
+                               
+                               <p class="missing-docs">(Not documented)</p>
+                               
+                               </div>
+                       </div>
+                       
+                       <div id="agent-name-attribute-method" class="method-detail">
+                               <a name="agent_name"></a>
+                               
+                               <a name="agent_name="></a>
+                               
+                               <div class="method-heading attribute-method-heading">
+                                       <span class="method-name">agent_name</span><span
+                                               class="attribute-access-type">[RW]</span>
+                               </div>
+
+                               <div class="method-description">
+                               
+                               <p class="missing-docs">(Not documented)</p>
+                               
+                               </div>
+                       </div>
+                       
+                       <div id="logger-attribute-method" class="method-detail">
+                               <a name="logger"></a>
+                               
+                               <div class="method-heading attribute-method-heading">
+                                       <span class="method-name">logger</span><span
+                                               class="attribute-access-type">[R]</span>
+                               </div>
+
+                               <div class="method-description">
+                               
+                               <p class="missing-docs">(Not documented)</p>
+                               
+                               </div>
+                       </div>
+                       
+                       <div id="config-attribute-method" class="method-detail">
+                               <a name="config"></a>
+                               
+                               <div class="method-heading attribute-method-heading">
+                                       <span class="method-name">config</span><span
+                                               class="attribute-access-type">[R]</span>
+                               </div>
+
+                               <div class="method-description">
+                               
+                               <p class="missing-docs">(Not documented)</p>
+                               
+                               </div>
+                       </div>
+                       
+                       <div id="timeout-attribute-method" class="method-detail">
+                               <a name="timeout"></a>
+                               
+                               <div class="method-heading attribute-method-heading">
+                                       <span class="method-name">timeout</span><span
+                                               class="attribute-access-type">[R]</span>
+                               </div>
+
+                               <div class="method-description">
+                               
+                               <p class="missing-docs">(Not documented)</p>
+                               
+                               </div>
+                       </div>
+                       
+                       <div id="ddl-attribute-method" class="method-detail">
+                               <a name="ddl"></a>
+                               
+                               <div class="method-heading attribute-method-heading">
+                                       <span class="method-name">ddl</span><span
+                                               class="attribute-access-type">[R]</span>
+                               </div>
+
+                               <div class="method-description">
+                               
+                               <p class="missing-docs">(Not documented)</p>
+                               
+                               </div>
+                       </div>
+                       
+                       <div id="meta-attribute-method" class="method-detail">
+                               <a name="meta"></a>
+                               
+                               <div class="method-heading attribute-method-heading">
+                                       <span class="method-name">meta</span><span
+                                               class="attribute-access-type">[R]</span>
+                               </div>
+
+                               <div class="method-description">
+                               
+                               <p class="missing-docs">(Not documented)</p>
+                               
+                               </div>
+                       </div>
+                       
+               </div>
+               
+
+               <!-- Methods -->
+               
+               <div id="public-class-method-details" class="method-section section">
+                       <h3 class="section-header">Public Class Methods</h3>
+
+               
+                       <div id="actions-method" class="method-detail ">
+                               <a name="M000405"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">actions</span><span
+                                               class="method-args">()</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Returns an array of actions this agent support
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="actions-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 157</span>
+157:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">actions</span>
+158:         <span class="ruby-identifier">public_instance_methods</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp re">/_action$/</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span>
+159:           <span class="ruby-identifier">$1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">method</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/(.+)_action$/</span>
+160:         <span class="ruby-keyword kw">end</span>
+161:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="activate--method" class="method-detail ">
+                               <a name="M000404"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">activate?</span><span
+                                               class="method-args">()</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+By default <a href="../RPC.html">RPC</a> <a
+href="../Agents.html">Agents</a> support a toggle in the configuration that
+can enable and disable them based on the agent name
+</p>
+<p>
+Example an agent called Foo can have:
+</p>
+<p>
+plugin.foo.activate_agent = false
+</p>
+<p>
+and this will prevent the agent from loading on this particular machine.
+</p>
+<p>
+<a href="../Agents.html">Agents</a> can use the <a
+href="Agent.html#M000410">activate_when</a> helper to override this for
+example:
+</p>
+<p>
+<a href="Agent.html#M000410">activate_when</a> do
+</p>
+<pre>
+   File.exist?(&quot;/usr/bin/puppet&quot;)
+</pre>
+<p>
+end
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="activate--source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 142</span>
+142:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">activate?</span>
+143:         <span class="ruby-identifier">agent_name</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;::&quot;</span>).<span class="ruby-identifier">last</span>.<span class="ruby-identifier">downcase</span>
+144: 
+145:         <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC37</span>, <span class="ruby-value str">&quot;Starting default activation checks for the '%{agent}' agent&quot;</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">agent_name</span>)
+146: 
+147:         <span class="ruby-identifier">should_activate</span> = <span class="ruby-constant">Util</span>.<span class="ruby-identifier">str_to_bool</span>(<span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">pluginconf</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-node">&quot;#{agent_name}.activate_agent&quot;</span>, <span class="ruby-keyword kw">true</span>))
+148: 
+149:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">should_activate</span>
+150:           <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC38</span>, <span class="ruby-value str">&quot;Found plugin configuration '%{agent}.activate_agent' with value '%{should_activate}'&quot;</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">agent_name</span>, <span class="ruby-identifier">:should_activate</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">should_activate</span>)
+151:         <span class="ruby-keyword kw">end</span>
+152: 
+153:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">should_activate</span>
+154:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="new-method" class="method-detail ">
+                               <a name="M000393"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">new</span><span
+                                               class="method-args">()</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/rpc/agent.rb, line 40</span>
+40:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
+41:         <span class="ruby-ivar">@agent_name</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;::&quot;</span>).<span class="ruby-identifier">last</span>.<span class="ruby-identifier">downcase</span>
+42: 
+43:         <span class="ruby-identifier">load_ddl</span>
+44: 
+45:         <span class="ruby-ivar">@logger</span> = <span class="ruby-constant">Log</span>.<span class="ruby-identifier">instance</span>
+46:         <span class="ruby-ivar">@config</span> = <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>
+47: 
+48:         <span class="ruby-comment cmt"># if we have a global authorization provider enable it</span>
+49:         <span class="ruby-comment cmt"># plugins can still override it per plugin</span>
+50:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">authorized_by</span>(<span class="ruby-ivar">@config</span>.<span class="ruby-identifier">rpcauthprovider</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">rpcauthorization</span>
+51: 
+52:         <span class="ruby-identifier">startup_hook</span>
+53:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+               </div>
+       
+               <div id="private-class-method-details" class="method-section section">
+                       <h3 class="section-header">Private Class Methods</h3>
+
+               
+                       <div id="action-method" class="method-detail ">
+                               <a name="M000411"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">action</span><span
+                                               class="method-args">(name, &block)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Creates a new action with the block passed and sets some defaults
+</p>
+<p>
+action &#8220;status&#8221; do
+</p>
+<pre>
+   # logic here to restart service
+</pre>
+<p>
+end
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="action-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 260</span>
+260:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">action</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
+261:         <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Need to pass a body for the action&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block_given?</span>
+262: 
+263:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">module_eval</span> { <span class="ruby-identifier">define_method</span>(<span class="ruby-node">&quot;#{name}_action&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) }
+264:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="activate-when-method" class="method-detail ">
+                               <a name="M000410"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">activate_when</span><span
+                                               class="method-args">(&block)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Creates the needed activate? class in a manner similar to the other helpers
+like action, <a href="Agent.html#M000412">authorized_by</a> etc
+</p>
+<p>
+<a href="Agent.html#M000410">activate_when</a> do
+</p>
+<pre>
+   File.exist?(&quot;/usr/bin/puppet&quot;)
+</pre>
+<p>
+end
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="activate-when-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 249</span>
+249:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">activate_when</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
+250:         (<span class="ruby-keyword kw">class</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">end</span>).<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword kw">do</span>
+251:           <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">&quot;activate?&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
+252:         <span class="ruby-keyword kw">end</span>
+253:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="authorized-by-method" class="method-detail ">
+                               <a name="M000412"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">authorized_by</span><span
+                                               class="method-args">(plugin)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Helper that creates a method on the class that will call your authorization
+plugin. If your plugin raises an exception that will abort the request
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="authorized-by-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 268</span>
+268:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">authorized_by</span>(<span class="ruby-identifier">plugin</span>)
+269:         <span class="ruby-identifier">plugin</span> = <span class="ruby-identifier">plugin</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">capitalize</span>
+270: 
+271:         <span class="ruby-comment cmt"># turns foo_bar into FooBar</span>
+272:         <span class="ruby-identifier">plugin</span> = <span class="ruby-identifier">plugin</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;_&quot;</span>).<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">capitalize</span>}.<span class="ruby-identifier">join</span>
+273:         <span class="ruby-identifier">pluginname</span> = <span class="ruby-node">&quot;MCollective::Util::#{plugin}&quot;</span>
+274: 
+275:         <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">loadclass</span>(<span class="ruby-identifier">pluginname</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">MCollective</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">plugin</span>)
+276: 
+277:         <span class="ruby-identifier">class_eval</span>(<span class="ruby-node">&quot;
+278:                       def authorization_hook(request)
+279:                    #{pluginname}.authorize(request)
+280:                       end
+281:                    &quot;</span>)
+282:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="metadata-method" class="method-detail ">
+                               <a name="M000407"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">metadata</span><span
+                                               class="method-args">(data)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Registers meta data for the introspection hash
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="metadata-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 237</span>
+237:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">metadata</span>(<span class="ruby-identifier">data</span>)
+238:         <span class="ruby-identifier">agent</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">caller</span>.<span class="ruby-identifier">first</span>).<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;:&quot;</span>).<span class="ruby-identifier">first</span>
+239: 
+240:         <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC34</span>, <span class="ruby-value str">&quot;setting meta data in agents have been deprecated, DDL files are now being used for this information. Please update the '%{agent}' agent&quot;</span>, <span class="ruby-identifier">:warn</span>,  <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">agent</span>)
+241:       <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="handlemsg-method" class="method-detail ">
+                               <a name="M000395"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">handlemsg</span><span
+                                               class="method-args">(msg, connection)</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="handlemsg-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 64</span>
+ 64:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handlemsg</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>)
+ 65:         <span class="ruby-ivar">@request</span> = <span class="ruby-constant">RPC</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-ivar">@ddl</span>)
+ 66:         <span class="ruby-ivar">@reply</span> = <span class="ruby-constant">RPC</span><span class="ruby-operator">::</span><span class="ruby-constant">Reply</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">action</span>, <span class="ruby-ivar">@ddl</span>)
+ 67: 
+ 68:         <span class="ruby-keyword kw">begin</span>
+ 69:           <span class="ruby-comment cmt"># Incoming requests need to be validated against the DDL thus reusing</span>
+ 70:           <span class="ruby-comment cmt"># all the work users put into creating DDLs and creating a consistent</span>
+ 71:           <span class="ruby-comment cmt"># quality of input validation everywhere with the a simple once off</span>
+ 72:           <span class="ruby-comment cmt"># investment of writing a DDL</span>
+ 73:           <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">validate!</span>
+ 74: 
+ 75:           <span class="ruby-comment cmt"># Calls the authorization plugin if any is defined</span>
+ 76:           <span class="ruby-comment cmt"># if this raises an exception we wil just skip processing this</span>
+ 77:           <span class="ruby-comment cmt"># message</span>
+ 78:           <span class="ruby-identifier">authorization_hook</span>(<span class="ruby-ivar">@request</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">&quot;authorization_hook&quot;</span>)
+ 79: 
+ 80:           <span class="ruby-comment cmt"># Audits the request, currently continues processing the message</span>
+ 81:           <span class="ruby-comment cmt"># we should make this a configurable so that an audit failure means</span>
+ 82:           <span class="ruby-comment cmt"># a message wont be processed by this node depending on config</span>
+ 83:           <span class="ruby-identifier">audit_request</span>(<span class="ruby-ivar">@request</span>, <span class="ruby-identifier">connection</span>)
+ 84: 
+ 85:           <span class="ruby-identifier">before_processing_hook</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>)
+ 86: 
+ 87:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;#{@request.action}_action&quot;</span>)
+ 88:             <span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{@request.action}_action&quot;</span>)
+ 89:           <span class="ruby-keyword kw">else</span>
+ 90:             <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC36</span>, <span class="ruby-value str">&quot;Unknown action '%{action}' for agent '%{agent}'&quot;</span>, <span class="ruby-identifier">:warn</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">action</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">agent</span>)
+ 91:             <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownRPCAction</span>, <span class="ruby-node">&quot;Unknown action '#{@request.action}' for agent '#{@request.agent}'&quot;</span>
+ 92:           <span class="ruby-keyword kw">end</span>
+ 93:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">RPCAborted</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+ 94:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">1</span>
+ 95: 
+ 96:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">UnknownRPCAction</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+ 97:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">2</span>
+ 98: 
+ 99:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">MissingRPCData</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+100:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">3</span>
+101: 
+102:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">InvalidRPCData</span>, <span class="ruby-constant">DDLValidationError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+103:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">4</span>
+104: 
+105:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">UnknownRPCError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+106:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-value str">&quot;%s#%s failed: %s: %s&quot;</span> <span class="ruby-operator">%</span> [<span class="ruby-ivar">@agent_name</span>, <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">action</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>])
+107:           <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&quot;</span>))
+108:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">5</span>
+109: 
+110:         <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>
+111:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-value str">&quot;%s#%s failed: %s: %s&quot;</span> <span class="ruby-operator">%</span> [<span class="ruby-ivar">@agent_name</span>, <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">action</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>])
+112:           <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&quot;</span>))
+113:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">5</span>
+114: 
+115:         <span class="ruby-keyword kw">end</span>
+116: 
+117:         <span class="ruby-identifier">after_processing_hook</span>
+118: 
+119:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">should_respond?</span>
+120:           <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">to_hash</span>
+121:         <span class="ruby-keyword kw">else</span>
+122:           <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC35</span>, <span class="ruby-value str">&quot;Client did not request a response, surpressing reply&quot;</span>, <span class="ruby-identifier">:debug</span>)
+123:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
+124:         <span class="ruby-keyword kw">end</span>
+125:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="load-ddl-method" class="method-detail ">
+                               <a name="M000394"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">load_ddl</span><span
+                                               class="method-args">()</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="load-ddl-source">
+<pre>
+    <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 55</span>
+55:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_ddl</span>
+56:         <span class="ruby-ivar">@ddl</span> = <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@agent_name</span>, <span class="ruby-identifier">:agent</span>)
+57:         <span class="ruby-ivar">@meta</span> = <span class="ruby-ivar">@ddl</span>.<span class="ruby-identifier">meta</span>
+58:         <span class="ruby-ivar">@timeout</span> = <span class="ruby-ivar">@meta</span>[<span class="ruby-identifier">:timeout</span>] <span class="ruby-operator">||</span> <span class="ruby-value">10</span>
+59: 
+60:       <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>
+61:         <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC24</span>, <span class="ruby-value str">&quot;Failed to load DDL for the '%{agent}' agent, DDLs are required: %{error_class}: %{error}&quot;</span>, <span class="ruby-identifier">:error</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@agent_name</span>, <span class="ruby-identifier">:error_class</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">:error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>)
+62:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+               </div>
+       
+               <div id="private-instance-method-details" class="method-section section">
+                       <h3 class="section-header">Private Instance Methods</h3>
+
+               
+                       <div id="after-processing-hook-method" class="method-detail ">
+                               <a name="M000418"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">after_processing_hook</span><span
+                                               class="method-args">()</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Called at the end of processing just before the response gets sent to the
+middleware.
+</p>
+<p>
+This gets run outside of the main exception handling block of the agent so
+you should handle any exceptions you could raise yourself. The reason it is
+outside of the block is so you&#8217;ll have access to even status codes
+set by the exception handlers. If you do raise an exception it will just be
+passed onto the runner and processing will fail.
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="after-processing-hook-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 356</span>
+356:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after_processing_hook</span>
+357:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="audit-request-method" class="method-detail ">
+                               <a name="M000419"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">audit_request</span><span
+                                               class="method-args">(msg, connection)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Gets called right after a request was received and calls audit plugins
+</p>
+<p>
+<a href="../Agents.html">Agents</a> can disable auditing by just overriding
+this method with a noop one this might be useful for agents that gets a lot
+of requests or simply if you do not care for the auditing in a specific
+agent.
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="audit-request-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 364</span>
+364:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">audit_request</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>)
+365:         <span class="ruby-constant">PluginManager</span>[<span class="ruby-value str">&quot;rpcaudit_plugin&quot;</span>].<span class="ruby-identifier">audit_request</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">rpcaudit</span>
+366:       <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>
+367:         <span class="ruby-identifier">logexception</span>(<span class="ruby-identifier">:PLMC39</span>, <span class="ruby-value str">&quot;Audit failed with an error, processing the request will continue.&quot;</span>, <span class="ruby-identifier">:warn</span>, <span class="ruby-identifier">e</span>)
+368:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="before-processing-hook-method" class="method-detail ">
+                               <a name="M000417"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">before_processing_hook</span><span
+                                               class="method-args">(msg, connection)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Called just after a message was received from the middleware before it gets
+passed to the handlers. @request and @reply will already be set, the msg
+passed is the message as received from the normal mcollective runner and
+the connection is the actual connector.
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="before-processing-hook-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 345</span>
+345:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before_processing_hook</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>)
+346:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="implemented-by-method" class="method-detail ">
+                               <a name="M000415"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">implemented_by</span><span
+                                               class="method-args">(command, type=:json)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+handles external actions
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="implemented-by-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 313</span>
+313:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">implemented_by</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">type</span>=<span class="ruby-identifier">:json</span>)
+314:         <span class="ruby-identifier">runner</span> = <span class="ruby-constant">ActionRunner</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">request</span>, <span class="ruby-identifier">type</span>)
+315: 
+316:         <span class="ruby-identifier">res</span> = <span class="ruby-identifier">runner</span>.<span class="ruby-identifier">run</span>
+317: 
+318:         <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail!</span> <span class="ruby-node">&quot;Did not receive data from #{command}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:data</span>)
+319:         <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail!</span> <span class="ruby-node">&quot;Reply data from #{command} is not a Hash&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>[<span class="ruby-identifier">:data</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
+320: 
+321:         <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">data</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">res</span>[<span class="ruby-identifier">:data</span>])
+322: 
+323:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>[<span class="ruby-identifier">:exitstatus</span>] <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
+324:           <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-node">&quot;Failed to run #{command}: #{res[:stderr]}&quot;</span>, <span class="ruby-identifier">res</span>[<span class="ruby-identifier">:exitstatus</span>]
+325:         <span class="ruby-keyword kw">end</span>
+326:       <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>
+327:         <span class="ruby-constant">Log</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-node">&quot;Unhandled #{e.class} exception during #{request.agent}##{request.action}: #{e}&quot;</span>)
+328:         <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail!</span> <span class="ruby-node">&quot;Unexpected failure calling #{command}: #{e.class}: #{e}&quot;</span>
+329:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="run-method" class="method-detail ">
+                               <a name="M000406"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">run</span><span
+                                               class="method-args">(command, options={})</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Runs a command via the MC::Shell wrapper, options are as per MC::Shell
+</p>
+<p>
+The simplest use is:
+</p>
+<pre>
+  out = &quot;&quot;
+  err = &quot;&quot;
+  status = run(&quot;echo 1&quot;, :stdout =&gt; out, :stderr =&gt; err)
+
+  reply[:out] = out
+  reply[:error] = err
+  reply[:exitstatus] = status
+</pre>
+<p>
+This can be simplified as:
+</p>
+<pre>
+  reply[:exitstatus] = run(&quot;echo 1&quot;, :stdout =&gt; :out, :stderr =&gt; :error)
+</pre>
+<p>
+You can set a command specific environment and cwd:
+</p>
+<pre>
+  run(&quot;echo 1&quot;, :cwd =&gt; &quot;/tmp&quot;, :environment =&gt; {&quot;FOO&quot; =&gt; &quot;BAR&quot;})
+</pre>
+<p>
+This will run &#8216;echo 1&#8217; from /tmp with FOO=BAR in addition to a
+setting forcing LC_ALL = C. To prevent LC_ALL from being set either set it
+specifically or:
+</p>
+<pre>
+  run(&quot;echo 1&quot;, :cwd =&gt; &quot;/tmp&quot;, :environment =&gt; nil)
+</pre>
+<p>
+Exceptions here will be handled by the usual agent exception handler or any
+specific one you create, if you dont it will just fall through and be sent
+to the client.
+</p>
+<p>
+If the shell handler fails to return a Process::Status instance for exit
+status this method will return -1 as the exit status
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="run-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 195</span>
+195:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">options</span>={})
+196:         <span class="ruby-identifier">shellopts</span> = {}
+197: 
+198:         <span class="ruby-comment cmt"># force stderr and stdout to be strings as the library</span>
+199:         <span class="ruby-comment cmt"># will append data to them if given using the &lt;&lt; method.</span>
+200:         <span class="ruby-comment cmt">#</span>
+201:         <span class="ruby-comment cmt"># if the data pased to :stderr or :stdin is a Symbol</span>
+202:         <span class="ruby-comment cmt"># add that into the reply hash with that Symbol</span>
+203:         [<span class="ruby-identifier">:stderr</span>, <span class="ruby-identifier">:stdout</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
+204:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>)
+205:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
+206:               <span class="ruby-identifier">reply</span>[ <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>] ] = <span class="ruby-value str">&quot;&quot;</span>
+207:               <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">reply</span>[ <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>] ]
+208:             <span class="ruby-keyword kw">else</span>
+209:               <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">&quot;&lt;&lt;&quot;</span>)
+210:                 <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>]
+211:               <span class="ruby-keyword kw">else</span>
+212:                 <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail!</span> <span class="ruby-node">&quot;#{k} should support &lt;&lt; while calling run(#{command})&quot;</span>
+213:               <span class="ruby-keyword kw">end</span>
+214:             <span class="ruby-keyword kw">end</span>
+215:           <span class="ruby-keyword kw">end</span>
+216:         <span class="ruby-keyword kw">end</span>
+217: 
+218:         [<span class="ruby-identifier">:stdin</span>, <span class="ruby-identifier">:cwd</span>, <span class="ruby-identifier">:environment</span>, <span class="ruby-identifier">:timeout</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
+219:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>)
+220:             <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>]
+221:           <span class="ruby-keyword kw">end</span>
+222:         <span class="ruby-keyword kw">end</span>
+223: 
+224:         <span class="ruby-identifier">shell</span> = <span class="ruby-constant">Shell</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">shellopts</span>)
+225: 
+226:         <span class="ruby-identifier">shell</span>.<span class="ruby-identifier">runcommand</span>
+227: 
+228:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:chomp</span>]
+229:           <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">:stdout</span>].<span class="ruby-identifier">chomp!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">:stdout</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
+230:           <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">:stderr</span>].<span class="ruby-identifier">chomp!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">:stderr</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
+231:         <span class="ruby-keyword kw">end</span>
+232: 
+233:         <span class="ruby-identifier">shell</span>.<span class="ruby-identifier">status</span>.<span class="ruby-identifier">exitstatus</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-value">-1</span>
+234:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="shellescape-method" class="method-detail ">
+                               <a name="M000414"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">shellescape</span><span
+                                               class="method-args">(str)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+convenience wrapper around <a
+href="../Util.html#M000311">Util#shellescape</a>
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="shellescape-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 308</span>
+308:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shellescape</span>(<span class="ruby-identifier">str</span>)
+309:         <span class="ruby-constant">Util</span>.<span class="ruby-identifier">shellescape</span>(<span class="ruby-identifier">str</span>)
+310:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="startup-hook-method" class="method-detail ">
+                               <a name="M000416"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">startup_hook</span><span
+                                               class="method-args">()</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Called at the end of the <a href="Agent.html">RPC::Agent</a> standard
+initialize method use this to adjust meta parameters, timeouts and any
+setup you need to do.
+</p>
+<p>
+This will not be called right when the daemon starts up, we use lazy
+loading and initialization so it will only be called the first time a
+request for this agent arrives.
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="startup-hook-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 338</span>
+338:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">startup_hook</span>
+339:       <span class="ruby-keyword kw">end</span></pre>
+                                       </div>
+                                       
+                               </div>
+
+                               
+                       </div>
+
+               
+                       <div id="validate-method" class="method-detail ">
+                               <a name="M000413"></a>
+
+                               <div class="method-heading">
+                               
+                                       <span class="method-name">validate</span><span
+                                               class="method-args">(key, validation)</span>
+                                       <span class="method-click-advice">click to toggle source</span>
+                               
+                               </div>
+
+                               <div class="method-description">
+                                       
+                                       <p>
+Validates a data member, if validation is a regex then it will try to match
+it else it supports testing object types only:
+</p>
+<p>
+validate :msg, <a href="../../String.html">String</a> validate :msg,
+/^[w\s]+$/
+</p>
+<p>
+There are also some special helper validators:
+</p>
+<p>
+validate :command, :shellsafe validate :command, :ipv6address validate
+:command, :ipv4address validate :command, :boolean validate :command,
+[&#8220;start&#8221;, &#8220;stop&#8221;]
+</p>
+<p>
+It will raise appropriate exceptions that the <a href="../RPC.html">RPC</a>
+system understand
+</p>
+                                       
+
+                                       
+                                       <div class="method-source-code"
+                                               id="validate-source">
+<pre>
+     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 299</span>
+299:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">validation</span>)
+300:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">MissingRPCData</span>, <span class="ruby-node">&quot;please supply a #{key} argument&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>)
+301: 
+302:         <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">validate</span>(<span class="ruby-ivar">@request</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">validation</span>)
+303:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ValidatorError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
+304:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidRPCData</span>, <span class="ruby-value str">&quot;Input %s did not pass validation: %s&quot;</span> <span class="ruby-operator">%</span> [ <span class="ruby-identifier">key</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span> ]
+305:       <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>
+