Update version according to OSCI-936
[packages/precise/mcollective.git] / doc / MCollective / Applications.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::Applications</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/applications_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
32                                                         class="thickbox" title="lib/mcollective/applications.rb">lib/mcollective/applications.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="#M000091">::[]</a></li>
63                                         
64                                         <li><a href="#M000096">::filter_extra_options</a></li>
65                                         
66                                         <li><a href="#M000095">::list</a></li>
67                                         
68                                         <li><a href="#M000093">::load_application</a></li>
69                                         
70                                         <li><a href="#M000098">::load_config</a></li>
71                                         
72                                         <li><a href="#M000092">::run</a></li>
73                                         
74                                 </ul>
75                         </div>
76                         
77
78                         <!-- Included Modules -->
79                         
80                 </div>
81
82                 <div id="project-metadata">
83                         
84                         
85                         <div id="fileindex-section" class="section project-section">
86                                 <h3 class="section-header">Files</h3>
87                                 <ul>
88                                 
89                                         <li class="file"><a href="../COPYING.html">COPYING</a></li>
90                                 
91                                         <li class="file"><a href="../Gemfile.html">Gemfile</a></li>
92                                 
93                                         <li class="file"><a href="../README.html">README</a></li>
94                                 
95                                         <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
96                                 
97                                         <li class="file"><a href="../etc/client_cfg_dist.html">client.cfg.dist</a></li>
98                                 
99                                         <li class="file"><a href="../etc/data-help_erb.html">data-help.erb</a></li>
100                                 
101                                         <li class="file"><a href="../etc/discovery-help_erb.html">discovery-help.erb</a></li>
102                                 
103                                         <li class="file"><a href="../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
104                                 
105                                         <li class="file"><a href="../etc/metadata-help_erb.html">metadata-help.erb</a></li>
106                                 
107                                         <li class="file"><a href="../etc/msg-help_erb.html">msg-help.erb</a></li>
108                                 
109                                         <li class="file"><a href="../etc/rpc-help_erb.html">rpc-help.erb</a></li>
110                                 
111                                         <li class="file"><a href="../etc/server_cfg_dist.html">server.cfg.dist</a></li>
112                                 
113                                         <li class="file"><a href="../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
114                                 
115                                         <li class="file"><a href="../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
116                                 
117                                         <li class="file"><a href="../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
118                                 
119                                         <li class="file"><a href="../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
120                                 
121                                         <li class="file"><a href="../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
122                                 
123                                         <li class="file"><a href="../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
124                                 
125                                         <li class="file"><a href="../lib/mcollective/locales/en_yml.html">en.yml</a></li>
126                                 
127                                         <li class="file"><a href="../mcollective_init.html">mcollective.init</a></li>
128                                 
129                                 </ul>
130                         </div>
131                         
132
133                         <div id="classindex-section" class="section project-section">
134                                 <h3 class="section-header">Class Index
135                                         <span class="search-toggle"><img src="../images/find.png"
136                                                 height="16" width="16" alt="[+]"
137                                                 title="show/hide quicksearch" /></span></h3>
138                                 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
139                                 <fieldset>
140                                         <legend>Quicksearch</legend>
141                                         <input type="text" name="quicksearch" value=""
142                                                 class="quicksearch-field" />
143                                 </fieldset>
144                                 </form>
145
146                                 <ul class="link-list">
147                                 
148                                         <li><a href="../MCollective.html">MCollective</a></li>
149                                 
150                                         <li><a href="../MCollective/Agent.html">MCollective::Agent</a></li>
151                                 
152                                         <li><a href="../MCollective/Agents.html">MCollective::Agents</a></li>
153                                 
154                                         <li><a href="../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
155                                 
156                                         <li><a href="../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
157                                 
158                                         <li><a href="../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
159                                 
160                                         <li><a href="../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
161                                 
162                                         <li><a href="../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
163                                 
164                                         <li><a href="../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
165                                 
166                                         <li><a href="../MCollective/Application.html">MCollective::Application</a></li>
167                                 
168                                         <li><a href="../MCollective/Applications.html">MCollective::Applications</a></li>
169                                 
170                                         <li><a href="../MCollective/Cache.html">MCollective::Cache</a></li>
171                                 
172                                         <li><a href="../MCollective/Client.html">MCollective::Client</a></li>
173                                 
174                                         <li><a href="../MCollective/CodedError.html">MCollective::CodedError</a></li>
175                                 
176                                         <li><a href="../MCollective/Config.html">MCollective::Config</a></li>
177                                 
178                                         <li><a href="../MCollective/Connector.html">MCollective::Connector</a></li>
179                                 
180                                         <li><a href="../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
181                                 
182                                         <li><a href="../MCollective/DDL.html">MCollective::DDL</a></li>
183                                 
184                                         <li><a href="../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
185                                 
186                                         <li><a href="../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
187                                 
188                                         <li><a href="../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
189                                 
190                                         <li><a href="../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
191                                 
192                                         <li><a href="../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
193                                 
194                                         <li><a href="../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
195                                 
196                                         <li><a href="../MCollective/Data.html">MCollective::Data</a></li>
197                                 
198                                         <li><a href="../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
199                                 
200                                         <li><a href="../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
201                                 
202                                         <li><a href="../MCollective/Discovery.html">MCollective::Discovery</a></li>
203                                 
204                                         <li><a href="../MCollective/Facts.html">MCollective::Facts</a></li>
205                                 
206                                         <li><a href="../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
207                                 
208                                         <li><a href="../MCollective/Generators.html">MCollective::Generators</a></li>
209                                 
210                                         <li><a href="../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
211                                 
212                                         <li><a href="../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
213                                 
214                                         <li><a href="../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
215                                 
216                                         <li><a href="../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
217                                 
218                                         <li><a href="../MCollective/Log.html">MCollective::Log</a></li>
219                                 
220                                         <li><a href="../MCollective/Logger.html">MCollective::Logger</a></li>
221                                 
222                                         <li><a href="../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
223                                 
224                                         <li><a href="../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
225                                 
226                                         <li><a href="../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
227                                 
228                                         <li><a href="../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
229                                 
230                                         <li><a href="../MCollective/Matcher.html">MCollective::Matcher</a></li>
231                                 
232                                         <li><a href="../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
233                                 
234                                         <li><a href="../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
235                                 
236                                         <li><a href="../MCollective/Message.html">MCollective::Message</a></li>
237                                 
238                                         <li><a href="../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
239                                 
240                                         <li><a href="../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
241                                 
242                                         <li><a href="../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
243                                 
244                                         <li><a href="../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
245                                 
246                                         <li><a href="../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
247                                 
248                                         <li><a href="../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
249                                 
250                                         <li><a href="../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
251                                 
252                                         <li><a href="../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
253                                 
254                                         <li><a href="../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
255                                 
256                                         <li><a href="../MCollective/RPC.html">MCollective::RPC</a></li>
257                                 
258                                         <li><a href="../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
259                                 
260                                         <li><a href="../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
261                                 
262                                         <li><a href="../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
263                                 
264                                         <li><a href="../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
265                                 
266                                         <li><a href="../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
267                                 
268                                         <li><a href="../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
269                                 
270                                         <li><a href="../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
271                                 
272                                         <li><a href="../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
273                                 
274                                         <li><a href="../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
275                                 
276                                         <li><a href="../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
277                                 
278                                         <li><a href="../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
279                                 
280                                         <li><a href="../MCollective/RPCError.html">MCollective::RPCError</a></li>
281                                 
282                                         <li><a href="../MCollective/Registration.html">MCollective::Registration</a></li>
283                                 
284                                         <li><a href="../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
285                                 
286                                         <li><a href="../MCollective/Runner.html">MCollective::Runner</a></li>
287                                 
288                                         <li><a href="../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
289                                 
290                                         <li><a href="../MCollective/SSL.html">MCollective::SSL</a></li>
291                                 
292                                         <li><a href="../MCollective/Security.html">MCollective::Security</a></li>
293                                 
294                                         <li><a href="../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
295                                 
296                                         <li><a href="../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
297                                 
298                                         <li><a href="../MCollective/Shell.html">MCollective::Shell</a></li>
299                                 
300                                         <li><a href="../MCollective/Translatable.html">MCollective::Translatable</a></li>
301                                 
302                                         <li><a href="../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
303                                 
304                                         <li><a href="../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
305                                 
306                                         <li><a href="../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
307                                 
308                                         <li><a href="../MCollective/Util.html">MCollective::Util</a></li>
309                                 
310                                         <li><a href="../MCollective/Validator.html">MCollective::Validator</a></li>
311                                 
312                                         <li><a href="../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
313                                 
314                                         <li><a href="../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
315                                 
316                                         <li><a href="../Array.html">Array</a></li>
317                                 
318                                         <li><a href="../Dir.html">Dir</a></li>
319                                 
320                                         <li><a href="../Object.html">Object</a></li>
321                                 
322                                         <li><a href="../String.html">String</a></li>
323                                 
324                                         <li><a href="../Symbol.html">Symbol</a></li>
325                                 
326                                 </ul>
327                                 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
328                         </div>
329
330                         
331                 </div>
332         </div>
333
334         <div id="documentation">
335                 <h1 class="class">MCollective::Applications</h1>
336
337                 <div id="description">
338                         
339                 </div>
340
341                 <!-- Constants -->
342                 
343
344                 <!-- Attributes -->
345                 
346
347                 <!-- Methods -->
348                 
349                 <div id="public-class-method-details" class="method-section section">
350                         <h3 class="section-header">Public Class Methods</h3>
351
352                 
353                         <div id="--method" class="method-detail ">
354                                 <a name="M000091"></a>
355
356                                 <div class="method-heading">
357                                 
358                                         <span class="method-name">[]</span><span
359                                                 class="method-args">(appname)</span>
360                                         <span class="method-click-advice">click to toggle source</span>
361                                 
362                                 </div>
363
364                                 <div class="method-description">
365                                         
366                                         <p class="missing-docs">(Not documented)</p>
367                                         
368
369                                         
370                                         <div class="method-source-code"
371                                                 id="--source">
372 <pre>
373    <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 3</span>
374 3:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-operator">[]</span>(<span class="ruby-identifier">appname</span>)
375 4:       <span class="ruby-identifier">load_application</span>(<span class="ruby-identifier">appname</span>)
376 5:       <span class="ruby-constant">PluginManager</span>[<span class="ruby-node">&quot;#{appname}_application&quot;</span>]
377 6:     <span class="ruby-keyword kw">end</span></pre>
378                                         </div>
379                                         
380                                 </div>
381
382                                 
383                         </div>
384
385                 
386                         <div id="filter-extra-options-method" class="method-detail ">
387                                 <a name="M000096"></a>
388
389                                 <div class="method-heading">
390                                 
391                                         <span class="method-name">filter_extra_options</span><span
392                                                 class="method-args">(opts)</span>
393                                         <span class="method-click-advice">click to toggle source</span>
394                                 
395                                 </div>
396
397                                 <div class="method-description">
398                                         
399                                         <p>
400 Filters a string of opts out using Shellwords keeping only things related
401 to &#8212;config and -c
402 </p>
403                                         
404
405                                         
406                                         <div class="method-source-code"
407                                                 id="filter-extra-options-source">
408 <pre>
409     <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 49</span>
410 49:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">filter_extra_options</span>(<span class="ruby-identifier">opts</span>)
411 50:       <span class="ruby-identifier">res</span> = <span class="ruby-value str">&quot;&quot;</span>
412 51:       <span class="ruby-identifier">words</span> = <span class="ruby-constant">Shellwords</span>.<span class="ruby-identifier">shellwords</span>(<span class="ruby-identifier">opts</span>)
413 52:       <span class="ruby-identifier">words</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">word</span>,<span class="ruby-identifier">idx</span><span class="ruby-operator">|</span>
414 53:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">word</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;-c&quot;</span>
415 54:           <span class="ruby-keyword kw">return</span> <span class="ruby-node">&quot;--config=#{words[idx + 1]}&quot;</span>
416 55:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">word</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;--config&quot;</span>
417 56:           <span class="ruby-keyword kw">return</span> <span class="ruby-node">&quot;--config=#{words[idx + 1]}&quot;</span>
418 57:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">word</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\-c=/</span>
419 58:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">word</span>
420 59:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">word</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\-\-config=/</span>
421 60:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">word</span>
422 61:         <span class="ruby-keyword kw">end</span>
423 62:       <span class="ruby-keyword kw">end</span>
424 63: 
425 64:       <span class="ruby-keyword kw">return</span> <span class="ruby-value str">&quot;&quot;</span>
426 65:     <span class="ruby-keyword kw">end</span></pre>
427                                         </div>
428                                         
429                                 </div>
430
431                                 
432                         </div>
433
434                 
435                         <div id="list-method" class="method-detail ">
436                                 <a name="M000095"></a>
437
438                                 <div class="method-heading">
439                                 
440                                         <span class="method-name">list</span><span
441                                                 class="method-args">()</span>
442                                         <span class="method-click-advice">click to toggle source</span>
443                                 
444                                 </div>
445
446                                 <div class="method-description">
447                                         
448                                         <p>
449 Returns an array of applications found in the lib dirs
450 </p>
451                                         
452
453                                         
454                                         <div class="method-source-code"
455                                                 id="list-source">
456 <pre>
457     <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 36</span>
458 36:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">list</span>
459 37:       <span class="ruby-identifier">load_config</span>
460 38: 
461 39:       <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value str">&quot;application&quot;</span>)
462 40:     <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SystemExit</span>
463 41:       <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
464 42:     <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>
465 43:       <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Failed to generate application list: #{e.class}: #{e}&quot;</span>
466 44:       <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
467 45:     <span class="ruby-keyword kw">end</span></pre>
468                                         </div>
469                                         
470                                 </div>
471
472                                 
473                         </div>
474
475                 
476                         <div id="load-application-method" class="method-detail ">
477                                 <a name="M000093"></a>
478
479                                 <div class="method-heading">
480                                 
481                                         <span class="method-name">load_application</span><span
482                                                 class="method-args">(appname)</span>
483                                         <span class="method-click-advice">click to toggle source</span>
484                                 
485                                 </div>
486
487                                 <div class="method-description">
488                                         
489                                         <p class="missing-docs">(Not documented)</p>
490                                         
491
492                                         
493                                         <div class="method-source-code"
494                                                 id="load-application-source">
495 <pre>
496     <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 26</span>
497 26:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_application</span>(<span class="ruby-identifier">appname</span>)
498 27:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-node">&quot;#{appname}_application&quot;</span>)
499 28: 
500 29:       <span class="ruby-identifier">load_config</span>
501 30: 
502 31:       <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">loadclass</span> <span class="ruby-node">&quot;MCollective::Application::#{appname.capitalize}&quot;</span>
503 32:       <span class="ruby-constant">PluginManager</span> <span class="ruby-operator">&lt;&lt;</span> {<span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{appname}_application&quot;</span>, <span class="ruby-identifier">:class</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;MCollective::Application::#{appname.capitalize}&quot;</span>}
504 33:     <span class="ruby-keyword kw">end</span></pre>
505                                         </div>
506                                         
507                                 </div>
508
509                                 
510                         </div>
511
512                 
513                         <div id="load-config-method" class="method-detail ">
514                                 <a name="M000098"></a>
515
516                                 <div class="method-heading">
517                                 
518                                         <span class="method-name">load_config</span><span
519                                                 class="method-args">()</span>
520                                         <span class="method-click-advice">click to toggle source</span>
521                                 
522                                 </div>
523
524                                 <div class="method-description">
525                                         
526                                         <p>
527 We need to know the config file in order to know the libdir so that we can
528 find applications.
529 </p>
530 <p>
531 The problem is the CLI might be stuffed with options only the app in the
532 libdir might understand so we have a chicken and egg situation.
533 </p>
534 <p>
535 We&#8217;re parsing and filtering MCOLLECTIVE_EXTRA_OPTS removing all but
536 config related options and parsing the options looking just for the config
537 file.
538 </p>
539 <p>
540 We&#8217;re handling failures gracefully and finally restoring the ARG and
541 MCOLLECTIVE_EXTRA_OPTS to the state they were before we started parsing.
542 </p>
543 <p>
544 This is mostly a hack, when we&#8217;re redoing how config works this stuff
545 should be made less sucky
546 </p>
547                                         
548
549                                         
550                                         <div class="method-source-code"
551                                                 id="load-config-source">
552 <pre>
553      <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 84</span>
554  84:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_config</span>
555  85:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">configured</span>
556  86: 
557  87:       <span class="ruby-identifier">original_argv</span> = <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">clone</span>
558  88:       <span class="ruby-identifier">original_extra_opts</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;MCOLLECTIVE_EXTRA_OPTS&quot;</span>].<span class="ruby-identifier">clone</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
559  89:       <span class="ruby-identifier">configfile</span> = <span class="ruby-keyword kw">nil</span>
560  90: 
561  91:       <span class="ruby-identifier">parser</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>
562  92:       <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;--config CONFIG&quot;</span>, <span class="ruby-value str">&quot;-c&quot;</span>, <span class="ruby-value str">&quot;Config file&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
563  93:         <span class="ruby-identifier">configfile</span> = <span class="ruby-identifier">f</span>
564  94:       <span class="ruby-keyword kw">end</span>
565  95: 
566  96:       <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">program_name</span> = <span class="ruby-identifier">$0</span>
567  97: 
568  98:       <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;--help&quot;</span>)
569  99: 
570 100:       <span class="ruby-comment cmt"># avoid option parsers own internal version handling that sux</span>
571 101:       <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-v&quot;</span>, <span class="ruby-value str">&quot;--verbose&quot;</span>)
572 102: 
573 103:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">original_extra_opts</span>
574 104:         <span class="ruby-keyword kw">begin</span>
575 105:           <span class="ruby-comment cmt"># optparse will parse the whole ENV in one go and refuse</span>
576 106:           <span class="ruby-comment cmt"># to play along with the retry trick I do below so in</span>
577 107:           <span class="ruby-comment cmt"># order to handle unknown options properly I parse out</span>
578 108:           <span class="ruby-comment cmt"># only -c and --config deleting everything else and</span>
579 109:           <span class="ruby-comment cmt"># then restore the environment variable later when I</span>
580 110:           <span class="ruby-comment cmt"># am done with it</span>
581 111:           <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;MCOLLECTIVE_EXTRA_OPTS&quot;</span>] = <span class="ruby-identifier">filter_extra_options</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;MCOLLECTIVE_EXTRA_OPTS&quot;</span>].<span class="ruby-identifier">clone</span>)
582 112:           <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">environment</span>(<span class="ruby-value str">&quot;MCOLLECTIVE_EXTRA_OPTS&quot;</span>)
583 113:         <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>
584 114:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;Failed to parse MCOLLECTIVE_EXTRA_OPTS: #{e}&quot;</span>)
585 115:         <span class="ruby-keyword kw">end</span>
586 116: 
587 117:         <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;MCOLLECTIVE_EXTRA_OPTS&quot;</span>] = <span class="ruby-identifier">original_extra_opts</span>.<span class="ruby-identifier">clone</span>
588 118:       <span class="ruby-keyword kw">end</span>
589 119: 
590 120:       <span class="ruby-keyword kw">begin</span>
591 121:         <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse!</span>
592 122:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidOption</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
593 123:         <span class="ruby-keyword kw">retry</span>
594 124:       <span class="ruby-keyword kw">end</span>
595 125: 
596 126:       <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">clear</span>
597 127:       <span class="ruby-identifier">original_argv</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-constant">ARGV</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">a</span>}
598 128: 
599 129:       <span class="ruby-identifier">configfile</span> = <span class="ruby-constant">Util</span>.<span class="ruby-identifier">config_file_for_user</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">configfile</span>
600 130: 
601 131:       <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">loadconfig</span>(<span class="ruby-identifier">configfile</span>)
602 132:     <span class="ruby-keyword kw">end</span></pre>
603                                         </div>
604                                         
605                                 </div>
606
607                                 
608                         </div>
609
610                 
611                         <div id="run-method" class="method-detail ">
612                                 <a name="M000092"></a>
613
614                                 <div class="method-heading">
615                                 
616                                         <span class="method-name">run</span><span
617                                                 class="method-args">(appname)</span>
618                                         <span class="method-click-advice">click to toggle source</span>
619                                 
620                                 </div>
621
622                                 <div class="method-description">
623                                         
624                                         <p class="missing-docs">(Not documented)</p>
625                                         
626
627                                         
628                                         <div class="method-source-code"
629                                                 id="run-source">
630 <pre>
631     <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 8</span>
632  8:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">appname</span>)
633  9:       <span class="ruby-identifier">load_config</span>
634 10: 
635 11:       <span class="ruby-keyword kw">begin</span>
636 12:         <span class="ruby-identifier">load_application</span>(<span class="ruby-identifier">appname</span>)
637 13:       <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>
638 14:         <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Util</span>.<span class="ruby-identifier">colorize</span>(<span class="ruby-identifier">:red</span>, <span class="ruby-value str">&quot;  &lt;----&quot;</span>)
639 15:         <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Application '#{appname}' failed to load:&quot;</span>
640 16:         <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span>
641 17:         <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-constant">Util</span>.<span class="ruby-identifier">colorize</span>(<span class="ruby-identifier">:red</span>, <span class="ruby-node">&quot;   #{e} (#{e.class})&quot;</span>)
642 18:         <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span>
643 19:         <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;       %s&quot;</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n       &quot;</span>)]
644 20:         <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
645 21:       <span class="ruby-keyword kw">end</span>
646 22: 
647 23:       <span class="ruby-constant">PluginManager</span>[<span class="ruby-node">&quot;#{appname}_application&quot;</span>].<span class="ruby-identifier">run</span>
648 24:     <span class="ruby-keyword kw">end</span></pre>
649                                         </div>
650                                         
651                                 </div>
652
653                                 
654                         </div>
655
656                 
657                 </div>
658         
659
660         </div>
661
662
663         <div id="rdoc-debugging-section-dump" class="debugging-section">
664         
665                 <p>Disabled; run with --debug to generate this.</p>
666         
667         </div>
668
669         <div id="validator-badges">
670                 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
671                 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
672                         Rdoc Generator</a> 1.1.6</small>.</p>
673         </div>
674
675 </body>
676 </html>
677