Update version according to OSCI-883
[packages/precise/mcollective.git] / doc / MCollective / Facts / Base.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::Facts::Base</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/facts/base_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
32                                                         class="thickbox" title="lib/mcollective/facts/base.rb">lib/mcollective/facts/base.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="#M000260">::inherited</a></li>
63                                         
64                                         <li><a href="#M000259">::new</a></li>
65                                         
66                                         <li><a href="#M000265">#force_reload?</a></li>
67                                         
68                                         <li><a href="#M000261">#get_fact</a></li>
69                                         
70                                         <li><a href="#M000263">#get_facts</a></li>
71                                         
72                                         <li><a href="#M000264">#has_fact?</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::Facts::Base</h1>
336
337                 <div id="description">
338                         <p>
339 A base class for fact providers, to make a new fully functional fact
340 provider inherit from this and simply provide a self.get_facts method that
341 returns a hash like:
342 </p>
343 <pre>
344  {&quot;foo&quot; =&gt; &quot;bar&quot;,
345   &quot;bar&quot; =&gt; &quot;baz&quot;}
346 </pre>
347
348                 </div>
349
350                 <!-- Constants -->
351                 
352
353                 <!-- Attributes -->
354                 
355
356                 <!-- Methods -->
357                 
358                 <div id="public-class-method-details" class="method-section section">
359                         <h3 class="section-header">Public Class Methods</h3>
360
361                 
362                         <div id="inherited-method" class="method-detail ">
363                                 <a name="M000260"></a>
364
365                                 <div class="method-heading">
366                                 
367                                         <span class="method-name">inherited</span><span
368                                                 class="method-args">(klass)</span>
369                                         <span class="method-click-advice">click to toggle source</span>
370                                 
371                                 </div>
372
373                                 <div class="method-description">
374                                         
375                                         <p>
376 Registers new fact sources into the plugin manager
377 </p>
378                                         
379
380                                         
381                                         <div class="method-source-code"
382                                                 id="inherited-source">
383 <pre>
384     <span class="ruby-comment cmt"># File lib/mcollective/facts/base.rb, line 17</span>
385 17:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">inherited</span>(<span class="ruby-identifier">klass</span>)
386 18:         <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-value str">&quot;facts_plugin&quot;</span>, <span class="ruby-identifier">:class</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">to_s</span>}
387 19:       <span class="ruby-keyword kw">end</span></pre>
388                                         </div>
389                                         
390                                 </div>
391
392                                 
393                         </div>
394
395                 
396                         <div id="new-method" class="method-detail ">
397                                 <a name="M000259"></a>
398
399                                 <div class="method-heading">
400                                 
401                                         <span class="method-name">new</span><span
402                                                 class="method-args">()</span>
403                                         <span class="method-click-advice">click to toggle source</span>
404                                 
405                                 </div>
406
407                                 <div class="method-description">
408                                         
409                                         <p class="missing-docs">(Not documented)</p>
410                                         
411
412                                         
413                                         <div class="method-source-code"
414                                                 id="new-source">
415 <pre>
416     <span class="ruby-comment cmt"># File lib/mcollective/facts/base.rb, line 10</span>
417 10:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
418 11:         <span class="ruby-ivar">@facts</span> = {}
419 12:         <span class="ruby-ivar">@last_good_facts</span> = {}
420 13:         <span class="ruby-ivar">@last_facts_load</span> = <span class="ruby-value">0</span>
421 14:       <span class="ruby-keyword kw">end</span></pre>
422                                         </div>
423                                         
424                                 </div>
425
426                                 
427                         </div>
428
429                 
430                 </div>
431         
432                 <div id="public-instance-method-details" class="method-section section">
433                         <h3 class="section-header">Public Instance Methods</h3>
434
435                 
436                         <div id="force-reload--method" class="method-detail ">
437                                 <a name="M000265"></a>
438
439                                 <div class="method-heading">
440                                 
441                                         <span class="method-name">force_reload?</span><span
442                                                 class="method-args">()</span>
443                                         <span class="method-click-advice">click to toggle source</span>
444                                 
445                                 </div>
446
447                                 <div class="method-description">
448                                         
449                                         <p>
450 Plugins can override this to provide forced fact invalidation
451 </p>
452                                         
453
454                                         
455                                         <div class="method-source-code"
456                                                 id="force-reload--source">
457 <pre>
458     <span class="ruby-comment cmt"># File lib/mcollective/facts/base.rb, line 81</span>
459 81:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">force_reload?</span>
460 82:         <span class="ruby-keyword kw">false</span>
461 83:       <span class="ruby-keyword kw">end</span></pre>
462                                         </div>
463                                         
464                                 </div>
465
466                                 
467                         </div>
468
469                 
470                         <div id="get-fact-method" class="method-detail ">
471                                 <a name="M000261"></a>
472
473                                 <div class="method-heading">
474                                 
475                                         <span class="method-name">get_fact</span><span
476                                                 class="method-args">(fact=nil)</span>
477                                         <span class="method-click-advice">click to toggle source</span>
478                                 
479                                 </div>
480
481                                 <div class="method-description">
482                                         
483                                         <p>
484 Returns the value of a single fact
485 </p>
486                                         
487
488                                         
489                                         <div class="method-source-code"
490                                                 id="get-fact-source">
491 <pre>
492     <span class="ruby-comment cmt"># File lib/mcollective/facts/base.rb, line 22</span>
493 22:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_fact</span>(<span class="ruby-identifier">fact</span>=<span class="ruby-keyword kw">nil</span>)
494 23:         <span class="ruby-identifier">config</span> = <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>
495 24: 
496 25:         <span class="ruby-identifier">cache_time</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">fact_cache_time</span> <span class="ruby-operator">||</span> <span class="ruby-value">300</span>
497 26: 
498 27:         <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">exclusive</span> <span class="ruby-keyword kw">do</span>
499 28:           <span class="ruby-keyword kw">begin</span>
500 29:             <span class="ruby-keyword kw">if</span> (<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@last_facts_load</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">cache_time</span>.<span class="ruby-identifier">to_i</span> ) <span class="ruby-operator">||</span> <span class="ruby-identifier">force_reload?</span>
501 30:               <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Resetting facter cache, now: #{Time.now.to_i} last-known-good: #{@last_facts_load}&quot;</span>)
502 31: 
503 32:               <span class="ruby-identifier">tfacts</span> = <span class="ruby-identifier">load_facts_from_source</span>
504 33: 
505 34:               <span class="ruby-comment cmt"># Force reset to last known good state on empty facts</span>
506 35:               <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Got empty facts&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tfacts</span>.<span class="ruby-identifier">empty?</span>
507 36: 
508 37:               <span class="ruby-ivar">@facts</span>.<span class="ruby-identifier">clear</span>
509 38: 
510 39:               <span class="ruby-identifier">tfacts</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
511 40:                 <span class="ruby-ivar">@facts</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
512 41:               <span class="ruby-keyword kw">end</span>
513 42: 
514 43:               <span class="ruby-ivar">@last_good_facts</span> = <span class="ruby-ivar">@facts</span>.<span class="ruby-identifier">clone</span>
515 44:               <span class="ruby-ivar">@last_facts_load</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_i</span>
516 45:             <span class="ruby-keyword kw">else</span>
517 46:               <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;Using cached facts now: #{Time.now.to_i} last-known-good: #{@last_facts_load}&quot;</span>)
518 47:             <span class="ruby-keyword kw">end</span>
519 48:           <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>
520 49:             <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;Failed to load facts: #{e.class}: #{e}&quot;</span>)
521 50: 
522 51:             <span class="ruby-comment cmt"># Avoid loops where failing fact loads cause huge CPU</span>
523 52:             <span class="ruby-comment cmt"># loops, this way it only retries once every cache_time</span>
524 53:             <span class="ruby-comment cmt"># seconds</span>
525 54:             <span class="ruby-ivar">@last_facts_load</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_i</span>
526 55: 
527 56:             <span class="ruby-comment cmt"># Revert to last known good state</span>
528 57:             <span class="ruby-ivar">@facts</span> = <span class="ruby-ivar">@last_good_facts</span>.<span class="ruby-identifier">clone</span>
529 58:           <span class="ruby-keyword kw">end</span>
530 59:         <span class="ruby-keyword kw">end</span>
531 60: 
532 61: 
533 62:         <span class="ruby-comment cmt"># If you do not supply a specific fact all facts will be returned</span>
534 63:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fact</span>.<span class="ruby-identifier">nil?</span>
535 64:           <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@facts</span>
536 65:         <span class="ruby-keyword kw">else</span>
537 66:           <span class="ruby-ivar">@facts</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">fact</span>) <span class="ruby-operator">?</span> <span class="ruby-ivar">@facts</span>[<span class="ruby-identifier">fact</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
538 67:         <span class="ruby-keyword kw">end</span>
539 68:       <span class="ruby-keyword kw">end</span></pre>
540                                         </div>
541                                         
542                                 </div>
543
544                                 
545                         </div>
546
547                 
548                         <div id="get-facts-method" class="method-detail ">
549                                 <a name="M000263"></a>
550
551                                 <div class="method-heading">
552                                 
553                                         <span class="method-name">get_facts</span><span
554                                                 class="method-args">()</span>
555                                         <span class="method-click-advice">click to toggle source</span>
556                                 
557                                 </div>
558
559                                 <div class="method-description">
560                                         
561                                         <p>
562 Returns all facts
563 </p>
564                                         
565
566                                         
567                                         <div class="method-source-code"
568                                                 id="get-facts-source">
569 <pre>
570     <span class="ruby-comment cmt"># File lib/mcollective/facts/base.rb, line 71</span>
571 71:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_facts</span>
572 72:         <span class="ruby-identifier">get_fact</span>(<span class="ruby-keyword kw">nil</span>)
573 73:       <span class="ruby-keyword kw">end</span></pre>
574                                         </div>
575                                         
576                                 </div>
577
578                                 
579                         </div>
580
581                 
582                         <div id="has-fact--method" class="method-detail ">
583                                 <a name="M000264"></a>
584
585                                 <div class="method-heading">
586                                 
587                                         <span class="method-name">has_fact?</span><span
588                                                 class="method-args">(fact)</span>
589                                         <span class="method-click-advice">click to toggle source</span>
590                                 
591                                 </div>
592
593                                 <div class="method-description">
594                                         
595                                         <p>
596 Returns true if we know about a specific fact, false otherwise
597 </p>
598                                         
599
600                                         
601                                         <div class="method-source-code"
602                                                 id="has-fact--source">
603 <pre>
604     <span class="ruby-comment cmt"># File lib/mcollective/facts/base.rb, line 76</span>
605 76:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_fact?</span>(<span class="ruby-identifier">fact</span>)
606 77:         <span class="ruby-identifier">get_fact</span>(<span class="ruby-keyword kw">nil</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">fact</span>)
607 78:       <span class="ruby-keyword kw">end</span></pre>
608                                         </div>
609                                         
610                                 </div>
611
612                                 
613                         </div>
614
615                 
616                 </div>
617         
618
619         </div>
620
621
622         <div id="rdoc-debugging-section-dump" class="debugging-section">
623         
624                 <p>Disabled; run with --debug to generate this.</p>
625         
626         </div>
627
628         <div id="validator-badges">
629                 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
630                 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
631                         Rdoc Generator</a> 1.1.6</small>.</p>
632         </div>
633
634 </body>
635 </html>
636