1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
8 <title>Class: MCollective::DDL::AgentDDL</title>
10 <link rel="stylesheet" href="../../rdoc.css" type="text/css" media="screen" />
12 <script src="../../js/jquery.js" type="text/javascript"
13 charset="utf-8"></script>
14 <script src="../../js/thickbox-compressed.js" type="text/javascript"
15 charset="utf-8"></script>
16 <script src="../../js/quicksearch.js" type="text/javascript"
17 charset="utf-8"></script>
18 <script src="../../js/darkfish.js" type="text/javascript"
19 charset="utf-8"></script>
25 <div id="file-metadata">
26 <div id="file-list-section" class="section">
27 <h3 class="section-header">In Files</h3>
28 <div class="section-body">
31 <li><a href="../../lib/mcollective/ddl/agentddl_rb.html?TB_iframe=true&height=550&width=785"
32 class="thickbox" title="lib/mcollective/ddl/agentddl.rb">lib/mcollective/ddl/agentddl.rb</a></li>
41 <div id="class-metadata">
45 <div id="parent-class-section" class="section">
46 <h3 class="section-header">Parent</h3>
48 <p class="link">Base</p>
53 <!-- Namespace Contents -->
56 <!-- Method Quickref -->
58 <div id="method-list-section" class="section">
59 <h3 class="section-header">Methods</h3>
60 <ul class="link-list">
62 <li><a href="#M000266">::new</a></li>
64 <li><a href="#M000271">#action</a></li>
66 <li><a href="#M000276">#action_interface</a></li>
68 <li><a href="#M000277">#actions</a></li>
70 <li><a href="#M000269">#aggregate</a></li>
72 <li><a href="#M000270">#display</a></li>
74 <li><a href="#M000267">#input</a></li>
76 <li><a href="#M000273">#is_function?</a></li>
78 <li><a href="#M000272">#method_missing</a></li>
80 <li><a href="#M000274">#set_default_input_arguments</a></li>
82 <li><a href="#M000268">#summarize</a></li>
84 <li><a href="#M000275">#validate_rpc_request</a></li>
90 <!-- Included Modules -->
94 <div id="project-metadata">
97 <div id="fileindex-section" class="section project-section">
98 <h3 class="section-header">Files</h3>
101 <li class="file"><a href="../../COPYING.html">COPYING</a></li>
103 <li class="file"><a href="../../Gemfile.html">Gemfile</a></li>
105 <li class="file"><a href="../../README.html">README</a></li>
107 <li class="file"><a href="../../Rakefile.html">Rakefile</a></li>
109 <li class="file"><a href="../../etc/client_cfg_dist.html">client.cfg.dist</a></li>
111 <li class="file"><a href="../../etc/data-help_erb.html">data-help.erb</a></li>
113 <li class="file"><a href="../../etc/discovery-help_erb.html">discovery-help.erb</a></li>
115 <li class="file"><a href="../../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
117 <li class="file"><a href="../../etc/metadata-help_erb.html">metadata-help.erb</a></li>
119 <li class="file"><a href="../../etc/msg-help_erb.html">msg-help.erb</a></li>
121 <li class="file"><a href="../../etc/rpc-help_erb.html">rpc-help.erb</a></li>
123 <li class="file"><a href="../../etc/server_cfg_dist.html">server.cfg.dist</a></li>
125 <li class="file"><a href="../../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
127 <li class="file"><a href="../../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
129 <li class="file"><a href="../../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
131 <li class="file"><a href="../../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
133 <li class="file"><a href="../../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
135 <li class="file"><a href="../../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
137 <li class="file"><a href="../../lib/mcollective/locales/en_yml.html">en.yml</a></li>
139 <li class="file"><a href="../../mcollective_init.html">mcollective.init</a></li>
145 <div id="classindex-section" class="section project-section">
146 <h3 class="section-header">Class Index
147 <span class="search-toggle"><img src="../../images/find.png"
148 height="16" width="16" alt="[+]"
149 title="show/hide quicksearch" /></span></h3>
150 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
152 <legend>Quicksearch</legend>
153 <input type="text" name="quicksearch" value=""
154 class="quicksearch-field" />
158 <ul class="link-list">
160 <li><a href="../../MCollective.html">MCollective</a></li>
162 <li><a href="../../MCollective/Agent.html">MCollective::Agent</a></li>
164 <li><a href="../../MCollective/Agents.html">MCollective::Agents</a></li>
166 <li><a href="../../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
168 <li><a href="../../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
170 <li><a href="../../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
172 <li><a href="../../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
174 <li><a href="../../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
176 <li><a href="../../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
178 <li><a href="../../MCollective/Application.html">MCollective::Application</a></li>
180 <li><a href="../../MCollective/Applications.html">MCollective::Applications</a></li>
182 <li><a href="../../MCollective/Cache.html">MCollective::Cache</a></li>
184 <li><a href="../../MCollective/Client.html">MCollective::Client</a></li>
186 <li><a href="../../MCollective/CodedError.html">MCollective::CodedError</a></li>
188 <li><a href="../../MCollective/Config.html">MCollective::Config</a></li>
190 <li><a href="../../MCollective/Connector.html">MCollective::Connector</a></li>
192 <li><a href="../../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
194 <li><a href="../../MCollective/DDL.html">MCollective::DDL</a></li>
196 <li><a href="../../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
198 <li><a href="../../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
200 <li><a href="../../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
202 <li><a href="../../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
204 <li><a href="../../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
206 <li><a href="../../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
208 <li><a href="../../MCollective/Data.html">MCollective::Data</a></li>
210 <li><a href="../../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
212 <li><a href="../../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
214 <li><a href="../../MCollective/Discovery.html">MCollective::Discovery</a></li>
216 <li><a href="../../MCollective/Facts.html">MCollective::Facts</a></li>
218 <li><a href="../../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
220 <li><a href="../../MCollective/Generators.html">MCollective::Generators</a></li>
222 <li><a href="../../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
224 <li><a href="../../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
226 <li><a href="../../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
228 <li><a href="../../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
230 <li><a href="../../MCollective/Log.html">MCollective::Log</a></li>
232 <li><a href="../../MCollective/Logger.html">MCollective::Logger</a></li>
234 <li><a href="../../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
236 <li><a href="../../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
238 <li><a href="../../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
240 <li><a href="../../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
242 <li><a href="../../MCollective/Matcher.html">MCollective::Matcher</a></li>
244 <li><a href="../../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
246 <li><a href="../../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
248 <li><a href="../../MCollective/Message.html">MCollective::Message</a></li>
250 <li><a href="../../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
252 <li><a href="../../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
254 <li><a href="../../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
256 <li><a href="../../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
258 <li><a href="../../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
260 <li><a href="../../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
262 <li><a href="../../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
264 <li><a href="../../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
266 <li><a href="../../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
268 <li><a href="../../MCollective/RPC.html">MCollective::RPC</a></li>
270 <li><a href="../../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
272 <li><a href="../../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
274 <li><a href="../../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
276 <li><a href="../../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
278 <li><a href="../../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
280 <li><a href="../../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
282 <li><a href="../../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
284 <li><a href="../../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
286 <li><a href="../../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
288 <li><a href="../../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
290 <li><a href="../../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
292 <li><a href="../../MCollective/RPCError.html">MCollective::RPCError</a></li>
294 <li><a href="../../MCollective/Registration.html">MCollective::Registration</a></li>
296 <li><a href="../../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
298 <li><a href="../../MCollective/Runner.html">MCollective::Runner</a></li>
300 <li><a href="../../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
302 <li><a href="../../MCollective/SSL.html">MCollective::SSL</a></li>
304 <li><a href="../../MCollective/Security.html">MCollective::Security</a></li>
306 <li><a href="../../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
308 <li><a href="../../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
310 <li><a href="../../MCollective/Shell.html">MCollective::Shell</a></li>
312 <li><a href="../../MCollective/Translatable.html">MCollective::Translatable</a></li>
314 <li><a href="../../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
316 <li><a href="../../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
318 <li><a href="../../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
320 <li><a href="../../MCollective/Util.html">MCollective::Util</a></li>
322 <li><a href="../../MCollective/Validator.html">MCollective::Validator</a></li>
324 <li><a href="../../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
326 <li><a href="../../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
328 <li><a href="../../Array.html">Array</a></li>
330 <li><a href="../../Dir.html">Dir</a></li>
332 <li><a href="../../Object.html">Object</a></li>
334 <li><a href="../../String.html">String</a></li>
336 <li><a href="../../Symbol.html">Symbol</a></li>
339 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
346 <div id="documentation">
347 <h1 class="class">MCollective::DDL::AgentDDL</h1>
349 <div id="description">
351 A <a href="../DDL.html">DDL</a> class specific to agent plugins.
354 A full <a href="../DDL.html">DDL</a> can be seen below with all the
355 possible bells and whistles present.
358 metadata :name => “Utilities and Helpers for SimpleRPC Agents”,
361 :description => "General helpful actions that expose stats and internals to SimpleRPC clients",
362 :author => "R.I.Pienaar <rip@devco.net>",
363 :license => "Apache License, Version 2.0",
364 :version => "1.0",
365 :url => "http://marionette-collective.org/",
369 action “get_fact“, :description => “Retrieve a single
370 fact from the fact store” do
376 :prompt => "The name of the fact",
377 :description => "The fact to retrieve",
379 :validation => '^[\w\-\.]+$',
380 :optional => false,
382 :default => "fqdn"
385 :description => "The name of the fact being returned",
386 :display_as => "Fact"
389 :description => "The value of the fact",
390 :display_as => "Value",
391 :default => ""
394 aggregate summary(:value)
411 <div id="public-class-method-details" class="method-section section">
412 <h3 class="section-header">Public Class Methods</h3>
415 <div id="new-method" class="method-detail ">
416 <a name="M000266"></a>
418 <div class="method-heading">
420 <span class="method-name">new</span><span
421 class="method-args">(plugin, plugintype=:agent, loadddl=true)</span>
422 <span class="method-click-advice">click to toggle source</span>
426 <div class="method-description">
428 <p class="missing-docs">(Not documented)</p>
432 <div class="method-source-code"
435 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 41</span>
436 41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">plugin</span>, <span class="ruby-identifier">plugintype</span>=<span class="ruby-identifier">:agent</span>, <span class="ruby-identifier">loadddl</span>=<span class="ruby-keyword kw">true</span>)
437 42: <span class="ruby-ivar">@process_aggregate_functions</span> = <span class="ruby-keyword kw">nil</span>
439 44: <span class="ruby-keyword kw">super</span>
440 45: <span class="ruby-keyword kw">end</span></pre>
451 <div id="public-instance-method-details" class="method-section section">
452 <h3 class="section-header">Public Instance Methods</h3>
455 <div id="action-method" class="method-detail ">
456 <a name="M000271"></a>
458 <div class="method-heading">
460 <span class="method-name">action</span><span
461 class="method-args">(name, input, &block)</span>
462 <span class="method-click-advice">click to toggle source</span>
466 <div class="method-description">
469 Creates the definition for an action, you can nest input definitions inside
470 the action to attach inputs and validation to the actions
473 action "status", :description => "Restarts a Service" do
476 input "service",
477 :prompt => "Service Action",
478 :description => "The action to perform",
480 :optional => true,
481 :list => ["start", "stop", "restart", "status"]
483 output "status",
484 :description => "The status of the service after the action"
491 <div class="method-source-code"
494 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 112</span>
495 112: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">action</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">input</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
496 113: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Action needs a :description property"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">input</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:description</span>)
498 115: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@entities</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">name</span>)
499 116: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">name</span>] = {}
500 117: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">name</span>][<span class="ruby-identifier">:action</span>] = <span class="ruby-identifier">name</span>
501 118: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">name</span>][<span class="ruby-identifier">:input</span>] = {}
502 119: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">name</span>][<span class="ruby-identifier">:output</span>] = {}
503 120: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">name</span>][<span class="ruby-identifier">:display</span>] = <span class="ruby-identifier">:failed</span>
504 121: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">name</span>][<span class="ruby-identifier">:description</span>] = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">:description</span>]
505 122: <span class="ruby-keyword kw">end</span>
507 124: <span class="ruby-comment cmt"># if a block is passed it might be creating input methods, call it</span>
508 125: <span class="ruby-comment cmt"># we set @current_entity so the input block can know what its talking</span>
509 126: <span class="ruby-comment cmt"># to, this is probably an epic hack, need to improve.</span>
510 127: <span class="ruby-ivar">@current_entity</span> = <span class="ruby-identifier">name</span>
511 128: <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
512 129: <span class="ruby-ivar">@current_entity</span> = <span class="ruby-keyword kw">nil</span>
513 130: <span class="ruby-keyword kw">end</span></pre>
522 <div id="action-interface-method" class="method-detail ">
523 <a name="M000276"></a>
525 <div class="method-heading">
527 <span class="method-name">action_interface</span><span
528 class="method-args">(name)</span>
529 <span class="method-click-advice">click to toggle source</span>
533 <div class="method-description">
536 Returns the interface for a specific action
541 <div class="method-source-code"
542 id="action-interface-source">
544 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 198</span>
545 198: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">action_interface</span>(<span class="ruby-identifier">name</span>)
546 199: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">name</span>] <span class="ruby-operator">||</span> {}
547 200: <span class="ruby-keyword kw">end</span></pre>
556 <div id="actions-method" class="method-detail ">
557 <a name="M000277"></a>
559 <div class="method-heading">
561 <span class="method-name">actions</span><span
562 class="method-args">()</span>
563 <span class="method-click-advice">click to toggle source</span>
567 <div class="method-description">
570 Returns an array of actions this agent support
575 <div class="method-source-code"
578 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 203</span>
579 203: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">actions</span>
580 204: <span class="ruby-ivar">@entities</span>.<span class="ruby-identifier">keys</span>
581 205: <span class="ruby-keyword kw">end</span></pre>
590 <div id="aggregate-method" class="method-detail ">
591 <a name="M000269"></a>
593 <div class="method-heading">
595 <span class="method-name">aggregate</span><span
596 class="method-args">(function, format = {:format => nil})</span>
597 <span class="method-click-advice">click to toggle source</span>
601 <div class="method-description">
604 Sets the aggregate array for the given action
609 <div class="method-source-code"
610 id="aggregate-source">
612 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 70</span>
613 70: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">aggregate</span>(<span class="ruby-identifier">function</span>, <span class="ruby-identifier">format</span> = {<span class="ruby-identifier">:format</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">nil</span>})
614 71: <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC28</span>, <span class="ruby-value str">"Formats supplied to aggregation functions should be a hash"</span>, <span class="ruby-identifier">:error</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">format</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
615 72: <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC27</span>, <span class="ruby-value str">"Formats supplied to aggregation functions must have a :format key"</span>, <span class="ruby-identifier">:error</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">format</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:format</span>)
616 73: <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC26</span>, <span class="ruby-value str">"Functions supplied to aggregate should be a hash"</span>, <span class="ruby-identifier">:error</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">function</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
618 75: <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">function</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:args</span>)) <span class="ruby-operator">&&</span> <span class="ruby-identifier">function</span>[<span class="ruby-identifier">:args</span>]
619 76: <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC25</span>, <span class="ruby-value str">"aggregate method for action '%{action}' missing a function parameter"</span>, <span class="ruby-identifier">:error</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">entities</span>[<span class="ruby-ivar">@current_entity</span>][<span class="ruby-identifier">:action</span>])
620 77: <span class="ruby-keyword kw">end</span>
622 79: <span class="ruby-identifier">entities</span>[<span class="ruby-ivar">@current_entity</span>][<span class="ruby-identifier">:aggregate</span>] <span class="ruby-operator">||=</span> []
623 80: <span class="ruby-identifier">entities</span>[<span class="ruby-ivar">@current_entity</span>][<span class="ruby-identifier">:aggregate</span>] <span class="ruby-operator"><<</span> (<span class="ruby-identifier">format</span>[<span class="ruby-identifier">:format</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-identifier">function</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">function</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">format</span>))
624 81: <span class="ruby-keyword kw">end</span></pre>
633 <div id="display-method" class="method-detail ">
634 <a name="M000270"></a>
636 <div class="method-heading">
638 <span class="method-name">display</span><span
639 class="method-args">(pref)</span>
640 <span class="method-click-advice">click to toggle source</span>
644 <div class="method-description">
647 Sets the display preference to either :ok, :failed, :flatten or :always
648 operates on action level
653 <div class="method-source-code"
656 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 85</span>
657 85: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display</span>(<span class="ruby-identifier">pref</span>)
658 86: <span class="ruby-comment cmt"># defaults to old behavior, complain if its supplied and invalid</span>
659 87: <span class="ruby-keyword kw">unless</span> [<span class="ruby-identifier">:ok</span>, <span class="ruby-identifier">:failed</span>, <span class="ruby-identifier">:flatten</span>, <span class="ruby-identifier">:always</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">pref</span>)
660 88: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Display preference #{pref} is not valid, should be :ok, :failed, :flatten or :always"</span>
661 89: <span class="ruby-keyword kw">end</span>
663 91: <span class="ruby-identifier">action</span> = <span class="ruby-ivar">@current_entity</span>
664 92: <span class="ruby-ivar">@entities</span>[<span class="ruby-identifier">action</span>][<span class="ruby-identifier">:display</span>] = <span class="ruby-identifier">pref</span>
665 93: <span class="ruby-keyword kw">end</span></pre>
674 <div id="input-method" class="method-detail ">
675 <a name="M000267"></a>
677 <div class="method-heading">
679 <span class="method-name">input</span><span
680 class="method-args">(argument, properties)</span>
681 <span class="method-click-advice">click to toggle source</span>
685 <div class="method-description">
687 <p class="missing-docs">(Not documented)</p>
691 <div class="method-source-code"
694 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 47</span>
695 47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">input</span>(<span class="ruby-identifier">argument</span>, <span class="ruby-identifier">properties</span>)
696 48: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Input needs a :optional property"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:optional</span>)
698 50: <span class="ruby-keyword kw">super</span>
699 51: <span class="ruby-keyword kw">end</span></pre>
708 <div id="is-function--method" class="method-detail ">
709 <a name="M000273"></a>
711 <div class="method-heading">
713 <span class="method-name">is_function?</span><span
714 class="method-args">(method_name)</span>
715 <span class="method-click-advice">click to toggle source</span>
719 <div class="method-description">
722 Checks if a method name matches a aggregate plugin. This is used by method
723 missing so that we dont greedily assume that every <a
724 href="AgentDDL.html#M000272">method_missing</a> call in an agent ddl has
725 hit a aggregate function.
730 <div class="method-source-code"
731 id="is-function--source">
733 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 146</span>
734 146: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_function?</span>(<span class="ruby-identifier">method_name</span>)
735 147: <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value str">"aggregate"</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">method_name</span>.<span class="ruby-identifier">to_s</span>)
736 148: <span class="ruby-keyword kw">end</span></pre>
745 <div id="method-missing-method" class="method-detail ">
746 <a name="M000272"></a>
748 <div class="method-heading">
750 <span class="method-name">method_missing</span><span
751 class="method-args">(name, *args, &block)</span>
752 <span class="method-click-advice">click to toggle source</span>
756 <div class="method-description">
759 If the method name matches a # aggregate function, we return the function
760 with args as a hash. This will only be active if the
761 @process_aggregate_functions is set to true which only happens in the <a
762 href="AgentDDL.html#M000268">summarize</a> block
767 <div class="method-source-code"
768 id="method-missing-source">
770 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 135</span>
771 135: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
772 136: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@process_aggregate_functions</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">is_function?</span>(<span class="ruby-identifier">name</span>)
773 137: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>, <span class="ruby-node">"undefined local variable or method `#{name}'"</span>, <span class="ruby-identifier">caller</span>
774 138: <span class="ruby-keyword kw">end</span>
776 140: <span class="ruby-keyword kw">return</span> {<span class="ruby-identifier">:function</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">:args</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">args</span>}
777 141: <span class="ruby-keyword kw">end</span></pre>
786 <div id="set-default-input-arguments-method" class="method-detail ">
787 <a name="M000274"></a>
789 <div class="method-heading">
791 <span class="method-name">set_default_input_arguments</span><span
792 class="method-args">(action, arguments)</span>
793 <span class="method-click-advice">click to toggle source</span>
797 <div class="method-description">
800 For a given action and arguments look up the <a href="../DDL.html">DDL</a>
801 interface to that action and if any arguments in the <a
802 href="../DDL.html">DDL</a> have a :default value assign that to any input
803 that does not have an argument in the input arguments
806 This is intended to only be called on clients and not on servers as the
807 clients should never be able to publish non compliant requests and the
808 servers should really not tamper with incoming requests since doing so
809 might raise validation errors that were not raised on the client breaking
810 our fail-fast approach to input validation
815 <div class="method-source-code"
816 id="set-default-input-arguments-source">
818 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 159</span>
819 159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_default_input_arguments</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">arguments</span>)
820 160: <span class="ruby-identifier">input</span> = <span class="ruby-identifier">action_interface</span>(<span class="ruby-identifier">action</span>)[<span class="ruby-identifier">:input</span>]
822 162: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">input</span>
824 164: <span class="ruby-identifier">input</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
825 165: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">arguments</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:default</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:optional</span>]
826 166: <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-value str">"Setting default value for input '%s' to '%s'"</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">key</span>, <span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:default</span>]])
827 167: <span class="ruby-identifier">arguments</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:default</span>]
828 168: <span class="ruby-keyword kw">end</span>
829 169: <span class="ruby-keyword kw">end</span>
830 170: <span class="ruby-keyword kw">end</span></pre>
839 <div id="summarize-method" class="method-detail ">
840 <a name="M000268"></a>
842 <div class="method-heading">
844 <span class="method-name">summarize</span><span
845 class="method-args">(&block)</span>
846 <span class="method-click-advice">click to toggle source</span>
850 <div class="method-description">
853 Calls the summarize block defined in the ddl. Block will not be called if
854 the ddl is getting processed on the server side. This means that aggregate
855 plugins only have to be present on the client side.
858 The @process_aggregate_functions variable is used by the <a
859 href="AgentDDL.html#M000272">method_missing</a> block to determine if it
860 should kick in, this way we very tightly control where we activate the <a
861 href="AgentDDL.html#M000272">method_missing</a> behavior turning it into a
862 noop otherwise to maximise the chance of providing good user feedback
867 <div class="method-source-code"
868 id="summarize-source">
870 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 61</span>
871 61: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">summarize</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
872 62: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:server</span>
873 63: <span class="ruby-ivar">@process_aggregate_functions</span> = <span class="ruby-keyword kw">true</span>
874 64: <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>
875 65: <span class="ruby-ivar">@process_aggregate_functions</span> = <span class="ruby-keyword kw">nil</span>
876 66: <span class="ruby-keyword kw">end</span>
877 67: <span class="ruby-keyword kw">end</span></pre>
886 <div id="validate-rpc-request-method" class="method-detail ">
887 <a name="M000275"></a>
889 <div class="method-heading">
891 <span class="method-name">validate_rpc_request</span><span
892 class="method-args">(action, arguments)</span>
893 <span class="method-click-advice">click to toggle source</span>
897 <div class="method-description">
900 Helper to use the <a href="../DDL.html">DDL</a> to figure out if the remote
901 call to an agent should be allowed based on action name and inputs.
906 <div class="method-source-code"
907 id="validate-rpc-request-source">
909 <span class="ruby-comment cmt"># File lib/mcollective/ddl/agentddl.rb, line 174</span>
910 174: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate_rpc_request</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">arguments</span>)
911 175: <span class="ruby-comment cmt"># is the action known?</span>
912 176: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">action</span>)
913 177: <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC29</span>, <span class="ruby-value str">"Attempted to call action %{action} for %{plugin} but it's not declared in the DDL"</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">action</span>, <span class="ruby-identifier">:plugin</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@pluginname</span>)
914 178: <span class="ruby-keyword kw">end</span>
916 180: <span class="ruby-identifier">input</span> = <span class="ruby-identifier">action_interface</span>(<span class="ruby-identifier">action</span>)[<span class="ruby-identifier">:input</span>] <span class="ruby-operator">||</span> {}
918 182: <span class="ruby-identifier">input</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
919 183: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">input</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:optional</span>]
920 184: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">arguments</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>)
921 185: <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC30</span>, <span class="ruby-value str">"Action '%{action}' needs a '%{key}' argument"</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">action</span>, <span class="ruby-identifier">:key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">key</span>)
922 186: <span class="ruby-keyword kw">end</span>
923 187: <span class="ruby-keyword kw">end</span>
925 189: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arguments</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>)
926 190: <span class="ruby-identifier">validate_input_argument</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">arguments</span>[<span class="ruby-identifier">key</span>])
927 191: <span class="ruby-keyword kw">end</span>
928 192: <span class="ruby-keyword kw">end</span>
930 194: <span class="ruby-keyword kw">true</span>
931 195: <span class="ruby-keyword kw">end</span></pre>
946 <div id="rdoc-debugging-section-dump" class="debugging-section">
948 <p>Disabled; run with --debug to generate this.</p>
952 <div id="validator-badges">
953 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
954 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
955 Rdoc Generator</a> 1.1.6</small>.</p>