Update version according to OSCI-883
[packages/precise/mcollective.git] / doc / MCollective / RPC / ActionRunner.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::ActionRunner</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/actionrunner_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
32                                                         class="thickbox" title="lib/mcollective/rpc/actionrunner.rb">lib/mcollective/rpc/actionrunner.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="#M000372">::new</a></li>
63                                         
64                                         <li><a href="#M000379">#canrun?</a></li>
65                                         
66                                         <li><a href="#M000376">#load_json_results</a></li>
67                                         
68                                         <li><a href="#M000375">#load_results</a></li>
69                                         
70                                         <li><a href="#M000382">#path_to_command</a></li>
71                                         
72                                         <li><a href="#M000373">#run</a></li>
73                                         
74                                         <li><a href="#M000378">#save_json_request</a></li>
75                                         
76                                         <li><a href="#M000377">#saverequest</a></li>
77                                         
78                                         <li><a href="#M000374">#shell</a></li>
79                                         
80                                         <li><a href="#M000381">#tempfile</a></li>
81                                         
82                                         <li><a href="#M000380">#to_s</a></li>
83                                         
84                                 </ul>
85                         </div>
86                         
87
88                         <!-- Included Modules -->
89                         
90                 </div>
91
92                 <div id="project-metadata">
93                         
94                         
95                         <div id="fileindex-section" class="section project-section">
96                                 <h3 class="section-header">Files</h3>
97                                 <ul>
98                                 
99                                         <li class="file"><a href="../../COPYING.html">COPYING</a></li>
100                                 
101                                         <li class="file"><a href="../../Gemfile.html">Gemfile</a></li>
102                                 
103                                         <li class="file"><a href="../../README.html">README</a></li>
104                                 
105                                         <li class="file"><a href="../../Rakefile.html">Rakefile</a></li>
106                                 
107                                         <li class="file"><a href="../../etc/client_cfg_dist.html">client.cfg.dist</a></li>
108                                 
109                                         <li class="file"><a href="../../etc/data-help_erb.html">data-help.erb</a></li>
110                                 
111                                         <li class="file"><a href="../../etc/discovery-help_erb.html">discovery-help.erb</a></li>
112                                 
113                                         <li class="file"><a href="../../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
114                                 
115                                         <li class="file"><a href="../../etc/metadata-help_erb.html">metadata-help.erb</a></li>
116                                 
117                                         <li class="file"><a href="../../etc/msg-help_erb.html">msg-help.erb</a></li>
118                                 
119                                         <li class="file"><a href="../../etc/rpc-help_erb.html">rpc-help.erb</a></li>
120                                 
121                                         <li class="file"><a href="../../etc/server_cfg_dist.html">server.cfg.dist</a></li>
122                                 
123                                         <li class="file"><a href="../../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
124                                 
125                                         <li class="file"><a href="../../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
126                                 
127                                         <li class="file"><a href="../../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
128                                 
129                                         <li class="file"><a href="../../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
130                                 
131                                         <li class="file"><a href="../../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
132                                 
133                                         <li class="file"><a href="../../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
134                                 
135                                         <li class="file"><a href="../../lib/mcollective/locales/en_yml.html">en.yml</a></li>
136                                 
137                                         <li class="file"><a href="../../mcollective_init.html">mcollective.init</a></li>
138                                 
139                                 </ul>
140                         </div>
141                         
142
143                         <div id="classindex-section" class="section project-section">
144                                 <h3 class="section-header">Class Index
145                                         <span class="search-toggle"><img src="../../images/find.png"
146                                                 height="16" width="16" alt="[+]"
147                                                 title="show/hide quicksearch" /></span></h3>
148                                 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
149                                 <fieldset>
150                                         <legend>Quicksearch</legend>
151                                         <input type="text" name="quicksearch" value=""
152                                                 class="quicksearch-field" />
153                                 </fieldset>
154                                 </form>
155
156                                 <ul class="link-list">
157                                 
158                                         <li><a href="../../MCollective.html">MCollective</a></li>
159                                 
160                                         <li><a href="../../MCollective/Agent.html">MCollective::Agent</a></li>
161                                 
162                                         <li><a href="../../MCollective/Agents.html">MCollective::Agents</a></li>
163                                 
164                                         <li><a href="../../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
165                                 
166                                         <li><a href="../../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
167                                 
168                                         <li><a href="../../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
169                                 
170                                         <li><a href="../../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
171                                 
172                                         <li><a href="../../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
173                                 
174                                         <li><a href="../../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
175                                 
176                                         <li><a href="../../MCollective/Application.html">MCollective::Application</a></li>
177                                 
178                                         <li><a href="../../MCollective/Applications.html">MCollective::Applications</a></li>
179                                 
180                                         <li><a href="../../MCollective/Cache.html">MCollective::Cache</a></li>
181                                 
182                                         <li><a href="../../MCollective/Client.html">MCollective::Client</a></li>
183                                 
184                                         <li><a href="../../MCollective/CodedError.html">MCollective::CodedError</a></li>
185                                 
186                                         <li><a href="../../MCollective/Config.html">MCollective::Config</a></li>
187                                 
188                                         <li><a href="../../MCollective/Connector.html">MCollective::Connector</a></li>
189                                 
190                                         <li><a href="../../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
191                                 
192                                         <li><a href="../../MCollective/DDL.html">MCollective::DDL</a></li>
193                                 
194                                         <li><a href="../../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
195                                 
196                                         <li><a href="../../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
197                                 
198                                         <li><a href="../../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
199                                 
200                                         <li><a href="../../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
201                                 
202                                         <li><a href="../../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
203                                 
204                                         <li><a href="../../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
205                                 
206                                         <li><a href="../../MCollective/Data.html">MCollective::Data</a></li>
207                                 
208                                         <li><a href="../../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
209                                 
210                                         <li><a href="../../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
211                                 
212                                         <li><a href="../../MCollective/Discovery.html">MCollective::Discovery</a></li>
213                                 
214                                         <li><a href="../../MCollective/Facts.html">MCollective::Facts</a></li>
215                                 
216                                         <li><a href="../../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
217                                 
218                                         <li><a href="../../MCollective/Generators.html">MCollective::Generators</a></li>
219                                 
220                                         <li><a href="../../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
221                                 
222                                         <li><a href="../../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
223                                 
224                                         <li><a href="../../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
225                                 
226                                         <li><a href="../../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
227                                 
228                                         <li><a href="../../MCollective/Log.html">MCollective::Log</a></li>
229                                 
230                                         <li><a href="../../MCollective/Logger.html">MCollective::Logger</a></li>
231                                 
232                                         <li><a href="../../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
233                                 
234                                         <li><a href="../../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
235                                 
236                                         <li><a href="../../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
237                                 
238                                         <li><a href="../../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
239                                 
240                                         <li><a href="../../MCollective/Matcher.html">MCollective::Matcher</a></li>
241                                 
242                                         <li><a href="../../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
243                                 
244                                         <li><a href="../../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
245                                 
246                                         <li><a href="../../MCollective/Message.html">MCollective::Message</a></li>
247                                 
248                                         <li><a href="../../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
249                                 
250                                         <li><a href="../../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
251                                 
252                                         <li><a href="../../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
253                                 
254                                         <li><a href="../../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
255                                 
256                                         <li><a href="../../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
257                                 
258                                         <li><a href="../../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
259                                 
260                                         <li><a href="../../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
261                                 
262                                         <li><a href="../../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
263                                 
264                                         <li><a href="../../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
265                                 
266                                         <li><a href="../../MCollective/RPC.html">MCollective::RPC</a></li>
267                                 
268                                         <li><a href="../../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
269                                 
270                                         <li><a href="../../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
271                                 
272                                         <li><a href="../../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
273                                 
274                                         <li><a href="../../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
275                                 
276                                         <li><a href="../../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
277                                 
278                                         <li><a href="../../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
279                                 
280                                         <li><a href="../../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
281                                 
282                                         <li><a href="../../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
283                                 
284                                         <li><a href="../../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
285                                 
286                                         <li><a href="../../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
287                                 
288                                         <li><a href="../../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
289                                 
290                                         <li><a href="../../MCollective/RPCError.html">MCollective::RPCError</a></li>
291                                 
292                                         <li><a href="../../MCollective/Registration.html">MCollective::Registration</a></li>
293                                 
294                                         <li><a href="../../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
295                                 
296                                         <li><a href="../../MCollective/Runner.html">MCollective::Runner</a></li>
297                                 
298                                         <li><a href="../../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
299                                 
300                                         <li><a href="../../MCollective/SSL.html">MCollective::SSL</a></li>
301                                 
302                                         <li><a href="../../MCollective/Security.html">MCollective::Security</a></li>
303                                 
304                                         <li><a href="../../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
305                                 
306                                         <li><a href="../../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
307                                 
308                                         <li><a href="../../MCollective/Shell.html">MCollective::Shell</a></li>
309                                 
310                                         <li><a href="../../MCollective/Translatable.html">MCollective::Translatable</a></li>
311                                 
312                                         <li><a href="../../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
313                                 
314                                         <li><a href="../../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
315                                 
316                                         <li><a href="../../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
317                                 
318                                         <li><a href="../../MCollective/Util.html">MCollective::Util</a></li>
319                                 
320                                         <li><a href="../../MCollective/Validator.html">MCollective::Validator</a></li>
321                                 
322                                         <li><a href="../../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
323                                 
324                                         <li><a href="../../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
325                                 
326                                         <li><a href="../../Array.html">Array</a></li>
327                                 
328                                         <li><a href="../../Dir.html">Dir</a></li>
329                                 
330                                         <li><a href="../../Object.html">Object</a></li>
331                                 
332                                         <li><a href="../../String.html">String</a></li>
333                                 
334                                         <li><a href="../../Symbol.html">Symbol</a></li>
335                                 
336                                 </ul>
337                                 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
338                         </div>
339
340                         
341                 </div>
342         </div>
343
344         <div id="documentation">
345                 <h1 class="class">MCollective::RPC::ActionRunner</h1>
346
347                 <div id="description">
348                         <p>
349 A helper used by <a href="Agent.html#M000415">RPC::Agent#implemented_by</a>
350 to delegate an action to an external script. At present only JSON based
351 serialization is supported in future ones based on key=val pairs etc will
352 be added
353 </p>
354 <p>
355 It serializes the request object into an input file and creates an empty
356 output file. It then calls the external command reading the output file at
357 the end.
358 </p>
359 <p>
360 any STDERR gets logged at error level and any STDOUT gets logged at info
361 level.
362 </p>
363 <p>
364 It will interpret the exit code from the application the same way <a
365 href="Reply.html#M000386">RPC::Reply#fail!</a> and fail handles their codes
366 creating a consistent interface, the message part of the fail message will
367 come from STDERR
368 </p>
369 <p>
370 Generally externals should just exit with code 1 on failure and print to
371 STDERR, this is exactly what Perl die() does and translates perfectly to
372 our model
373 </p>
374 <p>
375 It uses the <a href="../Shell.html">MCollective::Shell</a> wrapper to call
376 the external application
377 </p>
378
379                 </div>
380
381                 <!-- Constants -->
382                 
383
384                 <!-- Attributes -->
385                 
386                 <div id="attribute-method-details" class="method-section section">
387                         <h3 class="section-header">Attributes</h3>
388
389                         
390                         <div id="command-attribute-method" class="method-detail">
391                                 <a name="command"></a>
392                                 
393                                 <div class="method-heading attribute-method-heading">
394                                         <span class="method-name">command</span><span
395                                                 class="attribute-access-type">[R]</span>
396                                 </div>
397
398                                 <div class="method-description">
399                                 
400                                 <p class="missing-docs">(Not documented)</p>
401                                 
402                                 </div>
403                         </div>
404                         
405                         <div id="agent-attribute-method" class="method-detail">
406                                 <a name="agent"></a>
407                                 
408                                 <div class="method-heading attribute-method-heading">
409                                         <span class="method-name">agent</span><span
410                                                 class="attribute-access-type">[R]</span>
411                                 </div>
412
413                                 <div class="method-description">
414                                 
415                                 <p class="missing-docs">(Not documented)</p>
416                                 
417                                 </div>
418                         </div>
419                         
420                         <div id="action-attribute-method" class="method-detail">
421                                 <a name="action"></a>
422                                 
423                                 <div class="method-heading attribute-method-heading">
424                                         <span class="method-name">action</span><span
425                                                 class="attribute-access-type">[R]</span>
426                                 </div>
427
428                                 <div class="method-description">
429                                 
430                                 <p class="missing-docs">(Not documented)</p>
431                                 
432                                 </div>
433                         </div>
434                         
435                         <div id="format-attribute-method" class="method-detail">
436                                 <a name="format"></a>
437                                 
438                                 <div class="method-heading attribute-method-heading">
439                                         <span class="method-name">format</span><span
440                                                 class="attribute-access-type">[R]</span>
441                                 </div>
442
443                                 <div class="method-description">
444                                 
445                                 <p class="missing-docs">(Not documented)</p>
446                                 
447                                 </div>
448                         </div>
449                         
450                         <div id="stdout-attribute-method" class="method-detail">
451                                 <a name="stdout"></a>
452                                 
453                                 <div class="method-heading attribute-method-heading">
454                                         <span class="method-name">stdout</span><span
455                                                 class="attribute-access-type">[R]</span>
456                                 </div>
457
458                                 <div class="method-description">
459                                 
460                                 <p class="missing-docs">(Not documented)</p>
461                                 
462                                 </div>
463                         </div>
464                         
465                         <div id="stderr-attribute-method" class="method-detail">
466                                 <a name="stderr"></a>
467                                 
468                                 <div class="method-heading attribute-method-heading">
469                                         <span class="method-name">stderr</span><span
470                                                 class="attribute-access-type">[R]</span>
471                                 </div>
472
473                                 <div class="method-description">
474                                 
475                                 <p class="missing-docs">(Not documented)</p>
476                                 
477                                 </div>
478                         </div>
479                         
480                         <div id="request-attribute-method" class="method-detail">
481                                 <a name="request"></a>
482                                 
483                                 <div class="method-heading attribute-method-heading">
484                                         <span class="method-name">request</span><span
485                                                 class="attribute-access-type">[R]</span>
486                                 </div>
487
488                                 <div class="method-description">
489                                 
490                                 <p class="missing-docs">(Not documented)</p>
491                                 
492                                 </div>
493                         </div>
494                         
495                 </div>
496                 
497
498                 <!-- Methods -->
499                 
500                 <div id="public-class-method-details" class="method-section section">
501                         <h3 class="section-header">Public Class Methods</h3>
502
503                 
504                         <div id="new-method" class="method-detail ">
505                                 <a name="M000372"></a>
506
507                                 <div class="method-heading">
508                                 
509                                         <span class="method-name">new</span><span
510                                                 class="method-args">(command, request, format=:json)</span>
511                                         <span class="method-click-advice">click to toggle source</span>
512                                 
513                                 </div>
514
515                                 <div class="method-description">
516                                         
517                                         <p class="missing-docs">(Not documented)</p>
518                                         
519
520                                         
521                                         <div class="method-source-code"
522                                                 id="new-source">
523 <pre>
524     <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 26</span>
525 26:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">request</span>, <span class="ruby-identifier">format</span>=<span class="ruby-identifier">:json</span>)
526 27:         <span class="ruby-ivar">@agent</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">agent</span>
527 28:         <span class="ruby-ivar">@action</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">action</span>
528 29:         <span class="ruby-ivar">@format</span> = <span class="ruby-identifier">format</span>
529 30:         <span class="ruby-ivar">@request</span> = <span class="ruby-identifier">request</span>
530 31:         <span class="ruby-ivar">@command</span> = <span class="ruby-identifier">path_to_command</span>(<span class="ruby-identifier">command</span>)
531 32:         <span class="ruby-ivar">@stdout</span> = <span class="ruby-value str">&quot;&quot;</span>
532 33:         <span class="ruby-ivar">@stderr</span> = <span class="ruby-value str">&quot;&quot;</span>
533 34:       <span class="ruby-keyword kw">end</span></pre>
534                                         </div>
535                                         
536                                 </div>
537
538                                 
539                         </div>
540
541                 
542                 </div>
543         
544                 <div id="public-instance-method-details" class="method-section section">
545                         <h3 class="section-header">Public Instance Methods</h3>
546
547                 
548                         <div id="canrun--method" class="method-detail ">
549                                 <a name="M000379"></a>
550
551                                 <div class="method-heading">
552                                 
553                                         <span class="method-name">canrun?</span><span
554                                                 class="method-args">(command)</span>
555                                         <span class="method-click-advice">click to toggle source</span>
556                                 
557                                 </div>
558
559                                 <div class="method-description">
560                                         
561                                         <p class="missing-docs">(Not documented)</p>
562                                         
563
564                                         
565                                         <div class="method-source-code"
566                                                 id="canrun--source">
567 <pre>
568      <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 117</span>
569 117:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">canrun?</span>(<span class="ruby-identifier">command</span>)
570 118:         <span class="ruby-constant">File</span>.<span class="ruby-identifier">executable?</span>(<span class="ruby-identifier">command</span>)
571 119:       <span class="ruby-keyword kw">end</span></pre>
572                                         </div>
573                                         
574                                 </div>
575
576                                 
577                         </div>
578
579                 
580                         <div id="load-json-results-method" class="method-detail ">
581                                 <a name="M000376"></a>
582
583                                 <div class="method-heading">
584                                 
585                                         <span class="method-name">load_json_results</span><span
586                                                 class="method-args">(file)</span>
587                                         <span class="method-click-advice">click to toggle source</span>
588                                 
589                                 </div>
590
591                                 <div class="method-description">
592                                         
593                                         <p class="missing-docs">(Not documented)</p>
594                                         
595
596                                         
597                                         <div class="method-source-code"
598                                                 id="load-json-results-source">
599 <pre>
600     <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 91</span>
601 91:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_json_results</span>(<span class="ruby-identifier">file</span>)
602 92:         <span class="ruby-keyword kw">return</span> {} <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">readable?</span>(<span class="ruby-identifier">file</span>)
603 93: 
604 94:         <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">file</span>)) <span class="ruby-operator">||</span> {}
605 95:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">JSON</span><span class="ruby-operator">::</span><span class="ruby-constant">ParserError</span>
606 96:         {}
607 97:       <span class="ruby-keyword kw">end</span></pre>
608                                         </div>
609                                         
610                                 </div>
611
612                                 
613                         </div>
614
615                 
616                         <div id="load-results-method" class="method-detail ">
617                                 <a name="M000375"></a>
618
619                                 <div class="method-heading">
620                                 
621                                         <span class="method-name">load_results</span><span
622                                                 class="method-args">(file)</span>
623                                         <span class="method-click-advice">click to toggle source</span>
624                                 
625                                 </div>
626
627                                 <div class="method-description">
628                                         
629                                         <p class="missing-docs">(Not documented)</p>
630                                         
631
632                                         
633                                         <div class="method-source-code"
634                                                 id="load-results-source">
635 <pre>
636     <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 73</span>
637 73:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_results</span>(<span class="ruby-identifier">file</span>)
638 74:         <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Attempting to load results in #{format} format from #{file}&quot;</span>)
639 75: 
640 76:         <span class="ruby-identifier">data</span> = {}
641 77: 
642 78:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;load_#{format}_results&quot;</span>)
643 79:           <span class="ruby-identifier">tempdata</span> = <span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;load_#{format}_results&quot;</span>, <span class="ruby-identifier">file</span>)
644 80: 
645 81:           <span class="ruby-identifier">tempdata</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
646 82:             <span class="ruby-identifier">data</span>[<span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">v</span>
647 83:           <span class="ruby-keyword kw">end</span>
648 84:         <span class="ruby-keyword kw">end</span>
649 85: 
650 86:         <span class="ruby-identifier">data</span>
651 87:       <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>
652 88:         {}
653 89:       <span class="ruby-keyword kw">end</span></pre>
654                                         </div>
655                                         
656                                 </div>
657
658                                 
659                         </div>
660
661                 
662                         <div id="path-to-command-method" class="method-detail ">
663                                 <a name="M000382"></a>
664
665                                 <div class="method-heading">
666                                 
667                                         <span class="method-name">path_to_command</span><span
668                                                 class="method-args">(command)</span>
669                                         <span class="method-click-advice">click to toggle source</span>
670                                 
671                                 </div>
672
673                                 <div class="method-description">
674                                         
675                                         <p class="missing-docs">(Not documented)</p>
676                                         
677
678                                         
679                                         <div class="method-source-code"
680                                                 id="path-to-command-source">
681 <pre>
682      <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 129</span>
683 129:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">path_to_command</span>(<span class="ruby-identifier">command</span>)
684 130:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">SEPARATOR</span>
685 131:           <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">libdir</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">libdir</span><span class="ruby-operator">|</span>
686 132:             <span class="ruby-identifier">command_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">libdir</span>, <span class="ruby-value str">&quot;agent&quot;</span>, <span class="ruby-identifier">agent</span>, <span class="ruby-identifier">command</span>)
687 133: 
688 134:             <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">command_file</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">command_file</span>)
689 135:           <span class="ruby-keyword kw">end</span>
690 136:         <span class="ruby-keyword kw">end</span>
691 137: 
692 138:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">command</span>
693 139:       <span class="ruby-keyword kw">end</span></pre>
694                                         </div>
695                                         
696                                 </div>
697
698                                 
699                         </div>
700
701                 
702                         <div id="run-method" class="method-detail ">
703                                 <a name="M000373"></a>
704
705                                 <div class="method-heading">
706                                 
707                                         <span class="method-name">run</span><span
708                                                 class="method-args">()</span>
709                                         <span class="method-click-advice">click to toggle source</span>
710                                 
711                                 </div>
712
713                                 <div class="method-description">
714                                         
715                                         <p class="missing-docs">(Not documented)</p>
716                                         
717
718                                         
719                                         <div class="method-source-code"
720                                                 id="run-source">
721 <pre>
722     <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 36</span>
723 36:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>
724 37:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">canrun?</span>(<span class="ruby-identifier">command</span>)
725 38:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-node">&quot;Cannot run #{to_s}&quot;</span>)
726 39:           <span class="ruby-identifier">raise</span> <span class="ruby-constant">RPCAborted</span>, <span class="ruby-node">&quot;Cannot execute #{to_s}&quot;</span>
727 40:         <span class="ruby-keyword kw">end</span>
728 41: 
729 42:         <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Running #{to_s}&quot;</span>)
730 43: 
731 44:         <span class="ruby-identifier">request_file</span> = <span class="ruby-identifier">saverequest</span>(<span class="ruby-identifier">request</span>)
732 45:         <span class="ruby-identifier">reply_file</span> = <span class="ruby-identifier">tempfile</span>(<span class="ruby-value str">&quot;reply&quot;</span>)
733 46:         <span class="ruby-identifier">reply_file</span>.<span class="ruby-identifier">close</span>
734 47: 
735 48:         <span class="ruby-identifier">runner</span> = <span class="ruby-identifier">shell</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">request_file</span>.<span class="ruby-identifier">path</span>, <span class="ruby-identifier">reply_file</span>.<span class="ruby-identifier">path</span>)
736 49: 
737 50:         <span class="ruby-identifier">runner</span>.<span class="ruby-identifier">runcommand</span>
738 51: 
739 52:         <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;#{command} exited with #{runner.status.exitstatus}&quot;</span>)
740 53: 
741 54:         <span class="ruby-identifier">stderr</span>.<span class="ruby-identifier">each_line</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;#{to_s}: #{l.chomp}&quot;</span>)} <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">stderr</span>.<span class="ruby-identifier">empty?</span>
742 55:         <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">each_line</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-constant">Log</span>.<span class="ruby-identifier">info</span>(<span class="ruby-node">&quot;#{to_s}: #{l.chomp}&quot;</span>)} <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">empty?</span>
743 56: 
744 57:         {<span class="ruby-identifier">:exitstatus</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">runner</span>.<span class="ruby-identifier">status</span>.<span class="ruby-identifier">exitstatus</span>,
745 58:          <span class="ruby-identifier">:stdout</span>     =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">runner</span>.<span class="ruby-identifier">stdout</span>,
746 59:          <span class="ruby-identifier">:stderr</span>     =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">runner</span>.<span class="ruby-identifier">stderr</span>,
747 60:          <span class="ruby-identifier">:data</span>       =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">load_results</span>(<span class="ruby-identifier">reply_file</span>.<span class="ruby-identifier">path</span>)}
748 61:       <span class="ruby-keyword kw">ensure</span>
749 62:         <span class="ruby-identifier">request_file</span>.<span class="ruby-identifier">close!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">request_file</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">&quot;close!&quot;</span>)
750 63:         <span class="ruby-identifier">reply_file</span>.<span class="ruby-identifier">close!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">reply_file</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">&quot;close&quot;</span>)
751 64:       <span class="ruby-keyword kw">end</span></pre>
752                                         </div>
753                                         
754                                 </div>
755
756                                 
757                         </div>
758
759                 
760                         <div id="save-json-request-method" class="method-detail ">
761                                 <a name="M000378"></a>
762
763                                 <div class="method-heading">
764                                 
765                                         <span class="method-name">save_json_request</span><span
766                                                 class="method-args">(req)</span>
767                                         <span class="method-click-advice">click to toggle source</span>
768                                 
769                                 </div>
770
771                                 <div class="method-description">
772                                         
773                                         <p class="missing-docs">(Not documented)</p>
774                                         
775
776                                         
777                                         <div class="method-source-code"
778                                                 id="save-json-request-source">
779 <pre>
780      <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 113</span>
781 113:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_json_request</span>(<span class="ruby-identifier">req</span>)
782 114:         <span class="ruby-identifier">req</span>.<span class="ruby-identifier">to_json</span>
783 115:       <span class="ruby-keyword kw">end</span></pre>
784                                         </div>
785                                         
786                                 </div>
787
788                                 
789                         </div>
790
791                 
792                         <div id="saverequest-method" class="method-detail ">
793                                 <a name="M000377"></a>
794
795                                 <div class="method-heading">
796                                 
797                                         <span class="method-name">saverequest</span><span
798                                                 class="method-args">(req)</span>
799                                         <span class="method-click-advice">click to toggle source</span>
800                                 
801                                 </div>
802
803                                 <div class="method-description">
804                                         
805                                         <p class="missing-docs">(Not documented)</p>
806                                         
807
808                                         
809                                         <div class="method-source-code"
810                                                 id="saverequest-source">
811 <pre>
812      <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 99</span>
813  99:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">saverequest</span>(<span class="ruby-identifier">req</span>)
814 100:         <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Attempting to save request in #{format} format&quot;</span>)
815 101: 
816 102:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;save_#{format}_request&quot;</span>)
817 103:           <span class="ruby-identifier">data</span> = <span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;save_#{format}_request&quot;</span>, <span class="ruby-identifier">req</span>)
818 104: 
819 105:           <span class="ruby-identifier">request_file</span> = <span class="ruby-identifier">tempfile</span>(<span class="ruby-value str">&quot;request&quot;</span>)
820 106:           <span class="ruby-identifier">request_file</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">data</span>
821 107:           <span class="ruby-identifier">request_file</span>.<span class="ruby-identifier">close</span>
822 108:         <span class="ruby-keyword kw">end</span>
823 109: 
824 110:         <span class="ruby-identifier">request_file</span>
825 111:       <span class="ruby-keyword kw">end</span></pre>
826                                         </div>
827                                         
828                                 </div>
829
830                                 
831                         </div>
832
833                 
834                         <div id="shell-method" class="method-detail ">
835                                 <a name="M000374"></a>
836
837                                 <div class="method-heading">
838                                 
839                                         <span class="method-name">shell</span><span
840                                                 class="method-args">(command, infile, outfile)</span>
841                                         <span class="method-click-advice">click to toggle source</span>
842                                 
843                                 </div>
844
845                                 <div class="method-description">
846                                         
847                                         <p class="missing-docs">(Not documented)</p>
848                                         
849
850                                         
851                                         <div class="method-source-code"
852                                                 id="shell-source">
853 <pre>
854     <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 66</span>
855 66:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shell</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">infile</span>, <span class="ruby-identifier">outfile</span>)
856 67:         <span class="ruby-identifier">env</span> = {<span class="ruby-value str">&quot;MCOLLECTIVE_REQUEST_FILE&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">infile</span>,
857 68:                <span class="ruby-value str">&quot;MCOLLECTIVE_REPLY_FILE&quot;</span>   =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">outfile</span>}
858 69: 
859 70:         <span class="ruby-constant">Shell</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{command} #{infile} #{outfile}&quot;</span>, <span class="ruby-identifier">:cwd</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>, <span class="ruby-identifier">:stdout</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">stdout</span>, <span class="ruby-identifier">:stderr</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">stderr</span>, <span class="ruby-identifier">:environment</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">env</span>)
860 71:       <span class="ruby-keyword kw">end</span></pre>
861                                         </div>
862                                         
863                                 </div>
864
865                                 
866                         </div>
867
868                 
869                         <div id="tempfile-method" class="method-detail ">
870                                 <a name="M000381"></a>
871
872                                 <div class="method-heading">
873                                 
874                                         <span class="method-name">tempfile</span><span
875                                                 class="method-args">(prefix)</span>
876                                         <span class="method-click-advice">click to toggle source</span>
877                                 
878                                 </div>
879
880                                 <div class="method-description">
881                                         
882                                         <p class="missing-docs">(Not documented)</p>
883                                         
884
885                                         
886                                         <div class="method-source-code"
887                                                 id="tempfile-source">
888 <pre>
889      <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 125</span>
890 125:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tempfile</span>(<span class="ruby-identifier">prefix</span>)
891 126:         <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;mcollective_#{prefix}&quot;</span>, <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
892 127:       <span class="ruby-keyword kw">end</span></pre>
893                                         </div>
894                                         
895                                 </div>
896
897                                 
898                         </div>
899
900                 
901                         <div id="to-s-method" class="method-detail ">
902                                 <a name="M000380"></a>
903
904                                 <div class="method-heading">
905                                 
906                                         <span class="method-name">to_s</span><span
907                                                 class="method-args">()</span>
908                                         <span class="method-click-advice">click to toggle source</span>
909                                 
910                                 </div>
911
912                                 <div class="method-description">
913                                         
914                                         <p class="missing-docs">(Not documented)</p>
915                                         
916
917                                         
918                                         <div class="method-source-code"
919                                                 id="to-s-source">
920 <pre>
921      <span class="ruby-comment cmt"># File lib/mcollective/rpc/actionrunner.rb, line 121</span>
922 121:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
923 122:         <span class="ruby-value str">&quot;%s#%s command: %s&quot;</span> <span class="ruby-operator">%</span> [ <span class="ruby-identifier">agent</span>, <span class="ruby-identifier">action</span>, <span class="ruby-identifier">command</span> ]
924 123:       <span class="ruby-keyword kw">end</span></pre>
925                                         </div>
926                                         
927                                 </div>
928
929                                 
930                         </div>
931
932                 
933                 </div>
934         
935
936         </div>
937
938
939         <div id="rdoc-debugging-section-dump" class="debugging-section">
940         
941                 <p>Disabled; run with --debug to generate this.</p>
942         
943         </div>
944
945         <div id="validator-badges">
946                 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
947                 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
948                         Rdoc Generator</a> 1.1.6</small>.</p>
949         </div>
950
951 </body>
952 </html>
953