Update version according to OSCI-883
[packages/precise/mcollective.git] / doc / MCollective / DDL / AgentDDL.html
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">
5 <head>
6         <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
8         <title>Class: MCollective::DDL::AgentDDL</title>
9
10         <link rel="stylesheet" href="../../rdoc.css" type="text/css" media="screen" />
11
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>
20
21 </head>
22 <body class="class">
23
24         <div id="metadata">
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">
29                                         <ul>
30                                         
31                                                 <li><a href="../../lib/mcollective/ddl/agentddl_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
32                                                         class="thickbox" title="lib/mcollective/ddl/agentddl.rb">lib/mcollective/ddl/agentddl.rb</a></li>
33                                         
34                                         </ul>
35                                 </div>
36                         </div>
37
38                         
39                 </div>
40
41                 <div id="class-metadata">
42
43                         <!-- Parent Class -->
44                         
45                         <div id="parent-class-section" class="section">
46                                 <h3 class="section-header">Parent</h3>
47                                 
48                                 <p class="link">Base</p>
49                                 
50                         </div>
51                         
52
53                         <!-- Namespace Contents -->
54                         
55
56                         <!-- Method Quickref -->
57                         
58                         <div id="method-list-section" class="section">
59                                 <h3 class="section-header">Methods</h3>
60                                 <ul class="link-list">
61                                         
62                                         <li><a href="#M000266">::new</a></li>
63                                         
64                                         <li><a href="#M000271">#action</a></li>
65                                         
66                                         <li><a href="#M000276">#action_interface</a></li>
67                                         
68                                         <li><a href="#M000277">#actions</a></li>
69                                         
70                                         <li><a href="#M000269">#aggregate</a></li>
71                                         
72                                         <li><a href="#M000270">#display</a></li>
73                                         
74                                         <li><a href="#M000267">#input</a></li>
75                                         
76                                         <li><a href="#M000273">#is_function?</a></li>
77                                         
78                                         <li><a href="#M000272">#method_missing</a></li>
79                                         
80                                         <li><a href="#M000274">#set_default_input_arguments</a></li>
81                                         
82                                         <li><a href="#M000268">#summarize</a></li>
83                                         
84                                         <li><a href="#M000275">#validate_rpc_request</a></li>
85                                         
86                                 </ul>
87                         </div>
88                         
89
90                         <!-- Included Modules -->
91                         
92                 </div>
93
94                 <div id="project-metadata">
95                         
96                         
97                         <div id="fileindex-section" class="section project-section">
98                                 <h3 class="section-header">Files</h3>
99                                 <ul>
100                                 
101                                         <li class="file"><a href="../../COPYING.html">COPYING</a></li>
102                                 
103                                         <li class="file"><a href="../../Gemfile.html">Gemfile</a></li>
104                                 
105                                         <li class="file"><a href="../../README.html">README</a></li>
106                                 
107                                         <li class="file"><a href="../../Rakefile.html">Rakefile</a></li>
108                                 
109                                         <li class="file"><a href="../../etc/client_cfg_dist.html">client.cfg.dist</a></li>
110                                 
111                                         <li class="file"><a href="../../etc/data-help_erb.html">data-help.erb</a></li>
112                                 
113                                         <li class="file"><a href="../../etc/discovery-help_erb.html">discovery-help.erb</a></li>
114                                 
115                                         <li class="file"><a href="../../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
116                                 
117                                         <li class="file"><a href="../../etc/metadata-help_erb.html">metadata-help.erb</a></li>
118                                 
119                                         <li class="file"><a href="../../etc/msg-help_erb.html">msg-help.erb</a></li>
120                                 
121                                         <li class="file"><a href="../../etc/rpc-help_erb.html">rpc-help.erb</a></li>
122                                 
123                                         <li class="file"><a href="../../etc/server_cfg_dist.html">server.cfg.dist</a></li>
124                                 
125                                         <li class="file"><a href="../../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
126                                 
127                                         <li class="file"><a href="../../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
128                                 
129                                         <li class="file"><a href="../../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
130                                 
131                                         <li class="file"><a href="../../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
132                                 
133                                         <li class="file"><a href="../../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
134                                 
135                                         <li class="file"><a href="../../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
136                                 
137                                         <li class="file"><a href="../../lib/mcollective/locales/en_yml.html">en.yml</a></li>
138                                 
139                                         <li class="file"><a href="../../mcollective_init.html">mcollective.init</a></li>
140                                 
141                                 </ul>
142                         </div>
143                         
144
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">
151                                 <fieldset>
152                                         <legend>Quicksearch</legend>
153                                         <input type="text" name="quicksearch" value=""
154                                                 class="quicksearch-field" />
155                                 </fieldset>
156                                 </form>
157
158                                 <ul class="link-list">
159                                 
160                                         <li><a href="../../MCollective.html">MCollective</a></li>
161                                 
162                                         <li><a href="../../MCollective/Agent.html">MCollective::Agent</a></li>
163                                 
164                                         <li><a href="../../MCollective/Agents.html">MCollective::Agents</a></li>
165                                 
166                                         <li><a href="../../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
167                                 
168                                         <li><a href="../../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
169                                 
170                                         <li><a href="../../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
171                                 
172                                         <li><a href="../../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
173                                 
174                                         <li><a href="../../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
175                                 
176                                         <li><a href="../../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
177                                 
178                                         <li><a href="../../MCollective/Application.html">MCollective::Application</a></li>
179                                 
180                                         <li><a href="../../MCollective/Applications.html">MCollective::Applications</a></li>
181                                 
182                                         <li><a href="../../MCollective/Cache.html">MCollective::Cache</a></li>
183                                 
184                                         <li><a href="../../MCollective/Client.html">MCollective::Client</a></li>
185                                 
186                                         <li><a href="../../MCollective/CodedError.html">MCollective::CodedError</a></li>
187                                 
188                                         <li><a href="../../MCollective/Config.html">MCollective::Config</a></li>
189                                 
190                                         <li><a href="../../MCollective/Connector.html">MCollective::Connector</a></li>
191                                 
192                                         <li><a href="../../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
193                                 
194                                         <li><a href="../../MCollective/DDL.html">MCollective::DDL</a></li>
195                                 
196                                         <li><a href="../../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
197                                 
198                                         <li><a href="../../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
199                                 
200                                         <li><a href="../../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
201                                 
202                                         <li><a href="../../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
203                                 
204                                         <li><a href="../../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
205                                 
206                                         <li><a href="../../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
207                                 
208                                         <li><a href="../../MCollective/Data.html">MCollective::Data</a></li>
209                                 
210                                         <li><a href="../../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
211                                 
212                                         <li><a href="../../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
213                                 
214                                         <li><a href="../../MCollective/Discovery.html">MCollective::Discovery</a></li>
215                                 
216                                         <li><a href="../../MCollective/Facts.html">MCollective::Facts</a></li>
217                                 
218                                         <li><a href="../../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
219                                 
220                                         <li><a href="../../MCollective/Generators.html">MCollective::Generators</a></li>
221                                 
222                                         <li><a href="../../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
223                                 
224                                         <li><a href="../../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
225                                 
226                                         <li><a href="../../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
227                                 
228                                         <li><a href="../../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
229                                 
230                                         <li><a href="../../MCollective/Log.html">MCollective::Log</a></li>
231                                 
232                                         <li><a href="../../MCollective/Logger.html">MCollective::Logger</a></li>
233                                 
234                                         <li><a href="../../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
235                                 
236                                         <li><a href="../../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
237                                 
238                                         <li><a href="../../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
239                                 
240                                         <li><a href="../../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
241                                 
242                                         <li><a href="../../MCollective/Matcher.html">MCollective::Matcher</a></li>
243                                 
244                                         <li><a href="../../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
245                                 
246                                         <li><a href="../../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
247                                 
248                                         <li><a href="../../MCollective/Message.html">MCollective::Message</a></li>
249                                 
250                                         <li><a href="../../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
251                                 
252                                         <li><a href="../../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
253                                 
254                                         <li><a href="../../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
255                                 
256                                         <li><a href="../../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
257                                 
258                                         <li><a href="../../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
259                                 
260                                         <li><a href="../../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
261                                 
262                                         <li><a href="../../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
263                                 
264                                         <li><a href="../../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
265                                 
266                                         <li><a href="../../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
267                                 
268                                         <li><a href="../../MCollective/RPC.html">MCollective::RPC</a></li>
269                                 
270                                         <li><a href="../../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
271                                 
272                                         <li><a href="../../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
273                                 
274                                         <li><a href="../../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
275                                 
276                                         <li><a href="../../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
277                                 
278                                         <li><a href="../../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
279                                 
280                                         <li><a href="../../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
281                                 
282                                         <li><a href="../../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
283                                 
284                                         <li><a href="../../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
285                                 
286                                         <li><a href="../../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
287                                 
288                                         <li><a href="../../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
289                                 
290                                         <li><a href="../../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
291                                 
292                                         <li><a href="../../MCollective/RPCError.html">MCollective::RPCError</a></li>
293                                 
294                                         <li><a href="../../MCollective/Registration.html">MCollective::Registration</a></li>
295                                 
296                                         <li><a href="../../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
297                                 
298                                         <li><a href="../../MCollective/Runner.html">MCollective::Runner</a></li>
299                                 
300                                         <li><a href="../../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
301                                 
302                                         <li><a href="../../MCollective/SSL.html">MCollective::SSL</a></li>
303                                 
304                                         <li><a href="../../MCollective/Security.html">MCollective::Security</a></li>
305                                 
306                                         <li><a href="../../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
307                                 
308                                         <li><a href="../../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
309                                 
310                                         <li><a href="../../MCollective/Shell.html">MCollective::Shell</a></li>
311                                 
312                                         <li><a href="../../MCollective/Translatable.html">MCollective::Translatable</a></li>
313                                 
314                                         <li><a href="../../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
315                                 
316                                         <li><a href="../../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
317                                 
318                                         <li><a href="../../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
319                                 
320                                         <li><a href="../../MCollective/Util.html">MCollective::Util</a></li>
321                                 
322                                         <li><a href="../../MCollective/Validator.html">MCollective::Validator</a></li>
323                                 
324                                         <li><a href="../../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
325                                 
326                                         <li><a href="../../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
327                                 
328                                         <li><a href="../../Array.html">Array</a></li>
329                                 
330                                         <li><a href="../../Dir.html">Dir</a></li>
331                                 
332                                         <li><a href="../../Object.html">Object</a></li>
333                                 
334                                         <li><a href="../../String.html">String</a></li>
335                                 
336                                         <li><a href="../../Symbol.html">Symbol</a></li>
337                                 
338                                 </ul>
339                                 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
340                         </div>
341
342                         
343                 </div>
344         </div>
345
346         <div id="documentation">
347                 <h1 class="class">MCollective::DDL::AgentDDL</h1>
348
349                 <div id="description">
350                         <p>
351 A <a href="../DDL.html">DDL</a> class specific to agent plugins.
352 </p>
353 <p>
354 A full <a href="../DDL.html">DDL</a> can be seen below with all the
355 possible bells and whistles present.
356 </p>
357 <p>
358 metadata :name => &#8220;Utilities and Helpers for SimpleRPC Agents&#8221;,
359 </p>
360 <pre>
361             :description =&gt; &quot;General helpful actions that expose stats and internals to SimpleRPC clients&quot;,
362             :author      =&gt; &quot;R.I.Pienaar &lt;rip@devco.net&gt;&quot;,
363             :license     =&gt; &quot;Apache License, Version 2.0&quot;,
364             :version     =&gt; &quot;1.0&quot;,
365             :url         =&gt; &quot;http://marionette-collective.org/&quot;,
366             :timeout     =&gt; 10
367 </pre>
368 <p>
369 action &#8220;get_fact&#8220;, :description => &#8220;Retrieve a single
370 fact from the fact store&#8221; do
371 </p>
372 <pre>
373      display :always
374
375      input :fact,
376            :prompt      =&gt; &quot;The name of the fact&quot;,
377            :description =&gt; &quot;The fact to retrieve&quot;,
378            :type        =&gt; :string,
379            :validation  =&gt; '^[\w\-\.]+$',
380            :optional    =&gt; false,
381            :maxlength   =&gt; 40,
382            :default     =&gt; &quot;fqdn&quot;
383
384      output :fact,
385             :description =&gt; &quot;The name of the fact being returned&quot;,
386             :display_as  =&gt; &quot;Fact&quot;
387
388      output :value,
389             :description =&gt; &quot;The value of the fact&quot;,
390             :display_as  =&gt; &quot;Value&quot;,
391             :default     =&gt; &quot;&quot;
392
393     summarize do
394         aggregate summary(:value)
395     end
396 </pre>
397 <p>
398 end
399 </p>
400
401                 </div>
402
403                 <!-- Constants -->
404                 
405
406                 <!-- Attributes -->
407                 
408
409                 <!-- Methods -->
410                 
411                 <div id="public-class-method-details" class="method-section section">
412                         <h3 class="section-header">Public Class Methods</h3>
413
414                 
415                         <div id="new-method" class="method-detail ">
416                                 <a name="M000266"></a>
417
418                                 <div class="method-heading">
419                                 
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>
423                                 
424                                 </div>
425
426                                 <div class="method-description">
427                                         
428                                         <p class="missing-docs">(Not documented)</p>
429                                         
430
431                                         
432                                         <div class="method-source-code"
433                                                 id="new-source">
434 <pre>
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>
438 43: 
439 44:         <span class="ruby-keyword kw">super</span>
440 45:       <span class="ruby-keyword kw">end</span></pre>
441                                         </div>
442                                         
443                                 </div>
444
445                                 
446                         </div>
447
448                 
449                 </div>
450         
451                 <div id="public-instance-method-details" class="method-section section">
452                         <h3 class="section-header">Public Instance Methods</h3>
453
454                 
455                         <div id="action-method" class="method-detail ">
456                                 <a name="M000271"></a>
457
458                                 <div class="method-heading">
459                                 
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>
463                                 
464                                 </div>
465
466                                 <div class="method-description">
467                                         
468                                         <p>
469 Creates the definition for an action, you can nest input definitions inside
470 the action to attach inputs and validation to the actions
471 </p>
472 <pre>
473    action &quot;status&quot;, :description =&gt; &quot;Restarts a Service&quot; do
474       display :always
475
476       input  &quot;service&quot;,
477              :prompt      =&gt; &quot;Service Action&quot;,
478              :description =&gt; &quot;The action to perform&quot;,
479              :type        =&gt; :list,
480              :optional    =&gt; true,
481              :list        =&gt; [&quot;start&quot;, &quot;stop&quot;, &quot;restart&quot;, &quot;status&quot;]
482
483       output &quot;status&quot;,
484              :description =&gt; &quot;The status of the service after the action&quot;
485
486    end
487 </pre>
488                                         
489
490                                         
491                                         <div class="method-source-code"
492                                                 id="action-source">
493 <pre>
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">&amp;</span><span class="ruby-identifier">block</span>)
496 113:         <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Action needs a :description property&quot;</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>)
497 114: 
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>
506 123: 
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>
514                                         </div>
515                                         
516                                 </div>
517
518                                 
519                         </div>
520
521                 
522                         <div id="action-interface-method" class="method-detail ">
523                                 <a name="M000276"></a>
524
525                                 <div class="method-heading">
526                                 
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>
530                                 
531                                 </div>
532
533                                 <div class="method-description">
534                                         
535                                         <p>
536 Returns the interface for a specific action
537 </p>
538                                         
539
540                                         
541                                         <div class="method-source-code"
542                                                 id="action-interface-source">
543 <pre>
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>
548                                         </div>
549                                         
550                                 </div>
551
552                                 
553                         </div>
554
555                 
556                         <div id="actions-method" class="method-detail ">
557                                 <a name="M000277"></a>
558
559                                 <div class="method-heading">
560                                 
561                                         <span class="method-name">actions</span><span
562                                                 class="method-args">()</span>
563                                         <span class="method-click-advice">click to toggle source</span>
564                                 
565                                 </div>
566
567                                 <div class="method-description">
568                                         
569                                         <p>
570 Returns an array of actions this agent support
571 </p>
572                                         
573
574                                         
575                                         <div class="method-source-code"
576                                                 id="actions-source">
577 <pre>
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>
582                                         </div>
583                                         
584                                 </div>
585
586                                 
587                         </div>
588
589                 
590                         <div id="aggregate-method" class="method-detail ">
591                                 <a name="M000269"></a>
592
593                                 <div class="method-heading">
594                                 
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>
598                                 
599                                 </div>
600
601                                 <div class="method-description">
602                                         
603                                         <p>
604 Sets the aggregate array for the given action
605 </p>
606                                         
607
608                                         
609                                         <div class="method-source-code"
610                                                 id="aggregate-source">
611 <pre>
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">&gt;</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">&quot;Formats supplied to aggregation functions should be a hash&quot;</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">&quot;Formats supplied to aggregation functions must have a :format key&quot;</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">&quot;Functions supplied to aggregate should be a hash&quot;</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>)
617 74: 
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">&amp;&amp;</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">&quot;aggregate method for action '%{action}' missing a function parameter&quot;</span>, <span class="ruby-identifier">:error</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</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>
621 78: 
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">&lt;&lt;</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>
625                                         </div>
626                                         
627                                 </div>
628
629                                 
630                         </div>
631
632                 
633                         <div id="display-method" class="method-detail ">
634                                 <a name="M000270"></a>
635
636                                 <div class="method-heading">
637                                 
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>
641                                 
642                                 </div>
643
644                                 <div class="method-description">
645                                         
646                                         <p>
647 Sets the display preference to either :ok, :failed, :flatten or :always
648 operates on action level
649 </p>
650                                         
651
652                                         
653                                         <div class="method-source-code"
654                                                 id="display-source">
655 <pre>
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">&quot;Display preference #{pref} is not valid, should be :ok, :failed, :flatten or :always&quot;</span>
661 89:         <span class="ruby-keyword kw">end</span>
662 90: 
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>
666                                         </div>
667                                         
668                                 </div>
669
670                                 
671                         </div>
672
673                 
674                         <div id="input-method" class="method-detail ">
675                                 <a name="M000267"></a>
676
677                                 <div class="method-heading">
678                                 
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>
682                                 
683                                 </div>
684
685                                 <div class="method-description">
686                                         
687                                         <p class="missing-docs">(Not documented)</p>
688                                         
689
690                                         
691                                         <div class="method-source-code"
692                                                 id="input-source">
693 <pre>
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">&quot;Input needs a :optional property&quot;</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>)
697 49: 
698 50:         <span class="ruby-keyword kw">super</span>
699 51:       <span class="ruby-keyword kw">end</span></pre>
700                                         </div>
701                                         
702                                 </div>
703
704                                 
705                         </div>
706
707                 
708                         <div id="is-function--method" class="method-detail ">
709                                 <a name="M000273"></a>
710
711                                 <div class="method-heading">
712                                 
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>
716                                 
717                                 </div>
718
719                                 <div class="method-description">
720                                         
721                                         <p>
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.
726 </p>
727                                         
728
729                                         
730                                         <div class="method-source-code"
731                                                 id="is-function--source">
732 <pre>
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">&quot;aggregate&quot;</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>
737                                         </div>
738                                         
739                                 </div>
740
741                                 
742                         </div>
743
744                 
745                         <div id="method-missing-method" class="method-detail ">
746                                 <a name="M000272"></a>
747
748                                 <div class="method-heading">
749                                 
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>
753                                 
754                                 </div>
755
756                                 <div class="method-description">
757                                         
758                                         <p>
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
763 </p>
764                                         
765
766                                         
767                                         <div class="method-source-code"
768                                                 id="method-missing-source">
769 <pre>
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">&amp;</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">&quot;undefined local variable or method `#{name}'&quot;</span>, <span class="ruby-identifier">caller</span>
774 138:         <span class="ruby-keyword kw">end</span>
775 139: 
776 140:         <span class="ruby-keyword kw">return</span> {<span class="ruby-identifier">:function</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">:args</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>}
777 141:       <span class="ruby-keyword kw">end</span></pre>
778                                         </div>
779                                         
780                                 </div>
781
782                                 
783                         </div>
784
785                 
786                         <div id="set-default-input-arguments-method" class="method-detail ">
787                                 <a name="M000274"></a>
788
789                                 <div class="method-heading">
790                                 
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>
794                                 
795                                 </div>
796
797                                 <div class="method-description">
798                                         
799                                         <p>
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
804 </p>
805 <p>
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
811 </p>
812                                         
813
814                                         
815                                         <div class="method-source-code"
816                                                 id="set-default-input-arguments-source">
817 <pre>
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>]
821 161: 
822 162:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">input</span>
823 163: 
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">&amp;&amp;</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">&amp;&amp;</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">&quot;Setting default value for input '%s' to '%s'&quot;</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>
831                                         </div>
832                                         
833                                 </div>
834
835                                 
836                         </div>
837
838                 
839                         <div id="summarize-method" class="method-detail ">
840                                 <a name="M000268"></a>
841
842                                 <div class="method-heading">
843                                 
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>
847                                 
848                                 </div>
849
850                                 <div class="method-description">
851                                         
852                                         <p>
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.
856 </p>
857 <p>
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
863 </p>
864                                         
865
866                                         
867                                         <div class="method-source-code"
868                                                 id="summarize-source">
869 <pre>
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">&amp;</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>
878                                         </div>
879                                         
880                                 </div>
881
882                                 
883                         </div>
884
885                 
886                         <div id="validate-rpc-request-method" class="method-detail ">
887                                 <a name="M000275"></a>
888
889                                 <div class="method-heading">
890                                 
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>
894                                 
895                                 </div>
896
897                                 <div class="method-description">
898                                         
899                                         <p>
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.
902 </p>
903                                         
904
905                                         
906                                         <div class="method-source-code"
907                                                 id="validate-rpc-request-source">
908 <pre>
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">&quot;Attempted to call action %{action} for %{plugin} but it's not declared in the DDL&quot;</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">action</span>, <span class="ruby-identifier">:plugin</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@pluginname</span>)
914 178:         <span class="ruby-keyword kw">end</span>
915 179: 
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> {}
917 181: 
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">&quot;Action '%{action}' needs a '%{key}' argument&quot;</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">action</span>, <span class="ruby-identifier">:key</span> =<span class="ruby-operator">&gt;</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>
924 188: 
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>
929 193: 
930 194:         <span class="ruby-keyword kw">true</span>
931 195:       <span class="ruby-keyword kw">end</span></pre>
932                                         </div>
933                                         
934                                 </div>
935
936                                 
937                         </div>
938
939                 
940                 </div>
941         
942
943         </div>
944
945
946         <div id="rdoc-debugging-section-dump" class="debugging-section">
947         
948                 <p>Disabled; run with --debug to generate this.</p>
949         
950         </div>
951
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>
956         </div>
957
958 </body>
959 </html>
960