Class MCollective::Registration::Base
In: lib/mcollective/registration/base.rb
Parent: Object

This is a base class that other registration plugins can use to handle regular announcements to the mcollective

The configuration file determines how often registration messages gets sent using the registerinterval option, the plugin runs in the background in a thread.

Methods

inherited   run  

Public Class methods

Register plugins that inherits base

[Source]

    # File lib/mcollective/registration/base.rb, line 11
11:             def self.inherited(klass)
12:                 PluginManager << {:type => "registration_plugin", :class => klass.to_s}
13:             end

Public Instance methods

Creates a background thread that periodically send a registration notice.

The actual registration notices comes from the ‘body’ method of the registration plugins.

[Source]

    # File lib/mcollective/registration/base.rb, line 19
19:             def run(connection)
20:                 config = Config.instance
21:                 return if config.registerinterval == 0
22: 
23:                 Thread.new do
24:                     loop do
25:                         begin
26:                             target = Util.make_target("registration", :command, config.main_collective)
27:                             reqid = Digest::MD5.hexdigest("#{config.identity}-#{Time.now.to_f.to_s}-#{target}")
28:                             filter = {"agent" => "registration"}
29: 
30:                             registration_message = body
31: 
32:                             unless registration_message.nil?
33:                                 req = PluginManager["security_plugin"].encoderequest(config.identity, target, registration_message, reqid, filter)
34: 
35:                                 Log.debug("Sending registration #{reqid} to #{target}")
36:                                 connection.send(target, req)
37:                             else
38:                                 Log.debug("Skipping registration due to nil body")
39:                             end
40: 
41:                             sleep config.registerinterval
42:                         rescue Exception => e
43:                             Log.error("Sending registration message failed: #{e}")
44:                             sleep config.registerinterval
45:                         end
46:                     end
47:                 end
48:             end

[Validate]