### Home Classes Methods

### In Files

- lib/mcollective/discovery.rb

### Parent

Object

### Methods

- ::new
- #check_capabilities
- #ddl
- #discover
- #discovery_class
- #discovery_method
- #find_known_methods
- #force_direct_mode?
- #force_discovery_method_by_filter
- #has_method?

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

### Public Instance Methods

check_capabilities(filter) click to toggle source

Agent filters are always present no matter what, so we cant raise an error if the capabilities suggest the discovery method cant do agents we just have to rely on the discovery plugin to not do stupid things in the presense of a agent filter

    # File lib/mcollective/discovery.rb, line 62
    def check_capabilities(filter)
      capabilities = ddl.discovery_interface[:capabilities]

      unless capabilities.include?(:classes)
        raise "Cannot use class filters while using the '%s' discovery method" % discovery_method unless filter["cf_class"].empty?
      end

      unless capabilities.include?(:facts)
        raise "Cannot use fact filters while using the '%s' discovery method" % discovery_method unless filter["fact"].empty?
      end

      unless capabilities.include?(:identity)
        raise "Cannot use identity filters while using the '%s' discovery method" % discovery_method unless filter["identity"].empty?
      end

      unless capabilities.include?(:compound)
        raise "Cannot use compound filters while using the '%s' discovery method" % discovery_method unless filter["compound"].empty?
      end
    end

ddl() click to toggle source

    # File lib/mcollective/discovery.rb, line 47
    def ddl
      @ddl ||= DDL.new(discovery_method, :discovery)

      # if the discovery method got changed we might have an old DDL cached
      # this will detect that and reread the correct DDL from disk
      unless @ddl.meta[:name] == discovery_method
        @ddl = DDL.new(discovery_method, :discovery)
      end

      return @ddl
    end

discover(filter, timeout, limit) click to toggle source

    # File lib/mcollective/discovery.rb, line 96
    def discover(filter, timeout, limit)
      raise "Limit has to be an integer" unless limit.is_a?(Fixnum)

      if force_discovery_method_by_filter(filter)
        timeout = ddl.meta[:timeout] + @client.timeout_for_compound_filter(filter["compound"])
      else
        timeout = ddl.meta[:timeout] unless timeout
      end

      check_capabilities(filter)

      discovered = discovery_class.discover(filter, timeout, limit, @client)

      if limit > 0
        return discovered[0,limit]
      else
        return discovered
      end
    end

discovery_class() click to toggle source

    # File lib/mcollective/discovery.rb, line 39
    def discovery_class
      method = discovery_method.capitalize

      PluginManager.loadclass("MCollective::Discovery::#{method}") unless self.class.const_defined?(method)

      self.class.const_get(method)
    end

discovery_method() click to toggle source

    # File lib/mcollective/discovery.rb, line 21
    def discovery_method
      method = "mc"

      if @client.options[:discovery_method]
        method = @client.options[:discovery_method]
      else
        method = @default_method
      end

      raise "Unknown discovery method %s" % method unless has_method?(method)

      unless method == "mc"
        raise "Custom discovery methods require direct addressing mode" unless Config.instance.direct_addressing
      end

      return method
    end

find_known_methods() click to toggle source

    # File lib/mcollective/discovery.rb, line 9
    def find_known_methods
      PluginManager.find("discovery")
    end

force_direct_mode?() click to toggle source

    # File lib/mcollective/discovery.rb, line 17
    def force_direct_mode?
      discovery_method != "mc"
    end

force_discovery_method_by_filter(filter) click to toggle source

checks if compound filters are used and then forces the ‘mc’ discovery plugin

    # File lib/mcollective/discovery.rb, line 83
    def force_discovery_method_by_filter(filter)
      unless discovery_method == "mc"
        unless filter["compound"].empty?
          Log.info "Switching to mc discovery method because compound filters are used"
          @client.options[:discovery_method] = "mc"

          return true
        end
      end

      return false
    end

has_method?(method) click to toggle source

    # File lib/mcollective/discovery.rb, line 13
    def has_method?(method)
      @known_methods.include?(method)
    end

### Public Class Methods

new(client) click to toggle source

    # File lib/mcollective/discovery.rb, line 3
    def initialize(client)
      @known_methods = find_known_methods
      @default_method = Config.instance.default_discovery_method
      @client = client
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.