Update version according to OSCI-883
[packages/precise/mcollective.git] / doc / MCollective / RPC / Agent.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::RPC::Agent</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/rpc/agent_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
32                                                         class="thickbox" title="lib/mcollective/rpc/agent.rb">lib/mcollective/rpc/agent.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"><a href="../../Object.html">Object</a></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="#M000411">::action</a></li>
63                                         
64                                         <li><a href="#M000405">::actions</a></li>
65                                         
66                                         <li><a href="#M000404">::activate?</a></li>
67                                         
68                                         <li><a href="#M000410">::activate_when</a></li>
69                                         
70                                         <li><a href="#M000412">::authorized_by</a></li>
71                                         
72                                         <li><a href="#M000407">::metadata</a></li>
73                                         
74                                         <li><a href="#M000393">::new</a></li>
75                                         
76                                         <li><a href="#M000418">#after_processing_hook</a></li>
77                                         
78                                         <li><a href="#M000419">#audit_request</a></li>
79                                         
80                                         <li><a href="#M000417">#before_processing_hook</a></li>
81                                         
82                                         <li><a href="#M000395">#handlemsg</a></li>
83                                         
84                                         <li><a href="#M000415">#implemented_by</a></li>
85                                         
86                                         <li><a href="#M000394">#load_ddl</a></li>
87                                         
88                                         <li><a href="#M000406">#run</a></li>
89                                         
90                                         <li><a href="#M000414">#shellescape</a></li>
91                                         
92                                         <li><a href="#M000416">#startup_hook</a></li>
93                                         
94                                         <li><a href="#M000413">#validate</a></li>
95                                         
96                                 </ul>
97                         </div>
98                         
99
100                         <!-- Included Modules -->
101                         
102                         <div id="includes-section" class="section">
103                                 <h3 class="section-header">Included Modules</h3>
104                                 <ul class="link-list">
105                                 
106                                 
107                                         <li><a class="include" href="../Validator.html">MCollective::Validator</a></li>
108                                 
109                                 
110                                 </ul>
111                         </div>
112                         
113                 </div>
114
115                 <div id="project-metadata">
116                         
117                         
118                         <div id="fileindex-section" class="section project-section">
119                                 <h3 class="section-header">Files</h3>
120                                 <ul>
121                                 
122                                         <li class="file"><a href="../../COPYING.html">COPYING</a></li>
123                                 
124                                         <li class="file"><a href="../../Gemfile.html">Gemfile</a></li>
125                                 
126                                         <li class="file"><a href="../../README.html">README</a></li>
127                                 
128                                         <li class="file"><a href="../../Rakefile.html">Rakefile</a></li>
129                                 
130                                         <li class="file"><a href="../../etc/client_cfg_dist.html">client.cfg.dist</a></li>
131                                 
132                                         <li class="file"><a href="../../etc/data-help_erb.html">data-help.erb</a></li>
133                                 
134                                         <li class="file"><a href="../../etc/discovery-help_erb.html">discovery-help.erb</a></li>
135                                 
136                                         <li class="file"><a href="../../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
137                                 
138                                         <li class="file"><a href="../../etc/metadata-help_erb.html">metadata-help.erb</a></li>
139                                 
140                                         <li class="file"><a href="../../etc/msg-help_erb.html">msg-help.erb</a></li>
141                                 
142                                         <li class="file"><a href="../../etc/rpc-help_erb.html">rpc-help.erb</a></li>
143                                 
144                                         <li class="file"><a href="../../etc/server_cfg_dist.html">server.cfg.dist</a></li>
145                                 
146                                         <li class="file"><a href="../../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
147                                 
148                                         <li class="file"><a href="../../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
149                                 
150                                         <li class="file"><a href="../../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
151                                 
152                                         <li class="file"><a href="../../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
153                                 
154                                         <li class="file"><a href="../../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
155                                 
156                                         <li class="file"><a href="../../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
157                                 
158                                         <li class="file"><a href="../../lib/mcollective/locales/en_yml.html">en.yml</a></li>
159                                 
160                                         <li class="file"><a href="../../mcollective_init.html">mcollective.init</a></li>
161                                 
162                                 </ul>
163                         </div>
164                         
165
166                         <div id="classindex-section" class="section project-section">
167                                 <h3 class="section-header">Class Index
168                                         <span class="search-toggle"><img src="../../images/find.png"
169                                                 height="16" width="16" alt="[+]"
170                                                 title="show/hide quicksearch" /></span></h3>
171                                 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
172                                 <fieldset>
173                                         <legend>Quicksearch</legend>
174                                         <input type="text" name="quicksearch" value=""
175                                                 class="quicksearch-field" />
176                                 </fieldset>
177                                 </form>
178
179                                 <ul class="link-list">
180                                 
181                                         <li><a href="../../MCollective.html">MCollective</a></li>
182                                 
183                                         <li><a href="../../MCollective/Agent.html">MCollective::Agent</a></li>
184                                 
185                                         <li><a href="../../MCollective/Agents.html">MCollective::Agents</a></li>
186                                 
187                                         <li><a href="../../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
188                                 
189                                         <li><a href="../../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
190                                 
191                                         <li><a href="../../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
192                                 
193                                         <li><a href="../../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
194                                 
195                                         <li><a href="../../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
196                                 
197                                         <li><a href="../../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
198                                 
199                                         <li><a href="../../MCollective/Application.html">MCollective::Application</a></li>
200                                 
201                                         <li><a href="../../MCollective/Applications.html">MCollective::Applications</a></li>
202                                 
203                                         <li><a href="../../MCollective/Cache.html">MCollective::Cache</a></li>
204                                 
205                                         <li><a href="../../MCollective/Client.html">MCollective::Client</a></li>
206                                 
207                                         <li><a href="../../MCollective/CodedError.html">MCollective::CodedError</a></li>
208                                 
209                                         <li><a href="../../MCollective/Config.html">MCollective::Config</a></li>
210                                 
211                                         <li><a href="../../MCollective/Connector.html">MCollective::Connector</a></li>
212                                 
213                                         <li><a href="../../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
214                                 
215                                         <li><a href="../../MCollective/DDL.html">MCollective::DDL</a></li>
216                                 
217                                         <li><a href="../../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
218                                 
219                                         <li><a href="../../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
220                                 
221                                         <li><a href="../../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
222                                 
223                                         <li><a href="../../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
224                                 
225                                         <li><a href="../../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
226                                 
227                                         <li><a href="../../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
228                                 
229                                         <li><a href="../../MCollective/Data.html">MCollective::Data</a></li>
230                                 
231                                         <li><a href="../../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
232                                 
233                                         <li><a href="../../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
234                                 
235                                         <li><a href="../../MCollective/Discovery.html">MCollective::Discovery</a></li>
236                                 
237                                         <li><a href="../../MCollective/Facts.html">MCollective::Facts</a></li>
238                                 
239                                         <li><a href="../../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
240                                 
241                                         <li><a href="../../MCollective/Generators.html">MCollective::Generators</a></li>
242                                 
243                                         <li><a href="../../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
244                                 
245                                         <li><a href="../../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
246                                 
247                                         <li><a href="../../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
248                                 
249                                         <li><a href="../../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
250                                 
251                                         <li><a href="../../MCollective/Log.html">MCollective::Log</a></li>
252                                 
253                                         <li><a href="../../MCollective/Logger.html">MCollective::Logger</a></li>
254                                 
255                                         <li><a href="../../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
256                                 
257                                         <li><a href="../../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
258                                 
259                                         <li><a href="../../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
260                                 
261                                         <li><a href="../../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
262                                 
263                                         <li><a href="../../MCollective/Matcher.html">MCollective::Matcher</a></li>
264                                 
265                                         <li><a href="../../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
266                                 
267                                         <li><a href="../../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
268                                 
269                                         <li><a href="../../MCollective/Message.html">MCollective::Message</a></li>
270                                 
271                                         <li><a href="../../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
272                                 
273                                         <li><a href="../../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
274                                 
275                                         <li><a href="../../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
276                                 
277                                         <li><a href="../../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
278                                 
279                                         <li><a href="../../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
280                                 
281                                         <li><a href="../../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
282                                 
283                                         <li><a href="../../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
284                                 
285                                         <li><a href="../../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
286                                 
287                                         <li><a href="../../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
288                                 
289                                         <li><a href="../../MCollective/RPC.html">MCollective::RPC</a></li>
290                                 
291                                         <li><a href="../../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
292                                 
293                                         <li><a href="../../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
294                                 
295                                         <li><a href="../../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
296                                 
297                                         <li><a href="../../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
298                                 
299                                         <li><a href="../../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
300                                 
301                                         <li><a href="../../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
302                                 
303                                         <li><a href="../../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
304                                 
305                                         <li><a href="../../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
306                                 
307                                         <li><a href="../../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
308                                 
309                                         <li><a href="../../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
310                                 
311                                         <li><a href="../../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
312                                 
313                                         <li><a href="../../MCollective/RPCError.html">MCollective::RPCError</a></li>
314                                 
315                                         <li><a href="../../MCollective/Registration.html">MCollective::Registration</a></li>
316                                 
317                                         <li><a href="../../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
318                                 
319                                         <li><a href="../../MCollective/Runner.html">MCollective::Runner</a></li>
320                                 
321                                         <li><a href="../../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
322                                 
323                                         <li><a href="../../MCollective/SSL.html">MCollective::SSL</a></li>
324                                 
325                                         <li><a href="../../MCollective/Security.html">MCollective::Security</a></li>
326                                 
327                                         <li><a href="../../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
328                                 
329                                         <li><a href="../../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
330                                 
331                                         <li><a href="../../MCollective/Shell.html">MCollective::Shell</a></li>
332                                 
333                                         <li><a href="../../MCollective/Translatable.html">MCollective::Translatable</a></li>
334                                 
335                                         <li><a href="../../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
336                                 
337                                         <li><a href="../../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
338                                 
339                                         <li><a href="../../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
340                                 
341                                         <li><a href="../../MCollective/Util.html">MCollective::Util</a></li>
342                                 
343                                         <li><a href="../../MCollective/Validator.html">MCollective::Validator</a></li>
344                                 
345                                         <li><a href="../../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
346                                 
347                                         <li><a href="../../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
348                                 
349                                         <li><a href="../../Array.html">Array</a></li>
350                                 
351                                         <li><a href="../../Dir.html">Dir</a></li>
352                                 
353                                         <li><a href="../../Object.html">Object</a></li>
354                                 
355                                         <li><a href="../../String.html">String</a></li>
356                                 
357                                         <li><a href="../../Symbol.html">Symbol</a></li>
358                                 
359                                 </ul>
360                                 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
361                         </div>
362
363                         
364                 </div>
365         </div>
366
367         <div id="documentation">
368                 <h1 class="class">MCollective::RPC::Agent</h1>
369
370                 <div id="description">
371                         <p>
372 A wrapper around the traditional agent, it takes care of a lot of the
373 tedious setup you would do for each agent allowing you to just create
374 methods following a naming standard leaving the heavy lifting up to this
375 clas.
376 </p>
377 <p>
378 See <a
379 href="http://marionette-collective.org/simplerpc/agents.html">marionette-collective.org/simplerpc/agents.html</a>
380 </p>
381 <p>
382 It only really makes sense to use this with a Simple <a
383 href="../RPC.html">RPC</a> client on the other end, basic usage would be:
384 </p>
385 <pre>
386    module MCollective
387      module Agent
388        class Helloworld&lt;RPC::Agent
389          action &quot;hello&quot; do
390            reply[:msg] = &quot;Hello #{request[:name]}&quot;
391          end
392
393          action &quot;foo&quot; do
394            implemented_by &quot;/some/script.sh&quot;
395          end
396        end
397      end
398    end
399 </pre>
400 <p>
401 If you wish to implement the logic for an action using an external script
402 use the <a href="Agent.html#M000415">implemented_by</a> method that will
403 cause your script to be run with 2 arguments.
404 </p>
405 <p>
406 The first argument is a file containing JSON with the request and the 2nd
407 argument is where the script should save its output as a JSON hash.
408 </p>
409 <p>
410 We also currently have the validation code in here, this will be moved to
411 plugins soon.
412 </p>
413
414                 </div>
415
416                 <!-- Constants -->
417                 
418
419                 <!-- Attributes -->
420                 
421                 <div id="attribute-method-details" class="method-section section">
422                         <h3 class="section-header">Attributes</h3>
423
424                         
425                         <div id="reply-attribute-method" class="method-detail">
426                                 <a name="reply"></a>
427                                 
428                                 <a name="reply="></a>
429                                 
430                                 <div class="method-heading attribute-method-heading">
431                                         <span class="method-name">reply</span><span
432                                                 class="attribute-access-type">[RW]</span>
433                                 </div>
434
435                                 <div class="method-description">
436                                 
437                                 <p class="missing-docs">(Not documented)</p>
438                                 
439                                 </div>
440                         </div>
441                         
442                         <div id="request-attribute-method" class="method-detail">
443                                 <a name="request"></a>
444                                 
445                                 <a name="request="></a>
446                                 
447                                 <div class="method-heading attribute-method-heading">
448                                         <span class="method-name">request</span><span
449                                                 class="attribute-access-type">[RW]</span>
450                                 </div>
451
452                                 <div class="method-description">
453                                 
454                                 <p class="missing-docs">(Not documented)</p>
455                                 
456                                 </div>
457                         </div>
458                         
459                         <div id="agent-name-attribute-method" class="method-detail">
460                                 <a name="agent_name"></a>
461                                 
462                                 <a name="agent_name="></a>
463                                 
464                                 <div class="method-heading attribute-method-heading">
465                                         <span class="method-name">agent_name</span><span
466                                                 class="attribute-access-type">[RW]</span>
467                                 </div>
468
469                                 <div class="method-description">
470                                 
471                                 <p class="missing-docs">(Not documented)</p>
472                                 
473                                 </div>
474                         </div>
475                         
476                         <div id="logger-attribute-method" class="method-detail">
477                                 <a name="logger"></a>
478                                 
479                                 <div class="method-heading attribute-method-heading">
480                                         <span class="method-name">logger</span><span
481                                                 class="attribute-access-type">[R]</span>
482                                 </div>
483
484                                 <div class="method-description">
485                                 
486                                 <p class="missing-docs">(Not documented)</p>
487                                 
488                                 </div>
489                         </div>
490                         
491                         <div id="config-attribute-method" class="method-detail">
492                                 <a name="config"></a>
493                                 
494                                 <div class="method-heading attribute-method-heading">
495                                         <span class="method-name">config</span><span
496                                                 class="attribute-access-type">[R]</span>
497                                 </div>
498
499                                 <div class="method-description">
500                                 
501                                 <p class="missing-docs">(Not documented)</p>
502                                 
503                                 </div>
504                         </div>
505                         
506                         <div id="timeout-attribute-method" class="method-detail">
507                                 <a name="timeout"></a>
508                                 
509                                 <div class="method-heading attribute-method-heading">
510                                         <span class="method-name">timeout</span><span
511                                                 class="attribute-access-type">[R]</span>
512                                 </div>
513
514                                 <div class="method-description">
515                                 
516                                 <p class="missing-docs">(Not documented)</p>
517                                 
518                                 </div>
519                         </div>
520                         
521                         <div id="ddl-attribute-method" class="method-detail">
522                                 <a name="ddl"></a>
523                                 
524                                 <div class="method-heading attribute-method-heading">
525                                         <span class="method-name">ddl</span><span
526                                                 class="attribute-access-type">[R]</span>
527                                 </div>
528
529                                 <div class="method-description">
530                                 
531                                 <p class="missing-docs">(Not documented)</p>
532                                 
533                                 </div>
534                         </div>
535                         
536                         <div id="meta-attribute-method" class="method-detail">
537                                 <a name="meta"></a>
538                                 
539                                 <div class="method-heading attribute-method-heading">
540                                         <span class="method-name">meta</span><span
541                                                 class="attribute-access-type">[R]</span>
542                                 </div>
543
544                                 <div class="method-description">
545                                 
546                                 <p class="missing-docs">(Not documented)</p>
547                                 
548                                 </div>
549                         </div>
550                         
551                 </div>
552                 
553
554                 <!-- Methods -->
555                 
556                 <div id="public-class-method-details" class="method-section section">
557                         <h3 class="section-header">Public Class Methods</h3>
558
559                 
560                         <div id="actions-method" class="method-detail ">
561                                 <a name="M000405"></a>
562
563                                 <div class="method-heading">
564                                 
565                                         <span class="method-name">actions</span><span
566                                                 class="method-args">()</span>
567                                         <span class="method-click-advice">click to toggle source</span>
568                                 
569                                 </div>
570
571                                 <div class="method-description">
572                                         
573                                         <p>
574 Returns an array of actions this agent support
575 </p>
576                                         
577
578                                         
579                                         <div class="method-source-code"
580                                                 id="actions-source">
581 <pre>
582      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 157</span>
583 157:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">actions</span>
584 158:         <span class="ruby-identifier">public_instance_methods</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp re">/_action$/</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span>
585 159:           <span class="ruby-identifier">$1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">method</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/(.+)_action$/</span>
586 160:         <span class="ruby-keyword kw">end</span>
587 161:       <span class="ruby-keyword kw">end</span></pre>
588                                         </div>
589                                         
590                                 </div>
591
592                                 
593                         </div>
594
595                 
596                         <div id="activate--method" class="method-detail ">
597                                 <a name="M000404"></a>
598
599                                 <div class="method-heading">
600                                 
601                                         <span class="method-name">activate?</span><span
602                                                 class="method-args">()</span>
603                                         <span class="method-click-advice">click to toggle source</span>
604                                 
605                                 </div>
606
607                                 <div class="method-description">
608                                         
609                                         <p>
610 By default <a href="../RPC.html">RPC</a> <a
611 href="../Agents.html">Agents</a> support a toggle in the configuration that
612 can enable and disable them based on the agent name
613 </p>
614 <p>
615 Example an agent called Foo can have:
616 </p>
617 <p>
618 plugin.foo.activate_agent = false
619 </p>
620 <p>
621 and this will prevent the agent from loading on this particular machine.
622 </p>
623 <p>
624 <a href="../Agents.html">Agents</a> can use the <a
625 href="Agent.html#M000410">activate_when</a> helper to override this for
626 example:
627 </p>
628 <p>
629 <a href="Agent.html#M000410">activate_when</a> do
630 </p>
631 <pre>
632    File.exist?(&quot;/usr/bin/puppet&quot;)
633 </pre>
634 <p>
635 end
636 </p>
637                                         
638
639                                         
640                                         <div class="method-source-code"
641                                                 id="activate--source">
642 <pre>
643      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 142</span>
644 142:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">activate?</span>
645 143:         <span class="ruby-identifier">agent_name</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;::&quot;</span>).<span class="ruby-identifier">last</span>.<span class="ruby-identifier">downcase</span>
646 144: 
647 145:         <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC37</span>, <span class="ruby-value str">&quot;Starting default activation checks for the '%{agent}' agent&quot;</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">agent_name</span>)
648 146: 
649 147:         <span class="ruby-identifier">should_activate</span> = <span class="ruby-constant">Util</span>.<span class="ruby-identifier">str_to_bool</span>(<span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">pluginconf</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-node">&quot;#{agent_name}.activate_agent&quot;</span>, <span class="ruby-keyword kw">true</span>))
650 148: 
651 149:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">should_activate</span>
652 150:           <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC38</span>, <span class="ruby-value str">&quot;Found plugin configuration '%{agent}.activate_agent' with value '%{should_activate}'&quot;</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">agent_name</span>, <span class="ruby-identifier">:should_activate</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">should_activate</span>)
653 151:         <span class="ruby-keyword kw">end</span>
654 152: 
655 153:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">should_activate</span>
656 154:       <span class="ruby-keyword kw">end</span></pre>
657                                         </div>
658                                         
659                                 </div>
660
661                                 
662                         </div>
663
664                 
665                         <div id="new-method" class="method-detail ">
666                                 <a name="M000393"></a>
667
668                                 <div class="method-heading">
669                                 
670                                         <span class="method-name">new</span><span
671                                                 class="method-args">()</span>
672                                         <span class="method-click-advice">click to toggle source</span>
673                                 
674                                 </div>
675
676                                 <div class="method-description">
677                                         
678                                         <p class="missing-docs">(Not documented)</p>
679                                         
680
681                                         
682                                         <div class="method-source-code"
683                                                 id="new-source">
684 <pre>
685     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 40</span>
686 40:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
687 41:         <span class="ruby-ivar">@agent_name</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;::&quot;</span>).<span class="ruby-identifier">last</span>.<span class="ruby-identifier">downcase</span>
688 42: 
689 43:         <span class="ruby-identifier">load_ddl</span>
690 44: 
691 45:         <span class="ruby-ivar">@logger</span> = <span class="ruby-constant">Log</span>.<span class="ruby-identifier">instance</span>
692 46:         <span class="ruby-ivar">@config</span> = <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>
693 47: 
694 48:         <span class="ruby-comment cmt"># if we have a global authorization provider enable it</span>
695 49:         <span class="ruby-comment cmt"># plugins can still override it per plugin</span>
696 50:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">authorized_by</span>(<span class="ruby-ivar">@config</span>.<span class="ruby-identifier">rpcauthprovider</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">rpcauthorization</span>
697 51: 
698 52:         <span class="ruby-identifier">startup_hook</span>
699 53:       <span class="ruby-keyword kw">end</span></pre>
700                                         </div>
701                                         
702                                 </div>
703
704                                 
705                         </div>
706
707                 
708                 </div>
709         
710                 <div id="private-class-method-details" class="method-section section">
711                         <h3 class="section-header">Private Class Methods</h3>
712
713                 
714                         <div id="action-method" class="method-detail ">
715                                 <a name="M000411"></a>
716
717                                 <div class="method-heading">
718                                 
719                                         <span class="method-name">action</span><span
720                                                 class="method-args">(name, &block)</span>
721                                         <span class="method-click-advice">click to toggle source</span>
722                                 
723                                 </div>
724
725                                 <div class="method-description">
726                                         
727                                         <p>
728 Creates a new action with the block passed and sets some defaults
729 </p>
730 <p>
731 action &#8220;status&#8221; do
732 </p>
733 <pre>
734    # logic here to restart service
735 </pre>
736 <p>
737 end
738 </p>
739                                         
740
741                                         
742                                         <div class="method-source-code"
743                                                 id="action-source">
744 <pre>
745      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 260</span>
746 260:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">action</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
747 261:         <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Need to pass a body for the action&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block_given?</span>
748 262: 
749 263:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">module_eval</span> { <span class="ruby-identifier">define_method</span>(<span class="ruby-node">&quot;#{name}_action&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) }
750 264:       <span class="ruby-keyword kw">end</span></pre>
751                                         </div>
752                                         
753                                 </div>
754
755                                 
756                         </div>
757
758                 
759                         <div id="activate-when-method" class="method-detail ">
760                                 <a name="M000410"></a>
761
762                                 <div class="method-heading">
763                                 
764                                         <span class="method-name">activate_when</span><span
765                                                 class="method-args">(&block)</span>
766                                         <span class="method-click-advice">click to toggle source</span>
767                                 
768                                 </div>
769
770                                 <div class="method-description">
771                                         
772                                         <p>
773 Creates the needed activate? class in a manner similar to the other helpers
774 like action, <a href="Agent.html#M000412">authorized_by</a> etc
775 </p>
776 <p>
777 <a href="Agent.html#M000410">activate_when</a> do
778 </p>
779 <pre>
780    File.exist?(&quot;/usr/bin/puppet&quot;)
781 </pre>
782 <p>
783 end
784 </p>
785                                         
786
787                                         
788                                         <div class="method-source-code"
789                                                 id="activate-when-source">
790 <pre>
791      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 249</span>
792 249:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">activate_when</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
793 250:         (<span class="ruby-keyword kw">class</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">end</span>).<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword kw">do</span>
794 251:           <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">&quot;activate?&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
795 252:         <span class="ruby-keyword kw">end</span>
796 253:       <span class="ruby-keyword kw">end</span></pre>
797                                         </div>
798                                         
799                                 </div>
800
801                                 
802                         </div>
803
804                 
805                         <div id="authorized-by-method" class="method-detail ">
806                                 <a name="M000412"></a>
807
808                                 <div class="method-heading">
809                                 
810                                         <span class="method-name">authorized_by</span><span
811                                                 class="method-args">(plugin)</span>
812                                         <span class="method-click-advice">click to toggle source</span>
813                                 
814                                 </div>
815
816                                 <div class="method-description">
817                                         
818                                         <p>
819 Helper that creates a method on the class that will call your authorization
820 plugin. If your plugin raises an exception that will abort the request
821 </p>
822                                         
823
824                                         
825                                         <div class="method-source-code"
826                                                 id="authorized-by-source">
827 <pre>
828      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 268</span>
829 268:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">authorized_by</span>(<span class="ruby-identifier">plugin</span>)
830 269:         <span class="ruby-identifier">plugin</span> = <span class="ruby-identifier">plugin</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">capitalize</span>
831 270: 
832 271:         <span class="ruby-comment cmt"># turns foo_bar into FooBar</span>
833 272:         <span class="ruby-identifier">plugin</span> = <span class="ruby-identifier">plugin</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;_&quot;</span>).<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">capitalize</span>}.<span class="ruby-identifier">join</span>
834 273:         <span class="ruby-identifier">pluginname</span> = <span class="ruby-node">&quot;MCollective::Util::#{plugin}&quot;</span>
835 274: 
836 275:         <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">loadclass</span>(<span class="ruby-identifier">pluginname</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">MCollective</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">plugin</span>)
837 276: 
838 277:         <span class="ruby-identifier">class_eval</span>(<span class="ruby-node">&quot;
839 278:                       def authorization_hook(request)
840 279:                    #{pluginname}.authorize(request)
841 280:                       end
842 281:                    &quot;</span>)
843 282:       <span class="ruby-keyword kw">end</span></pre>
844                                         </div>
845                                         
846                                 </div>
847
848                                 
849                         </div>
850
851                 
852                         <div id="metadata-method" class="method-detail ">
853                                 <a name="M000407"></a>
854
855                                 <div class="method-heading">
856                                 
857                                         <span class="method-name">metadata</span><span
858                                                 class="method-args">(data)</span>
859                                         <span class="method-click-advice">click to toggle source</span>
860                                 
861                                 </div>
862
863                                 <div class="method-description">
864                                         
865                                         <p>
866 Registers meta data for the introspection hash
867 </p>
868                                         
869
870                                         
871                                         <div class="method-source-code"
872                                                 id="metadata-source">
873 <pre>
874      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 237</span>
875 237:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">metadata</span>(<span class="ruby-identifier">data</span>)
876 238:         <span class="ruby-identifier">agent</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">caller</span>.<span class="ruby-identifier">first</span>).<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;:&quot;</span>).<span class="ruby-identifier">first</span>
877 239: 
878 240:         <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC34</span>, <span class="ruby-value str">&quot;setting meta data in agents have been deprecated, DDL files are now being used for this information. Please update the '%{agent}' agent&quot;</span>, <span class="ruby-identifier">:warn</span>,  <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">agent</span>)
879 241:       <span class="ruby-keyword kw">end</span></pre>
880                                         </div>
881                                         
882                                 </div>
883
884                                 
885                         </div>
886
887                 
888                 </div>
889         
890                 <div id="public-instance-method-details" class="method-section section">
891                         <h3 class="section-header">Public Instance Methods</h3>
892
893                 
894                         <div id="handlemsg-method" class="method-detail ">
895                                 <a name="M000395"></a>
896
897                                 <div class="method-heading">
898                                 
899                                         <span class="method-name">handlemsg</span><span
900                                                 class="method-args">(msg, connection)</span>
901                                         <span class="method-click-advice">click to toggle source</span>
902                                 
903                                 </div>
904
905                                 <div class="method-description">
906                                         
907                                         <p class="missing-docs">(Not documented)</p>
908                                         
909
910                                         
911                                         <div class="method-source-code"
912                                                 id="handlemsg-source">
913 <pre>
914      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 64</span>
915  64:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handlemsg</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>)
916  65:         <span class="ruby-ivar">@request</span> = <span class="ruby-constant">RPC</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-ivar">@ddl</span>)
917  66:         <span class="ruby-ivar">@reply</span> = <span class="ruby-constant">RPC</span><span class="ruby-operator">::</span><span class="ruby-constant">Reply</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">action</span>, <span class="ruby-ivar">@ddl</span>)
918  67: 
919  68:         <span class="ruby-keyword kw">begin</span>
920  69:           <span class="ruby-comment cmt"># Incoming requests need to be validated against the DDL thus reusing</span>
921  70:           <span class="ruby-comment cmt"># all the work users put into creating DDLs and creating a consistent</span>
922  71:           <span class="ruby-comment cmt"># quality of input validation everywhere with the a simple once off</span>
923  72:           <span class="ruby-comment cmt"># investment of writing a DDL</span>
924  73:           <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">validate!</span>
925  74: 
926  75:           <span class="ruby-comment cmt"># Calls the authorization plugin if any is defined</span>
927  76:           <span class="ruby-comment cmt"># if this raises an exception we wil just skip processing this</span>
928  77:           <span class="ruby-comment cmt"># message</span>
929  78:           <span class="ruby-identifier">authorization_hook</span>(<span class="ruby-ivar">@request</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">&quot;authorization_hook&quot;</span>)
930  79: 
931  80:           <span class="ruby-comment cmt"># Audits the request, currently continues processing the message</span>
932  81:           <span class="ruby-comment cmt"># we should make this a configurable so that an audit failure means</span>
933  82:           <span class="ruby-comment cmt"># a message wont be processed by this node depending on config</span>
934  83:           <span class="ruby-identifier">audit_request</span>(<span class="ruby-ivar">@request</span>, <span class="ruby-identifier">connection</span>)
935  84: 
936  85:           <span class="ruby-identifier">before_processing_hook</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>)
937  86: 
938  87:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;#{@request.action}_action&quot;</span>)
939  88:             <span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{@request.action}_action&quot;</span>)
940  89:           <span class="ruby-keyword kw">else</span>
941  90:             <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC36</span>, <span class="ruby-value str">&quot;Unknown action '%{action}' for agent '%{agent}'&quot;</span>, <span class="ruby-identifier">:warn</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">action</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">agent</span>)
942  91:             <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownRPCAction</span>, <span class="ruby-node">&quot;Unknown action '#{@request.action}' for agent '#{@request.agent}'&quot;</span>
943  92:           <span class="ruby-keyword kw">end</span>
944  93:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">RPCAborted</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
945  94:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">1</span>
946  95: 
947  96:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">UnknownRPCAction</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
948  97:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">2</span>
949  98: 
950  99:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">MissingRPCData</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
951 100:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">3</span>
952 101: 
953 102:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">InvalidRPCData</span>, <span class="ruby-constant">DDLValidationError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
954 103:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">4</span>
955 104: 
956 105:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">UnknownRPCError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
957 106:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-value str">&quot;%s#%s failed: %s: %s&quot;</span> <span class="ruby-operator">%</span> [<span class="ruby-ivar">@agent_name</span>, <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">action</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>])
958 107:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n\t&quot;</span>))
959 108:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">5</span>
960 109: 
961 110:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
962 111:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-value str">&quot;%s#%s failed: %s: %s&quot;</span> <span class="ruby-operator">%</span> [<span class="ruby-ivar">@agent_name</span>, <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">action</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>])
963 112:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n\t&quot;</span>))
964 113:           <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value">5</span>
965 114: 
966 115:         <span class="ruby-keyword kw">end</span>
967 116: 
968 117:         <span class="ruby-identifier">after_processing_hook</span>
969 118: 
970 119:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">should_respond?</span>
971 120:           <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@reply</span>.<span class="ruby-identifier">to_hash</span>
972 121:         <span class="ruby-keyword kw">else</span>
973 122:           <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC35</span>, <span class="ruby-value str">&quot;Client did not request a response, surpressing reply&quot;</span>, <span class="ruby-identifier">:debug</span>)
974 123:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
975 124:         <span class="ruby-keyword kw">end</span>
976 125:       <span class="ruby-keyword kw">end</span></pre>
977                                         </div>
978                                         
979                                 </div>
980
981                                 
982                         </div>
983
984                 
985                         <div id="load-ddl-method" class="method-detail ">
986                                 <a name="M000394"></a>
987
988                                 <div class="method-heading">
989                                 
990                                         <span class="method-name">load_ddl</span><span
991                                                 class="method-args">()</span>
992                                         <span class="method-click-advice">click to toggle source</span>
993                                 
994                                 </div>
995
996                                 <div class="method-description">
997                                         
998                                         <p class="missing-docs">(Not documented)</p>
999                                         
1000
1001                                         
1002                                         <div class="method-source-code"
1003                                                 id="load-ddl-source">
1004 <pre>
1005     <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 55</span>
1006 55:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_ddl</span>
1007 56:         <span class="ruby-ivar">@ddl</span> = <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@agent_name</span>, <span class="ruby-identifier">:agent</span>)
1008 57:         <span class="ruby-ivar">@meta</span> = <span class="ruby-ivar">@ddl</span>.<span class="ruby-identifier">meta</span>
1009 58:         <span class="ruby-ivar">@timeout</span> = <span class="ruby-ivar">@meta</span>[<span class="ruby-identifier">:timeout</span>] <span class="ruby-operator">||</span> <span class="ruby-value">10</span>
1010 59: 
1011 60:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
1012 61:         <span class="ruby-constant">DDL</span>.<span class="ruby-identifier">validation_fail!</span>(<span class="ruby-identifier">:PLMC24</span>, <span class="ruby-value str">&quot;Failed to load DDL for the '%{agent}' agent, DDLs are required: %{error_class}: %{error}&quot;</span>, <span class="ruby-identifier">:error</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@agent_name</span>, <span class="ruby-identifier">:error_class</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">:error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span>)
1013 62:       <span class="ruby-keyword kw">end</span></pre>
1014                                         </div>
1015                                         
1016                                 </div>
1017
1018                                 
1019                         </div>
1020
1021                 
1022                 </div>
1023         
1024                 <div id="private-instance-method-details" class="method-section section">
1025                         <h3 class="section-header">Private Instance Methods</h3>
1026
1027                 
1028                         <div id="after-processing-hook-method" class="method-detail ">
1029                                 <a name="M000418"></a>
1030
1031                                 <div class="method-heading">
1032                                 
1033                                         <span class="method-name">after_processing_hook</span><span
1034                                                 class="method-args">()</span>
1035                                         <span class="method-click-advice">click to toggle source</span>
1036                                 
1037                                 </div>
1038
1039                                 <div class="method-description">
1040                                         
1041                                         <p>
1042 Called at the end of processing just before the response gets sent to the
1043 middleware.
1044 </p>
1045 <p>
1046 This gets run outside of the main exception handling block of the agent so
1047 you should handle any exceptions you could raise yourself. The reason it is
1048 outside of the block is so you&#8217;ll have access to even status codes
1049 set by the exception handlers. If you do raise an exception it will just be
1050 passed onto the runner and processing will fail.
1051 </p>
1052                                         
1053
1054                                         
1055                                         <div class="method-source-code"
1056                                                 id="after-processing-hook-source">
1057 <pre>
1058      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 356</span>
1059 356:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after_processing_hook</span>
1060 357:       <span class="ruby-keyword kw">end</span></pre>
1061                                         </div>
1062                                         
1063                                 </div>
1064
1065                                 
1066                         </div>
1067
1068                 
1069                         <div id="audit-request-method" class="method-detail ">
1070                                 <a name="M000419"></a>
1071
1072                                 <div class="method-heading">
1073                                 
1074                                         <span class="method-name">audit_request</span><span
1075                                                 class="method-args">(msg, connection)</span>
1076                                         <span class="method-click-advice">click to toggle source</span>
1077                                 
1078                                 </div>
1079
1080                                 <div class="method-description">
1081                                         
1082                                         <p>
1083 Gets called right after a request was received and calls audit plugins
1084 </p>
1085 <p>
1086 <a href="../Agents.html">Agents</a> can disable auditing by just overriding
1087 this method with a noop one this might be useful for agents that gets a lot
1088 of requests or simply if you do not care for the auditing in a specific
1089 agent.
1090 </p>
1091                                         
1092
1093                                         
1094                                         <div class="method-source-code"
1095                                                 id="audit-request-source">
1096 <pre>
1097      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 364</span>
1098 364:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">audit_request</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>)
1099 365:         <span class="ruby-constant">PluginManager</span>[<span class="ruby-value str">&quot;rpcaudit_plugin&quot;</span>].<span class="ruby-identifier">audit_request</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">rpcaudit</span>
1100 366:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
1101 367:         <span class="ruby-identifier">logexception</span>(<span class="ruby-identifier">:PLMC39</span>, <span class="ruby-value str">&quot;Audit failed with an error, processing the request will continue.&quot;</span>, <span class="ruby-identifier">:warn</span>, <span class="ruby-identifier">e</span>)
1102 368:       <span class="ruby-keyword kw">end</span></pre>
1103                                         </div>
1104                                         
1105                                 </div>
1106
1107                                 
1108                         </div>
1109
1110                 
1111                         <div id="before-processing-hook-method" class="method-detail ">
1112                                 <a name="M000417"></a>
1113
1114                                 <div class="method-heading">
1115                                 
1116                                         <span class="method-name">before_processing_hook</span><span
1117                                                 class="method-args">(msg, connection)</span>
1118                                         <span class="method-click-advice">click to toggle source</span>
1119                                 
1120                                 </div>
1121
1122                                 <div class="method-description">
1123                                         
1124                                         <p>
1125 Called just after a message was received from the middleware before it gets
1126 passed to the handlers. @request and @reply will already be set, the msg
1127 passed is the message as received from the normal mcollective runner and
1128 the connection is the actual connector.
1129 </p>
1130                                         
1131
1132                                         
1133                                         <div class="method-source-code"
1134                                                 id="before-processing-hook-source">
1135 <pre>
1136      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 345</span>
1137 345:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before_processing_hook</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">connection</span>)
1138 346:       <span class="ruby-keyword kw">end</span></pre>
1139                                         </div>
1140                                         
1141                                 </div>
1142
1143                                 
1144                         </div>
1145
1146                 
1147                         <div id="implemented-by-method" class="method-detail ">
1148                                 <a name="M000415"></a>
1149
1150                                 <div class="method-heading">
1151                                 
1152                                         <span class="method-name">implemented_by</span><span
1153                                                 class="method-args">(command, type=:json)</span>
1154                                         <span class="method-click-advice">click to toggle source</span>
1155                                 
1156                                 </div>
1157
1158                                 <div class="method-description">
1159                                         
1160                                         <p>
1161 handles external actions
1162 </p>
1163                                         
1164
1165                                         
1166                                         <div class="method-source-code"
1167                                                 id="implemented-by-source">
1168 <pre>
1169      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 313</span>
1170 313:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">implemented_by</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">type</span>=<span class="ruby-identifier">:json</span>)
1171 314:         <span class="ruby-identifier">runner</span> = <span class="ruby-constant">ActionRunner</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">request</span>, <span class="ruby-identifier">type</span>)
1172 315: 
1173 316:         <span class="ruby-identifier">res</span> = <span class="ruby-identifier">runner</span>.<span class="ruby-identifier">run</span>
1174 317: 
1175 318:         <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail!</span> <span class="ruby-node">&quot;Did not receive data from #{command}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:data</span>)
1176 319:         <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail!</span> <span class="ruby-node">&quot;Reply data from #{command} is not a Hash&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>[<span class="ruby-identifier">:data</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
1177 320: 
1178 321:         <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">data</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">res</span>[<span class="ruby-identifier">:data</span>])
1179 322: 
1180 323:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>[<span class="ruby-identifier">:exitstatus</span>] <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
1181 324:           <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail</span> <span class="ruby-node">&quot;Failed to run #{command}: #{res[:stderr]}&quot;</span>, <span class="ruby-identifier">res</span>[<span class="ruby-identifier">:exitstatus</span>]
1182 325:         <span class="ruby-keyword kw">end</span>
1183 326:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
1184 327:         <span class="ruby-constant">Log</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-node">&quot;Unhandled #{e.class} exception during #{request.agent}##{request.action}: #{e}&quot;</span>)
1185 328:         <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail!</span> <span class="ruby-node">&quot;Unexpected failure calling #{command}: #{e.class}: #{e}&quot;</span>
1186 329:       <span class="ruby-keyword kw">end</span></pre>
1187                                         </div>
1188                                         
1189                                 </div>
1190
1191                                 
1192                         </div>
1193
1194                 
1195                         <div id="run-method" class="method-detail ">
1196                                 <a name="M000406"></a>
1197
1198                                 <div class="method-heading">
1199                                 
1200                                         <span class="method-name">run</span><span
1201                                                 class="method-args">(command, options={})</span>
1202                                         <span class="method-click-advice">click to toggle source</span>
1203                                 
1204                                 </div>
1205
1206                                 <div class="method-description">
1207                                         
1208                                         <p>
1209 Runs a command via the MC::Shell wrapper, options are as per MC::Shell
1210 </p>
1211 <p>
1212 The simplest use is:
1213 </p>
1214 <pre>
1215   out = &quot;&quot;
1216   err = &quot;&quot;
1217   status = run(&quot;echo 1&quot;, :stdout =&gt; out, :stderr =&gt; err)
1218
1219   reply[:out] = out
1220   reply[:error] = err
1221   reply[:exitstatus] = status
1222 </pre>
1223 <p>
1224 This can be simplified as:
1225 </p>
1226 <pre>
1227   reply[:exitstatus] = run(&quot;echo 1&quot;, :stdout =&gt; :out, :stderr =&gt; :error)
1228 </pre>
1229 <p>
1230 You can set a command specific environment and cwd:
1231 </p>
1232 <pre>
1233   run(&quot;echo 1&quot;, :cwd =&gt; &quot;/tmp&quot;, :environment =&gt; {&quot;FOO&quot; =&gt; &quot;BAR&quot;})
1234 </pre>
1235 <p>
1236 This will run &#8216;echo 1&#8217; from /tmp with FOO=BAR in addition to a
1237 setting forcing LC_ALL = C. To prevent LC_ALL from being set either set it
1238 specifically or:
1239 </p>
1240 <pre>
1241   run(&quot;echo 1&quot;, :cwd =&gt; &quot;/tmp&quot;, :environment =&gt; nil)
1242 </pre>
1243 <p>
1244 Exceptions here will be handled by the usual agent exception handler or any
1245 specific one you create, if you dont it will just fall through and be sent
1246 to the client.
1247 </p>
1248 <p>
1249 If the shell handler fails to return a Process::Status instance for exit
1250 status this method will return -1 as the exit status
1251 </p>
1252                                         
1253
1254                                         
1255                                         <div class="method-source-code"
1256                                                 id="run-source">
1257 <pre>
1258      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 195</span>
1259 195:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">options</span>={})
1260 196:         <span class="ruby-identifier">shellopts</span> = {}
1261 197: 
1262 198:         <span class="ruby-comment cmt"># force stderr and stdout to be strings as the library</span>
1263 199:         <span class="ruby-comment cmt"># will append data to them if given using the &lt;&lt; method.</span>
1264 200:         <span class="ruby-comment cmt">#</span>
1265 201:         <span class="ruby-comment cmt"># if the data pased to :stderr or :stdin is a Symbol</span>
1266 202:         <span class="ruby-comment cmt"># add that into the reply hash with that Symbol</span>
1267 203:         [<span class="ruby-identifier">:stderr</span>, <span class="ruby-identifier">:stdout</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
1268 204:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>)
1269 205:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
1270 206:               <span class="ruby-identifier">reply</span>[ <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>] ] = <span class="ruby-value str">&quot;&quot;</span>
1271 207:               <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">reply</span>[ <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>] ]
1272 208:             <span class="ruby-keyword kw">else</span>
1273 209:               <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">&quot;&lt;&lt;&quot;</span>)
1274 210:                 <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>]
1275 211:               <span class="ruby-keyword kw">else</span>
1276 212:                 <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">fail!</span> <span class="ruby-node">&quot;#{k} should support &lt;&lt; while calling run(#{command})&quot;</span>
1277 213:               <span class="ruby-keyword kw">end</span>
1278 214:             <span class="ruby-keyword kw">end</span>
1279 215:           <span class="ruby-keyword kw">end</span>
1280 216:         <span class="ruby-keyword kw">end</span>
1281 217: 
1282 218:         [<span class="ruby-identifier">:stdin</span>, <span class="ruby-identifier">:cwd</span>, <span class="ruby-identifier">:environment</span>, <span class="ruby-identifier">:timeout</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
1283 219:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>)
1284 220:             <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">k</span>]
1285 221:           <span class="ruby-keyword kw">end</span>
1286 222:         <span class="ruby-keyword kw">end</span>
1287 223: 
1288 224:         <span class="ruby-identifier">shell</span> = <span class="ruby-constant">Shell</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">shellopts</span>)
1289 225: 
1290 226:         <span class="ruby-identifier">shell</span>.<span class="ruby-identifier">runcommand</span>
1291 227: 
1292 228:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:chomp</span>]
1293 229:           <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">:stdout</span>].<span class="ruby-identifier">chomp!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">:stdout</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
1294 230:           <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">:stderr</span>].<span class="ruby-identifier">chomp!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">shellopts</span>[<span class="ruby-identifier">:stderr</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
1295 231:         <span class="ruby-keyword kw">end</span>
1296 232: 
1297 233:         <span class="ruby-identifier">shell</span>.<span class="ruby-identifier">status</span>.<span class="ruby-identifier">exitstatus</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-value">-1</span>
1298 234:       <span class="ruby-keyword kw">end</span></pre>
1299                                         </div>
1300                                         
1301                                 </div>
1302
1303                                 
1304                         </div>
1305
1306                 
1307                         <div id="shellescape-method" class="method-detail ">
1308                                 <a name="M000414"></a>
1309
1310                                 <div class="method-heading">
1311                                 
1312                                         <span class="method-name">shellescape</span><span
1313                                                 class="method-args">(str)</span>
1314                                         <span class="method-click-advice">click to toggle source</span>
1315                                 
1316                                 </div>
1317
1318                                 <div class="method-description">
1319                                         
1320                                         <p>
1321 convenience wrapper around <a
1322 href="../Util.html#M000311">Util#shellescape</a>
1323 </p>
1324                                         
1325
1326                                         
1327                                         <div class="method-source-code"
1328                                                 id="shellescape-source">
1329 <pre>
1330      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 308</span>
1331 308:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shellescape</span>(<span class="ruby-identifier">str</span>)
1332 309:         <span class="ruby-constant">Util</span>.<span class="ruby-identifier">shellescape</span>(<span class="ruby-identifier">str</span>)
1333 310:       <span class="ruby-keyword kw">end</span></pre>
1334                                         </div>
1335                                         
1336                                 </div>
1337
1338                                 
1339                         </div>
1340
1341                 
1342                         <div id="startup-hook-method" class="method-detail ">
1343                                 <a name="M000416"></a>
1344
1345                                 <div class="method-heading">
1346                                 
1347                                         <span class="method-name">startup_hook</span><span
1348                                                 class="method-args">()</span>
1349                                         <span class="method-click-advice">click to toggle source</span>
1350                                 
1351                                 </div>
1352
1353                                 <div class="method-description">
1354                                         
1355                                         <p>
1356 Called at the end of the <a href="Agent.html">RPC::Agent</a> standard
1357 initialize method use this to adjust meta parameters, timeouts and any
1358 setup you need to do.
1359 </p>
1360 <p>
1361 This will not be called right when the daemon starts up, we use lazy
1362 loading and initialization so it will only be called the first time a
1363 request for this agent arrives.
1364 </p>
1365                                         
1366
1367                                         
1368                                         <div class="method-source-code"
1369                                                 id="startup-hook-source">
1370 <pre>
1371      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 338</span>
1372 338:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">startup_hook</span>
1373 339:       <span class="ruby-keyword kw">end</span></pre>
1374                                         </div>
1375                                         
1376                                 </div>
1377
1378                                 
1379                         </div>
1380
1381                 
1382                         <div id="validate-method" class="method-detail ">
1383                                 <a name="M000413"></a>
1384
1385                                 <div class="method-heading">
1386                                 
1387                                         <span class="method-name">validate</span><span
1388                                                 class="method-args">(key, validation)</span>
1389                                         <span class="method-click-advice">click to toggle source</span>
1390                                 
1391                                 </div>
1392
1393                                 <div class="method-description">
1394                                         
1395                                         <p>
1396 Validates a data member, if validation is a regex then it will try to match
1397 it else it supports testing object types only:
1398 </p>
1399 <p>
1400 validate :msg, <a href="../../String.html">String</a> validate :msg,
1401 /^[w\s]+$/
1402 </p>
1403 <p>
1404 There are also some special helper validators:
1405 </p>
1406 <p>
1407 validate :command, :shellsafe validate :command, :ipv6address validate
1408 :command, :ipv4address validate :command, :boolean validate :command,
1409 [&#8220;start&#8221;, &#8220;stop&#8221;]
1410 </p>
1411 <p>
1412 It will raise appropriate exceptions that the <a href="../RPC.html">RPC</a>
1413 system understand
1414 </p>
1415                                         
1416
1417                                         
1418                                         <div class="method-source-code"
1419                                                 id="validate-source">
1420 <pre>
1421      <span class="ruby-comment cmt"># File lib/mcollective/rpc/agent.rb, line 299</span>
1422 299:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">validation</span>)
1423 300:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">MissingRPCData</span>, <span class="ruby-node">&quot;please supply a #{key} argument&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>)
1424 301: 
1425 302:         <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">validate</span>(<span class="ruby-ivar">@request</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">validation</span>)
1426 303:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ValidatorError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
1427 304:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidRPCData</span>, <span class="ruby-value str">&quot;Input %s did not pass validation: %s&quot;</span> <span class="ruby-operator">%</span> [ <span class="ruby-identifier">key</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span> ]
1428 305:       <span class="ruby-keyword kw">end</span></pre>
1429                                         </div>
1430                                         
1431                                 </div>
1432
1433                                 
1434                         </div>
1435
1436                 
1437                 </div>
1438         
1439
1440         </div>
1441
1442
1443         <div id="rdoc-debugging-section-dump" class="debugging-section">
1444         
1445                 <p>Disabled; run with --debug to generate this.</p>
1446         
1447         </div>
1448
1449         <div id="validator-badges">
1450                 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
1451                 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
1452                         Rdoc Generator</a> 1.1.6</small>.</p>
1453         </div>
1454
1455 </body>
1456 </html>
1457