Parent

Class/Module Index [+]

Quicksearch

MCollective::Registration::Base

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.

Public Class Methods

inherited(klass) click to toggle source

Register plugins that inherits base

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

Public Instance Methods

body() click to toggle source
# File lib/mcollective/registration/base.rb, line 67
def body
  raise "Registration Plugins must implement the #body method"
end
config() click to toggle source
# File lib/mcollective/registration/base.rb, line 27
def config
  Config.instance
end
interval() click to toggle source
# File lib/mcollective/registration/base.rb, line 50
def interval
  config.registerinterval
end
msg_filter() click to toggle source
# File lib/mcollective/registration/base.rb, line 31
def msg_filter
  filter = Util.empty_filter
  filter["agent"] << "registration"
  filter
end
publish(message) click to toggle source
# File lib/mcollective/registration/base.rb, line 54
def publish(message)
  unless message
    Log.debug("Skipping registration due to nil body")
  else
    req = Message.new(message, nil, {:type => :request, :agent => "registration", :collective => target_collective, :filter => msg_filter})
    req.encode!

    Log.debug("Sending registration #{req.requestid} to collective #{req.collective}")

    req.publish
  end
end
run(connection) click to toggle source

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
def run(connection)
  return false if interval == 0

  Thread.new do
    publish_thread(connection)
  end
end
target_collective() click to toggle source
# File lib/mcollective/registration/base.rb, line 37
def target_collective
  main_collective = config.main_collective

  collective = config.registration_collective || main_collective

  unless config.collectives.include?(collective)
    Log.warn("Sending registration to #{main_collective}: #{collective} is not a valid collective")
    collective = main_collective
  end

  return collective
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.