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.
Register plugins that inherits base
# File lib/mcollective/registration/base.rb, line 11 11: def self.inherited(klass) 12: PluginManager << {:type => "registration_plugin", :class => klass.to_s} 13: end
Creates a background thread that periodically send a registration notice.
The actual registration notices comes from the ‘body’ method of the registration plugins.
# 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) 27: reqid = Digest::MD5.hexdigest("#{config.identity}-#{Time.now.to_f.to_s}-#{target}") 28: filter = {"agent" => "registration"} 29: req = PluginManager["security_plugin"].encoderequest(config.identity, target, body, reqid, filter) 30: 31: Log.instance.debug("Sending registration #{reqid} to #{target}") 32: connection.send(target, req) 33: 34: sleep config.registerinterval 35: rescue Exception => e 36: Log.instance.error("Sending registration message failed: #{e}") 37: sleep config.registerinterval 38: end 39: end 40: end 41: end