Class: MCollective::Registration::Base

### Home Classes Methods

### In Files

- lib/mcollective/registration/base.rb

### Parent

Object

### Methods

- ::inherited
- #config
- #interval
- #msg_filter
- #publish
- #run
- #target_collective

### Files

- COPYING
- README
- Rakefile
- PLACEHOLDER
- PLACEHOLDER

### Class/Module Index

Quicksearch

- MCollective
- MCollective::Agent
- MCollective::Agents
- MCollective::Aggregate
- MCollective::Aggregate::Base
- MCollective::Aggregate::Result
- MCollective::Aggregate::Result::Base
- MCollective::Aggregate::Result::CollectionResult
- MCollective::Aggregate::Result::NumericResult
- MCollective::Application
- MCollective::Applications
- MCollective::Client
- MCollective::Config
- MCollective::Connector
- MCollective::Connector::Base
- MCollective::DDL
- MCollective::DDLValidationError
- MCollective::Data
- MCollective::Data::Base
- MCollective::Data::Result
- MCollective::Discovery
- MCollective::Facts
- MCollective::Facts::Base
- MCollective::Generators
- MCollective::Generators::AgentGenerator
- MCollective::Generators::Base
- MCollective::Generators::DataGenerator
- MCollective::InvalidRPCData
- MCollective::Log
- MCollective::Logger
- MCollective::Logger::Base
- MCollective::Logger::Console_logger
- MCollective::Logger::File_logger
- MCollective::Logger::Syslog_logger
- MCollective::Matcher
- MCollective::Matcher::Parser
- MCollective::Matcher::Scanner
- MCollective::Message
- MCollective::MissingRPCData
- MCollective::MsgDoesNotMatchRequestID
- MCollective::MsgTTLExpired
- MCollective::NotTargettedAtUs
- MCollective::Optionparser
- MCollective::PluginManager
- MCollective::PluginPackager
- MCollective::PluginPackager::AgentDefinition
- MCollective::PluginPackager::StandardDefinition
- MCollective::RPC
- MCollective::RPC::ActionRunner
- MCollective::RPC::Agent
- MCollective::RPC::Audit
- MCollective::RPC::Client
- MCollective::RPC::Helpers
- MCollective::RPC::Progress
- MCollective::RPC::Reply
- MCollective::RPC::Request
- MCollective::RPC::Result
- MCollective::RPC::Stats
- MCollective::RPCAborted
- MCollective::RPCError
- MCollective::Registration
- MCollective::Registration::Base
- MCollective::Runner
- MCollective::RunnerStats
- MCollective::SSL
- MCollective::Security
- MCollective::Security::Base
- MCollective::SecurityValidationFailed
- MCollective::Shell
- MCollective::UnixDaemon
- MCollective::UnknownRPCAction
- MCollective::UnknownRPCError
- MCollective::Util
- MCollective::WindowsDaemon
- Array
- Dir
- Object
- String
- Symbol

No matching classes.

# 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 Instance Methods

config() click to toggle source

    # File lib/mcollective/registration/base.rb, line 36
    def config
      Config.instance
    end

interval() click to toggle source

    # File lib/mcollective/registration/base.rb, line 59
    def interval
      config.registerinterval
    end

msg_filter() click to toggle source

    # File lib/mcollective/registration/base.rb, line 40
    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 63
    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
        loop do
          begin
            publish(body)

            sleep interval
          rescue Exception => e
            Log.error("Sending registration message failed: #{e}")
            sleep interval
          end
        end
      end
    end

target_collective() click to toggle source

    # File lib/mcollective/registration/base.rb, line 46
    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

### 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.