3 # This is a base class that other registration plugins can use
4 # to handle regular announcements to the mcollective
6 # The configuration file determines how often registration messages
7 # gets sent using the _registerinterval_ option, the plugin runs in the
8 # background in a thread.
10 # Register plugins that inherits base
11 def self.inherited(klass)
12 PluginManager << {:type => "registration_plugin", :class => klass.to_s}
15 # Creates a background thread that periodically send a registration notice.
17 # The actual registration notices comes from the 'body' method of the registration
20 return false if interval == 0
29 Log.error("Sending registration message failed: #{e}")
41 filter = Util.empty_filter
42 filter["agent"] << "registration"
47 main_collective = config.main_collective
49 collective = config.registration_collective || main_collective
51 unless config.collectives.include?(collective)
52 Log.warn("Sending registration to #{main_collective}: #{collective} is not a valid collective")
53 collective = main_collective
60 config.registerinterval
65 Log.debug("Skipping registration due to nil body")
67 req = Message.new(message, nil, {:type => :request, :agent => "registration", :collective => target_collective, :filter => msg_filter})
70 Log.debug("Sending registration #{req.requestid} to collective #{req.collective}")