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>Class: MCollective::Registration::Base</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/registration/base_rb.html?TB_iframe=true&height=550&width=785"
32 class="thickbox" title="lib/mcollective/registration/base.rb">lib/mcollective/registration/base.rb</a></li>
41 <div id="class-metadata">
45 <div id="parent-class-section" class="section">
46 <h3 class="section-header">Parent</h3>
48 <p class="link"><a href="../../Object.html">Object</a></p>
53 <!-- Namespace Contents -->
56 <!-- Method Quickref -->
58 <div id="method-list-section" class="section">
59 <h3 class="section-header">Methods</h3>
60 <ul class="link-list">
62 <li><a href="#M000153">::inherited</a></li>
64 <li><a href="#M000155">#config</a></li>
66 <li><a href="#M000158">#interval</a></li>
68 <li><a href="#M000156">#msg_filter</a></li>
70 <li><a href="#M000159">#publish</a></li>
72 <li><a href="#M000154">#run</a></li>
74 <li><a href="#M000157">#target_collective</a></li>
80 <!-- Included Modules -->
84 <div id="project-metadata">
87 <div id="fileindex-section" class="section project-section">
88 <h3 class="section-header">Files</h3>
91 <li class="file"><a href="../../COPYING.html">COPYING</a></li>
93 <li class="file"><a href="../../Gemfile.html">Gemfile</a></li>
95 <li class="file"><a href="../../README.html">README</a></li>
97 <li class="file"><a href="../../Rakefile.html">Rakefile</a></li>
99 <li class="file"><a href="../../etc/client_cfg_dist.html">client.cfg.dist</a></li>
101 <li class="file"><a href="../../etc/data-help_erb.html">data-help.erb</a></li>
103 <li class="file"><a href="../../etc/discovery-help_erb.html">discovery-help.erb</a></li>
105 <li class="file"><a href="../../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
107 <li class="file"><a href="../../etc/metadata-help_erb.html">metadata-help.erb</a></li>
109 <li class="file"><a href="../../etc/msg-help_erb.html">msg-help.erb</a></li>
111 <li class="file"><a href="../../etc/rpc-help_erb.html">rpc-help.erb</a></li>
113 <li class="file"><a href="../../etc/server_cfg_dist.html">server.cfg.dist</a></li>
115 <li class="file"><a href="../../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
117 <li class="file"><a href="../../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
119 <li class="file"><a href="../../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
121 <li class="file"><a href="../../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
123 <li class="file"><a href="../../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
125 <li class="file"><a href="../../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
127 <li class="file"><a href="../../lib/mcollective/locales/en_yml.html">en.yml</a></li>
129 <li class="file"><a href="../../mcollective_init.html">mcollective.init</a></li>
135 <div id="classindex-section" class="section project-section">
136 <h3 class="section-header">Class Index
137 <span class="search-toggle"><img src="../../images/find.png"
138 height="16" width="16" alt="[+]"
139 title="show/hide quicksearch" /></span></h3>
140 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
142 <legend>Quicksearch</legend>
143 <input type="text" name="quicksearch" value=""
144 class="quicksearch-field" />
148 <ul class="link-list">
150 <li><a href="../../MCollective.html">MCollective</a></li>
152 <li><a href="../../MCollective/Agent.html">MCollective::Agent</a></li>
154 <li><a href="../../MCollective/Agents.html">MCollective::Agents</a></li>
156 <li><a href="../../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
158 <li><a href="../../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
160 <li><a href="../../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
162 <li><a href="../../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
164 <li><a href="../../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
166 <li><a href="../../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
168 <li><a href="../../MCollective/Application.html">MCollective::Application</a></li>
170 <li><a href="../../MCollective/Applications.html">MCollective::Applications</a></li>
172 <li><a href="../../MCollective/Cache.html">MCollective::Cache</a></li>
174 <li><a href="../../MCollective/Client.html">MCollective::Client</a></li>
176 <li><a href="../../MCollective/CodedError.html">MCollective::CodedError</a></li>
178 <li><a href="../../MCollective/Config.html">MCollective::Config</a></li>
180 <li><a href="../../MCollective/Connector.html">MCollective::Connector</a></li>
182 <li><a href="../../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
184 <li><a href="../../MCollective/DDL.html">MCollective::DDL</a></li>
186 <li><a href="../../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
188 <li><a href="../../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
190 <li><a href="../../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
192 <li><a href="../../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
194 <li><a href="../../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
196 <li><a href="../../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
198 <li><a href="../../MCollective/Data.html">MCollective::Data</a></li>
200 <li><a href="../../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
202 <li><a href="../../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
204 <li><a href="../../MCollective/Discovery.html">MCollective::Discovery</a></li>
206 <li><a href="../../MCollective/Facts.html">MCollective::Facts</a></li>
208 <li><a href="../../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
210 <li><a href="../../MCollective/Generators.html">MCollective::Generators</a></li>
212 <li><a href="../../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
214 <li><a href="../../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
216 <li><a href="../../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
218 <li><a href="../../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
220 <li><a href="../../MCollective/Log.html">MCollective::Log</a></li>
222 <li><a href="../../MCollective/Logger.html">MCollective::Logger</a></li>
224 <li><a href="../../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
226 <li><a href="../../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
228 <li><a href="../../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
230 <li><a href="../../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
232 <li><a href="../../MCollective/Matcher.html">MCollective::Matcher</a></li>
234 <li><a href="../../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
236 <li><a href="../../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
238 <li><a href="../../MCollective/Message.html">MCollective::Message</a></li>
240 <li><a href="../../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
242 <li><a href="../../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
244 <li><a href="../../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
246 <li><a href="../../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
248 <li><a href="../../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
250 <li><a href="../../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
252 <li><a href="../../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
254 <li><a href="../../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
256 <li><a href="../../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
258 <li><a href="../../MCollective/RPC.html">MCollective::RPC</a></li>
260 <li><a href="../../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
262 <li><a href="../../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
264 <li><a href="../../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
266 <li><a href="../../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
268 <li><a href="../../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
270 <li><a href="../../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
272 <li><a href="../../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
274 <li><a href="../../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
276 <li><a href="../../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
278 <li><a href="../../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
280 <li><a href="../../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
282 <li><a href="../../MCollective/RPCError.html">MCollective::RPCError</a></li>
284 <li><a href="../../MCollective/Registration.html">MCollective::Registration</a></li>
286 <li><a href="../../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
288 <li><a href="../../MCollective/Runner.html">MCollective::Runner</a></li>
290 <li><a href="../../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
292 <li><a href="../../MCollective/SSL.html">MCollective::SSL</a></li>
294 <li><a href="../../MCollective/Security.html">MCollective::Security</a></li>
296 <li><a href="../../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
298 <li><a href="../../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
300 <li><a href="../../MCollective/Shell.html">MCollective::Shell</a></li>
302 <li><a href="../../MCollective/Translatable.html">MCollective::Translatable</a></li>
304 <li><a href="../../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
306 <li><a href="../../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
308 <li><a href="../../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
310 <li><a href="../../MCollective/Util.html">MCollective::Util</a></li>
312 <li><a href="../../MCollective/Validator.html">MCollective::Validator</a></li>
314 <li><a href="../../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
316 <li><a href="../../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
318 <li><a href="../../Array.html">Array</a></li>
320 <li><a href="../../Dir.html">Dir</a></li>
322 <li><a href="../../Object.html">Object</a></li>
324 <li><a href="../../String.html">String</a></li>
326 <li><a href="../../Symbol.html">Symbol</a></li>
329 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
336 <div id="documentation">
337 <h1 class="class">MCollective::Registration::Base</h1>
339 <div id="description">
341 This is a base class that other registration plugins can use to handle
342 regular announcements to the mcollective
345 The configuration file determines how often registration messages gets sent
346 using the <em>registerinterval</em> option, the plugin runs in the
347 background in a thread.
360 <div id="public-class-method-details" class="method-section section">
361 <h3 class="section-header">Public Class Methods</h3>
364 <div id="inherited-method" class="method-detail ">
365 <a name="M000153"></a>
367 <div class="method-heading">
369 <span class="method-name">inherited</span><span
370 class="method-args">(klass)</span>
371 <span class="method-click-advice">click to toggle source</span>
375 <div class="method-description">
378 Register plugins that inherits base
383 <div class="method-source-code"
384 id="inherited-source">
386 <span class="ruby-comment cmt"># File lib/mcollective/registration/base.rb, line 11</span>
387 11: <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>)
388 12: <span class="ruby-constant">PluginManager</span> <span class="ruby-operator"><<</span> {<span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"registration_plugin"</span>, <span class="ruby-identifier">:class</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">to_s</span>}
389 13: <span class="ruby-keyword kw">end</span></pre>
400 <div id="public-instance-method-details" class="method-section section">
401 <h3 class="section-header">Public Instance Methods</h3>
404 <div id="config-method" class="method-detail ">
405 <a name="M000155"></a>
407 <div class="method-heading">
409 <span class="method-name">config</span><span
410 class="method-args">()</span>
411 <span class="method-click-advice">click to toggle source</span>
415 <div class="method-description">
417 <p class="missing-docs">(Not documented)</p>
421 <div class="method-source-code"
424 <span class="ruby-comment cmt"># File lib/mcollective/registration/base.rb, line 36</span>
425 36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">config</span>
426 37: <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>
427 38: <span class="ruby-keyword kw">end</span></pre>
436 <div id="interval-method" class="method-detail ">
437 <a name="M000158"></a>
439 <div class="method-heading">
441 <span class="method-name">interval</span><span
442 class="method-args">()</span>
443 <span class="method-click-advice">click to toggle source</span>
447 <div class="method-description">
449 <p class="missing-docs">(Not documented)</p>
453 <div class="method-source-code"
454 id="interval-source">
456 <span class="ruby-comment cmt"># File lib/mcollective/registration/base.rb, line 59</span>
457 59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">interval</span>
458 60: <span class="ruby-identifier">config</span>.<span class="ruby-identifier">registerinterval</span>
459 61: <span class="ruby-keyword kw">end</span></pre>
468 <div id="msg-filter-method" class="method-detail ">
469 <a name="M000156"></a>
471 <div class="method-heading">
473 <span class="method-name">msg_filter</span><span
474 class="method-args">()</span>
475 <span class="method-click-advice">click to toggle source</span>
479 <div class="method-description">
481 <p class="missing-docs">(Not documented)</p>
485 <div class="method-source-code"
486 id="msg-filter-source">
488 <span class="ruby-comment cmt"># File lib/mcollective/registration/base.rb, line 40</span>
489 40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">msg_filter</span>
490 41: <span class="ruby-identifier">filter</span> = <span class="ruby-constant">Util</span>.<span class="ruby-identifier">empty_filter</span>
491 42: <span class="ruby-identifier">filter</span>[<span class="ruby-value str">"agent"</span>] <span class="ruby-operator"><<</span> <span class="ruby-value str">"registration"</span>
492 43: <span class="ruby-identifier">filter</span>
493 44: <span class="ruby-keyword kw">end</span></pre>
502 <div id="publish-method" class="method-detail ">
503 <a name="M000159"></a>
505 <div class="method-heading">
507 <span class="method-name">publish</span><span
508 class="method-args">(message)</span>
509 <span class="method-click-advice">click to toggle source</span>
513 <div class="method-description">
515 <p class="missing-docs">(Not documented)</p>
519 <div class="method-source-code"
522 <span class="ruby-comment cmt"># File lib/mcollective/registration/base.rb, line 63</span>
523 63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">publish</span>(<span class="ruby-identifier">message</span>)
524 64: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">message</span>
525 65: <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-value str">"Skipping registration due to nil body"</span>)
526 66: <span class="ruby-keyword kw">else</span>
527 67: <span class="ruby-identifier">req</span> = <span class="ruby-constant">Message</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">message</span>, <span class="ruby-keyword kw">nil</span>, {<span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:request</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"registration"</span>, <span class="ruby-identifier">:collective</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">target_collective</span>, <span class="ruby-identifier">:filter</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">msg_filter</span>})
528 68: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">encode!</span>
530 70: <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">"Sending registration #{req.requestid} to collective #{req.collective}"</span>)
532 72: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">publish</span>
533 73: <span class="ruby-keyword kw">end</span>
534 74: <span class="ruby-keyword kw">end</span></pre>
543 <div id="run-method" class="method-detail ">
544 <a name="M000154"></a>
546 <div class="method-heading">
548 <span class="method-name">run</span><span
549 class="method-args">(connection)</span>
550 <span class="method-click-advice">click to toggle source</span>
554 <div class="method-description">
557 Creates a background thread that periodically send a registration notice.
560 The actual registration notices comes from the ‘body’ method of
561 the registration plugins.
566 <div class="method-source-code"
569 <span class="ruby-comment cmt"># File lib/mcollective/registration/base.rb, line 19</span>
570 19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">connection</span>)
571 20: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">interval</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
573 22: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
574 23: <span class="ruby-identifier">loop</span> <span class="ruby-keyword kw">do</span>
575 24: <span class="ruby-keyword kw">begin</span>
576 25: <span class="ruby-identifier">publish</span>(<span class="ruby-identifier">body</span>)
578 27: <span class="ruby-identifier">sleep</span> <span class="ruby-identifier">interval</span>
579 28: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
580 29: <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">"Sending registration message failed: #{e}"</span>)
581 30: <span class="ruby-identifier">sleep</span> <span class="ruby-identifier">interval</span>
582 31: <span class="ruby-keyword kw">end</span>
583 32: <span class="ruby-keyword kw">end</span>
584 33: <span class="ruby-keyword kw">end</span>
585 34: <span class="ruby-keyword kw">end</span></pre>
594 <div id="target-collective-method" class="method-detail ">
595 <a name="M000157"></a>
597 <div class="method-heading">
599 <span class="method-name">target_collective</span><span
600 class="method-args">()</span>
601 <span class="method-click-advice">click to toggle source</span>
605 <div class="method-description">
607 <p class="missing-docs">(Not documented)</p>
611 <div class="method-source-code"
612 id="target-collective-source">
614 <span class="ruby-comment cmt"># File lib/mcollective/registration/base.rb, line 46</span>
615 46: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">target_collective</span>
616 47: <span class="ruby-identifier">main_collective</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">main_collective</span>
618 49: <span class="ruby-identifier">collective</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">registration_collective</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">main_collective</span>
620 51: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">collectives</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">collective</span>)
621 52: <span class="ruby-constant">Log</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-node">"Sending registration to #{main_collective}: #{collective} is not a valid collective"</span>)
622 53: <span class="ruby-identifier">collective</span> = <span class="ruby-identifier">main_collective</span>
623 54: <span class="ruby-keyword kw">end</span>
625 56: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">collective</span>
626 57: <span class="ruby-keyword kw">end</span></pre>
641 <div id="rdoc-debugging-section-dump" class="debugging-section">
643 <p>Disabled; run with --debug to generate this.</p>
647 <div id="validator-badges">
648 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
649 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
650 Rdoc Generator</a> 1.1.6</small>.</p>