1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
8 <title>Module: MCollective::RPC</title>
10 <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
12 <script src="../js/jquery.js" type="text/javascript"
13 charset="utf-8"></script>
14 <script src="../js/thickbox-compressed.js" type="text/javascript"
15 charset="utf-8"></script>
16 <script src="../js/quicksearch.js" type="text/javascript"
17 charset="utf-8"></script>
18 <script src="../js/darkfish.js" type="text/javascript"
19 charset="utf-8"></script>
25 <div id="file-metadata">
26 <div id="file-list-section" class="section">
27 <h3 class="section-header">In Files</h3>
28 <div class="section-body">
31 <li><a href="../lib/mcollective/rpc_rb.html?TB_iframe=true&height=550&width=785"
32 class="thickbox" title="lib/mcollective/rpc.rb">lib/mcollective/rpc.rb</a></li>
34 <li><a href="../lib/mcollective/rpc/actionrunner_rb.html?TB_iframe=true&height=550&width=785"
35 class="thickbox" title="lib/mcollective/rpc/actionrunner.rb">lib/mcollective/rpc/actionrunner.rb</a></li>
37 <li><a href="../lib/mcollective/rpc/reply_rb.html?TB_iframe=true&height=550&width=785"
38 class="thickbox" title="lib/mcollective/rpc/reply.rb">lib/mcollective/rpc/reply.rb</a></li>
40 <li><a href="../lib/mcollective/rpc/progress_rb.html?TB_iframe=true&height=550&width=785"
41 class="thickbox" title="lib/mcollective/rpc/progress.rb">lib/mcollective/rpc/progress.rb</a></li>
43 <li><a href="../lib/mcollective/rpc/agent_rb.html?TB_iframe=true&height=550&width=785"
44 class="thickbox" title="lib/mcollective/rpc/agent.rb">lib/mcollective/rpc/agent.rb</a></li>
46 <li><a href="../lib/mcollective/rpc/request_rb.html?TB_iframe=true&height=550&width=785"
47 class="thickbox" title="lib/mcollective/rpc/request.rb">lib/mcollective/rpc/request.rb</a></li>
49 <li><a href="../lib/mcollective/rpc/audit_rb.html?TB_iframe=true&height=550&width=785"
50 class="thickbox" title="lib/mcollective/rpc/audit.rb">lib/mcollective/rpc/audit.rb</a></li>
52 <li><a href="../lib/mcollective/rpc/stats_rb.html?TB_iframe=true&height=550&width=785"
53 class="thickbox" title="lib/mcollective/rpc/stats.rb">lib/mcollective/rpc/stats.rb</a></li>
55 <li><a href="../lib/mcollective/rpc/result_rb.html?TB_iframe=true&height=550&width=785"
56 class="thickbox" title="lib/mcollective/rpc/result.rb">lib/mcollective/rpc/result.rb</a></li>
58 <li><a href="../lib/mcollective/rpc/helpers_rb.html?TB_iframe=true&height=550&width=785"
59 class="thickbox" title="lib/mcollective/rpc/helpers.rb">lib/mcollective/rpc/helpers.rb</a></li>
61 <li><a href="../lib/mcollective/rpc/client_rb.html?TB_iframe=true&height=550&width=785"
62 class="thickbox" title="lib/mcollective/rpc/client.rb">lib/mcollective/rpc/client.rb</a></li>
71 <div id="class-metadata">
76 <!-- Namespace Contents -->
78 <div id="namespace-list-section" class="section">
79 <h3 class="section-header">Namespace</h3>
80 <ul class="link-list">
82 <li><span class="type">CLASS</span> <a href="RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
84 <li><span class="type">CLASS</span> <a href="RPC/Agent.html">MCollective::RPC::Agent</a></li>
86 <li><span class="type">CLASS</span> <a href="RPC/Audit.html">MCollective::RPC::Audit</a></li>
88 <li><span class="type">CLASS</span> <a href="RPC/Client.html">MCollective::RPC::Client</a></li>
90 <li><span class="type">CLASS</span> <a href="RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
92 <li><span class="type">CLASS</span> <a href="RPC/Progress.html">MCollective::RPC::Progress</a></li>
94 <li><span class="type">CLASS</span> <a href="RPC/Reply.html">MCollective::RPC::Reply</a></li>
96 <li><span class="type">CLASS</span> <a href="RPC/Request.html">MCollective::RPC::Request</a></li>
98 <li><span class="type">CLASS</span> <a href="RPC/Result.html">MCollective::RPC::Result</a></li>
100 <li><span class="type">CLASS</span> <a href="RPC/Stats.html">MCollective::RPC::Stats</a></li>
106 <!-- Method Quickref -->
108 <div id="method-list-section" class="section">
109 <h3 class="section-header">Methods</h3>
110 <ul class="link-list">
112 <li><a href="#M000327">::const_missing</a></li>
114 <li><a href="#M000320">::discovered</a></li>
116 <li><a href="#M000319">::stats</a></li>
118 <li><a href="#M000324">#empty_filter?</a></li>
120 <li><a href="#M000323">#printrpc</a></li>
122 <li><a href="#M000321">#printrpcstats</a></li>
124 <li><a href="#M000314">#rpcclient</a></li>
126 <li><a href="#M000310">#rpcoptions</a></li>
132 <!-- Included Modules -->
136 <div id="project-metadata">
139 <div id="fileindex-section" class="section project-section">
140 <h3 class="section-header">Files</h3>
143 <li class="file"><a href="../COPYING.html">COPYING</a></li>
145 <li class="file"><a href="../Gemfile.html">Gemfile</a></li>
147 <li class="file"><a href="../README.html">README</a></li>
149 <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
151 <li class="file"><a href="../etc/client_cfg_dist.html">client.cfg.dist</a></li>
153 <li class="file"><a href="../etc/data-help_erb.html">data-help.erb</a></li>
155 <li class="file"><a href="../etc/discovery-help_erb.html">discovery-help.erb</a></li>
157 <li class="file"><a href="../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
159 <li class="file"><a href="../etc/metadata-help_erb.html">metadata-help.erb</a></li>
161 <li class="file"><a href="../etc/msg-help_erb.html">msg-help.erb</a></li>
163 <li class="file"><a href="../etc/rpc-help_erb.html">rpc-help.erb</a></li>
165 <li class="file"><a href="../etc/server_cfg_dist.html">server.cfg.dist</a></li>
167 <li class="file"><a href="../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
169 <li class="file"><a href="../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
171 <li class="file"><a href="../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
173 <li class="file"><a href="../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
175 <li class="file"><a href="../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
177 <li class="file"><a href="../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
179 <li class="file"><a href="../lib/mcollective/locales/en_yml.html">en.yml</a></li>
181 <li class="file"><a href="../mcollective_init.html">mcollective.init</a></li>
187 <div id="classindex-section" class="section project-section">
188 <h3 class="section-header">Class Index
189 <span class="search-toggle"><img src="../images/find.png"
190 height="16" width="16" alt="[+]"
191 title="show/hide quicksearch" /></span></h3>
192 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
194 <legend>Quicksearch</legend>
195 <input type="text" name="quicksearch" value=""
196 class="quicksearch-field" />
200 <ul class="link-list">
202 <li><a href="../MCollective.html">MCollective</a></li>
204 <li><a href="../MCollective/Agent.html">MCollective::Agent</a></li>
206 <li><a href="../MCollective/Agents.html">MCollective::Agents</a></li>
208 <li><a href="../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
210 <li><a href="../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
212 <li><a href="../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
214 <li><a href="../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
216 <li><a href="../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
218 <li><a href="../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
220 <li><a href="../MCollective/Application.html">MCollective::Application</a></li>
222 <li><a href="../MCollective/Applications.html">MCollective::Applications</a></li>
224 <li><a href="../MCollective/Cache.html">MCollective::Cache</a></li>
226 <li><a href="../MCollective/Client.html">MCollective::Client</a></li>
228 <li><a href="../MCollective/CodedError.html">MCollective::CodedError</a></li>
230 <li><a href="../MCollective/Config.html">MCollective::Config</a></li>
232 <li><a href="../MCollective/Connector.html">MCollective::Connector</a></li>
234 <li><a href="../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
236 <li><a href="../MCollective/DDL.html">MCollective::DDL</a></li>
238 <li><a href="../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
240 <li><a href="../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
242 <li><a href="../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
244 <li><a href="../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
246 <li><a href="../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
248 <li><a href="../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
250 <li><a href="../MCollective/Data.html">MCollective::Data</a></li>
252 <li><a href="../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
254 <li><a href="../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
256 <li><a href="../MCollective/Discovery.html">MCollective::Discovery</a></li>
258 <li><a href="../MCollective/Facts.html">MCollective::Facts</a></li>
260 <li><a href="../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
262 <li><a href="../MCollective/Generators.html">MCollective::Generators</a></li>
264 <li><a href="../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
266 <li><a href="../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
268 <li><a href="../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
270 <li><a href="../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
272 <li><a href="../MCollective/Log.html">MCollective::Log</a></li>
274 <li><a href="../MCollective/Logger.html">MCollective::Logger</a></li>
276 <li><a href="../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
278 <li><a href="../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
280 <li><a href="../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
282 <li><a href="../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
284 <li><a href="../MCollective/Matcher.html">MCollective::Matcher</a></li>
286 <li><a href="../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
288 <li><a href="../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
290 <li><a href="../MCollective/Message.html">MCollective::Message</a></li>
292 <li><a href="../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
294 <li><a href="../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
296 <li><a href="../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
298 <li><a href="../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
300 <li><a href="../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
302 <li><a href="../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
304 <li><a href="../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
306 <li><a href="../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
308 <li><a href="../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
310 <li><a href="../MCollective/RPC.html">MCollective::RPC</a></li>
312 <li><a href="../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
314 <li><a href="../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
316 <li><a href="../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
318 <li><a href="../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
320 <li><a href="../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
322 <li><a href="../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
324 <li><a href="../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
326 <li><a href="../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
328 <li><a href="../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
330 <li><a href="../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
332 <li><a href="../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
334 <li><a href="../MCollective/RPCError.html">MCollective::RPCError</a></li>
336 <li><a href="../MCollective/Registration.html">MCollective::Registration</a></li>
338 <li><a href="../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
340 <li><a href="../MCollective/Runner.html">MCollective::Runner</a></li>
342 <li><a href="../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
344 <li><a href="../MCollective/SSL.html">MCollective::SSL</a></li>
346 <li><a href="../MCollective/Security.html">MCollective::Security</a></li>
348 <li><a href="../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
350 <li><a href="../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
352 <li><a href="../MCollective/Shell.html">MCollective::Shell</a></li>
354 <li><a href="../MCollective/Translatable.html">MCollective::Translatable</a></li>
356 <li><a href="../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
358 <li><a href="../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
360 <li><a href="../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
362 <li><a href="../MCollective/Util.html">MCollective::Util</a></li>
364 <li><a href="../MCollective/Validator.html">MCollective::Validator</a></li>
366 <li><a href="../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
368 <li><a href="../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
370 <li><a href="../Array.html">Array</a></li>
372 <li><a href="../Dir.html">Dir</a></li>
374 <li><a href="../Object.html">Object</a></li>
376 <li><a href="../String.html">String</a></li>
378 <li><a href="../Symbol.html">Symbol</a></li>
381 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
388 <div id="documentation">
389 <h1 class="module">MCollective::RPC</h1>
391 <div id="description">
393 Toolset to create a standard interface of client and agent using an <a
394 href="RPC.html">RPC</a> metaphor, standard compliant agents will make it
395 easier to create generic clients like web interfaces etc
408 <div id="public-class-method-details" class="method-section section">
409 <h3 class="section-header">Public Class Methods</h3>
412 <div id="const-missing-method" class="method-detail ">
413 <a name="M000327"></a>
415 <div class="method-heading">
417 <span class="method-name">const_missing</span><span
418 class="method-args">(const_name)</span>
419 <span class="method-click-advice">click to toggle source</span>
423 <div class="method-description">
425 <p class="missing-docs">(Not documented)</p>
429 <div class="method-source-code"
430 id="const-missing-source">
432 <span class="ruby-comment cmt"># File lib/mcollective/rpc.rb, line 175</span>
433 175: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">const_missing</span>(<span class="ruby-identifier">const_name</span>)
434 176: <span class="ruby-keyword kw">super</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">const_name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:DDL</span>
436 178: <span class="ruby-constant">Log</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-value str">"MCollective::RPC::DDL is deprecatd, please use MCollective::DDL instead"</span>)
437 179: <span class="ruby-constant">MCollective</span><span class="ruby-operator">::</span><span class="ruby-constant">DDL</span>
438 180: <span class="ruby-keyword kw">end</span></pre>
447 <div id="discovered-method" class="method-detail ">
448 <a name="M000320"></a>
450 <div class="method-heading">
452 <span class="method-name">discovered</span><span
453 class="method-args">(discovered)</span>
454 <span class="method-click-advice">click to toggle source</span>
458 <div class="method-description">
461 means for other classes to drop discovered hosts into this module its a bit
462 hacky but needed so that the mixin methods like printrpcstats can easily
463 get access to it without users having to pass it around in params.
468 <div class="method-source-code"
469 id="discovered-source">
471 <span class="ruby-comment cmt"># File lib/mcollective/rpc.rb, line 107</span>
472 107: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">discovered</span>(<span class="ruby-identifier">discovered</span>)
473 108: <span class="ruby-ivar">@@discovered</span> = <span class="ruby-identifier">discovered</span>
474 109: <span class="ruby-keyword kw">end</span></pre>
483 <div id="stats-method" class="method-detail ">
484 <a name="M000319"></a>
486 <div class="method-heading">
488 <span class="method-name">stats</span><span
489 class="method-args">(stats)</span>
490 <span class="method-click-advice">click to toggle source</span>
494 <div class="method-description">
497 means for other classes to drop stats into this module its a bit hacky but
498 needed so that the mixin methods like printrpcstats can easily get access
499 to it without users having to pass it around in params.
504 <div class="method-source-code"
507 <span class="ruby-comment cmt"># File lib/mcollective/rpc.rb, line 99</span>
508 99: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">stats</span>(<span class="ruby-identifier">stats</span>)
509 100: <span class="ruby-ivar">@@stats</span> = <span class="ruby-identifier">stats</span>
510 101: <span class="ruby-keyword kw">end</span></pre>
521 <div id="public-instance-method-details" class="method-section section">
522 <h3 class="section-header">Public Instance Methods</h3>
525 <div id="empty-filter--method" class="method-detail ">
526 <a name="M000324"></a>
528 <div class="method-heading">
530 <span class="method-name">empty_filter?</span><span
531 class="method-args">(options)</span>
532 <span class="method-click-advice">click to toggle source</span>
536 <div class="method-description">
539 Wrapper for <a href="Util.html#M000300">MCollective::Util.empty_filter?</a>
540 to make clients less fugly to write - ticket 18
545 <div class="method-source-code"
546 id="empty-filter--source">
548 <span class="ruby-comment cmt"># File lib/mcollective/rpc.rb, line 167</span>
549 167: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty_filter?</span>(<span class="ruby-identifier">options</span>)
550 168: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:filter</span>)
551 169: <span class="ruby-constant">Util</span>.<span class="ruby-identifier">empty_filter?</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:filter</span>])
552 170: <span class="ruby-keyword kw">else</span>
553 171: <span class="ruby-constant">Util</span>.<span class="ruby-identifier">empty_filter?</span>(<span class="ruby-identifier">options</span>)
554 172: <span class="ruby-keyword kw">end</span>
555 173: <span class="ruby-keyword kw">end</span></pre>
564 <div id="printrpc-method" class="method-detail ">
565 <a name="M000323"></a>
567 <div class="method-heading">
569 <span class="method-name">printrpc</span><span
570 class="method-args">(result, flags = {})</span>
571 <span class="method-click-advice">click to toggle source</span>
575 <div class="method-description">
578 Prints the result of an <a href="RPC.html">RPC</a> call.
581 In the default quiet mode - no flattening or verbose - only results that
582 produce an error will be printed
585 To get details of each result run with the -v command line option.
590 <div class="method-source-code"
591 id="printrpc-source">
593 <span class="ruby-comment cmt"># File lib/mcollective/rpc.rb, line 146</span>
594 146: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">printrpc</span>(<span class="ruby-identifier">result</span>, <span class="ruby-identifier">flags</span> = {})
595 147: <span class="ruby-identifier">verbose</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:verbose</span>] <span class="ruby-keyword kw">rescue</span> <span class="ruby-identifier">verbose</span> = <span class="ruby-keyword kw">false</span>
596 148: <span class="ruby-identifier">verbose</span> = <span class="ruby-identifier">flags</span>[<span class="ruby-identifier">:verbose</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">verbose</span>
597 149: <span class="ruby-identifier">flatten</span> = <span class="ruby-identifier">flags</span>[<span class="ruby-identifier">:flatten</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">false</span>
598 150: <span class="ruby-identifier">format</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:output_format</span>]
599 151: <span class="ruby-identifier">forced_mode</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:force_display_mode</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">false</span>
601 153: <span class="ruby-identifier">result_text</span> = <span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">rpcresults</span>(<span class="ruby-identifier">result</span>, {<span class="ruby-identifier">:verbose</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">verbose</span>, <span class="ruby-identifier">:flatten</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">flatten</span>, <span class="ruby-identifier">:format</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">format</span>, <span class="ruby-identifier">:force_display_mode</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">forced_mode</span>})
603 155: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">format</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:console</span>
604 156: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"\n%s\n"</span> <span class="ruby-operator">%</span> [ <span class="ruby-identifier">result_text</span> ]
605 157: <span class="ruby-keyword kw">else</span>
606 158: <span class="ruby-comment cmt"># when we get just one result to print dont pad them all with</span>
607 159: <span class="ruby-comment cmt"># blank spaces etc, just print the individual result with no</span>
608 160: <span class="ruby-comment cmt"># padding</span>
609 161: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">result_text</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">result_text</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span>
610 162: <span class="ruby-keyword kw">end</span>
611 163: <span class="ruby-keyword kw">end</span></pre>
620 <div id="printrpcstats-method" class="method-detail ">
621 <a name="M000321"></a>
623 <div class="method-heading">
625 <span class="method-name">printrpcstats</span><span
626 class="method-args">(flags={})</span>
627 <span class="method-click-advice">click to toggle source</span>
631 <div class="method-description">
634 Prints stats, requires stats to be saved from elsewhere using the <a
635 href="RPC.html#M000319">MCollective::RPC.stats</a> method.
638 If you’ve passed -v on the command line a detailed stat block will be
639 printed, else just a one liner.
642 You can pass flags into it:
645 printrpcstats :caption => "Foo", :summarize => true
648 This will use “Foo” as the caption to the stats in verbose mode
649 and print out any aggregate summary information if present
654 <div class="method-source-code"
655 id="printrpcstats-source">
657 <span class="ruby-comment cmt"># File lib/mcollective/rpc.rb, line 123</span>
658 123: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">printrpcstats</span>(<span class="ruby-identifier">flags</span>={})
659 124: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:output_format</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">:console</span>
661 126: <span class="ruby-identifier">flags</span> = {<span class="ruby-identifier">:summarize</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">:caption</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"rpc stats"</span>}.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">flags</span>)
663 128: <span class="ruby-identifier">verbose</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:verbose</span>] <span class="ruby-keyword kw">rescue</span> <span class="ruby-identifier">verbose</span> = <span class="ruby-keyword kw">false</span>
665 130: <span class="ruby-keyword kw">begin</span>
666 131: <span class="ruby-identifier">stats</span> = <span class="ruby-ivar">@@stats</span>
667 132: <span class="ruby-keyword kw">rescue</span>
668 133: <span class="ruby-identifier">puts</span>(<span class="ruby-value str">"no stats to display"</span>)
669 134: <span class="ruby-keyword kw">return</span>
670 135: <span class="ruby-keyword kw">end</span>
672 137: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">stats</span>.<span class="ruby-identifier">report</span>(<span class="ruby-identifier">flags</span>[<span class="ruby-identifier">:caption</span>], <span class="ruby-identifier">flags</span>[<span class="ruby-identifier">:summarize</span>], <span class="ruby-identifier">verbose</span>)
673 138: <span class="ruby-keyword kw">end</span></pre>
682 <div id="rpcclient-method" class="method-detail ">
683 <a name="M000314"></a>
685 <div class="method-heading">
687 <span class="method-name">rpcclient</span><span
688 class="method-args">(agent, flags = {})</span>
689 <span class="method-click-advice">click to toggle source</span>
693 <div class="method-description">
696 Wrapper to create clients, supposed to be used as a mixin:
699 include <a href="RPC.html">MCollective::RPC</a>
702 exim = rpcclient(“exim”) printrpc exim.mailq
708 rpcclient(“exim”) do |exim|
717 It will take a few flags:
720 :configfile => "etc/client.cfg"
721 :options => options
722 :exit_on_failure => true
725 Options would be a build up options hash from the <a
726 href="Optionparser.html">Optionparser</a> you can use the rpcoptions helper
730 :exit_on_failure is true by default, and causes the application to exit if
731 there is a failure constructing the <a href="RPC.html">RPC</a> client. Set
732 this flag to false to cause an Exception to be raised instead.
737 <div class="method-source-code"
738 id="rpcclient-source">
740 <span class="ruby-comment cmt"># File lib/mcollective/rpc.rb, line 60</span>
741 60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rpcclient</span>(<span class="ruby-identifier">agent</span>, <span class="ruby-identifier">flags</span> = {})
742 61: <span class="ruby-identifier">configfile</span> = <span class="ruby-identifier">flags</span>[<span class="ruby-identifier">:configfile</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">"/etc/mcollective/client.cfg"</span>
743 62: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">flags</span>[<span class="ruby-identifier">:options</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
745 64: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">flags</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">:exit_on_failure</span>)
746 65: <span class="ruby-identifier">exit_on_failure</span> = <span class="ruby-identifier">flags</span>[<span class="ruby-identifier">:exit_on_failure</span>]
747 66: <span class="ruby-keyword kw">else</span>
748 67: <span class="ruby-comment cmt"># We exit on failure by default for CLI-friendliness</span>
749 68: <span class="ruby-identifier">exit_on_failure</span> = <span class="ruby-keyword kw">true</span>
750 69: <span class="ruby-keyword kw">end</span>
752 71: <span class="ruby-keyword kw">begin</span>
753 72: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>
754 73: <span class="ruby-identifier">rpc</span> = <span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">agent</span>, <span class="ruby-identifier">:configfile</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:config</span>], <span class="ruby-identifier">:options</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>)
755 74: <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">rpc</span>.<span class="ruby-identifier">options</span>
756 75: <span class="ruby-keyword kw">else</span>
757 76: <span class="ruby-identifier">rpc</span> = <span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">agent</span>, <span class="ruby-identifier">:configfile</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">configfile</span>)
758 77: <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">rpc</span>.<span class="ruby-identifier">options</span>
759 78: <span class="ruby-keyword kw">end</span>
760 79: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
761 80: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">exit_on_failure</span>
762 81: <span class="ruby-identifier">puts</span>(<span class="ruby-node">"Could not create RPC client: #{e}"</span>)
763 82: <span class="ruby-identifier">exit!</span>
764 83: <span class="ruby-keyword kw">else</span>
765 84: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
766 85: <span class="ruby-keyword kw">end</span>
767 86: <span class="ruby-keyword kw">end</span>
769 88: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
770 89: <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">rpc</span>)
771 90: <span class="ruby-keyword kw">else</span>
772 91: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rpc</span>
773 92: <span class="ruby-keyword kw">end</span>
774 93: <span class="ruby-keyword kw">end</span></pre>
783 <div id="rpcoptions-method" class="method-detail ">
784 <a name="M000310"></a>
786 <div class="method-heading">
788 <span class="method-name">rpcoptions</span><span
789 class="method-args">()</span>
790 <span class="method-click-advice">click to toggle source</span>
794 <div class="method-description">
797 Creates a standard options hash, pass in a block to add extra headings etc
798 see <a href="Optionparser.html">Optionparser</a>
803 <div class="method-source-code"
804 id="rpcoptions-source">
806 <span class="ruby-comment cmt"># File lib/mcollective/rpc.rb, line 21</span>
807 21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rpcoptions</span>
808 22: <span class="ruby-identifier">oparser</span> = <span class="ruby-constant">MCollective</span><span class="ruby-operator">::</span><span class="ruby-constant">Optionparser</span>.<span class="ruby-identifier">new</span>({<span class="ruby-identifier">:verbose</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">:progress_bar</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>}, <span class="ruby-value str">"filter"</span>)
810 24: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">oparser</span>.<span class="ruby-identifier">parse</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">parser</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
811 25: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
812 26: <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">parser</span>, <span class="ruby-identifier">options</span>)
813 27: <span class="ruby-keyword kw">end</span>
815 29: <span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">add_simplerpc_options</span>(<span class="ruby-identifier">parser</span>, <span class="ruby-identifier">options</span>)
816 30: <span class="ruby-keyword kw">end</span>
818 32: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">options</span>
819 33: <span class="ruby-keyword kw">end</span></pre>
834 <div id="rdoc-debugging-section-dump" class="debugging-section">
836 <p>Disabled; run with --debug to generate this.</p>
840 <div id="validator-badges">
841 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
842 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
843 Rdoc Generator</a> 1.1.6</small>.</p>