Class: MCollective::Data::Base

### Home Classes Methods

### In Files

- lib/mcollective/data/base.rb

### Parent

Object

### Methods

- ::activate?
- ::activate_when
- ::inherited
- ::new
- ::query
- #ddl_validate
- #lookup
- #startup_hook

### 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::Data::Base

### Attributes

ddl[R]
name[R]
result[R]
timeout[R]

### Public Instance Methods

ddl_validate(what) click to toggle source

    # File lib/mcollective/data/base.rb, line 46
    def ddl_validate(what)
      Data.ddl_validate(@ddl, what)
    end

lookup(what) click to toggle source

    # File lib/mcollective/data/base.rb, line 22
    def lookup(what)
      ddl_validate(what)

      Log.debug("Doing data query %s for '%s'" % [ @name, what ])

      Timeout::timeout(@timeout) do
        query_data(what)
      end

      @result
    rescue Timeout::Error
      # Timeout::Error is a inherited from Interrupt which seems a really
      # strange choice, making it an equivelant of ^C and such.  Catch it
      # and raise something less critical that will not the runner to just
      # give up the ghost
      msg = "Data plugin %s timed out on query '%s'" % [@name, what]
      Log.error(msg)
      raise MsgTTLExpired, msg
    end

startup_hook() click to toggle source

    # File lib/mcollective/data/base.rb, line 64
    def startup_hook;end

### Public Class Methods

activate?() click to toggle source

Always be active unless a specific block is given with activate_when

    # File lib/mcollective/data/base.rb, line 60
    def self.activate?
      return true
    end

activate_when(&block) click to toggle source

activate_when do

    file.exist?("/usr/bin/puppet")

end

    # File lib/mcollective/data/base.rb, line 53
    def self.activate_when(&block)
      (class << self; self; end).instance_eval do
        define_method("activate?", &block)
      end
    end

inherited(klass) click to toggle source

Register plugins that inherits base

    # File lib/mcollective/data/base.rb, line 7
    def self.inherited(klass)
      type = klass.to_s.split("::").last.downcase

      PluginManager << {:type => type, :class => klass.to_s, :single_instance => false}
    end

new() click to toggle source

    # File lib/mcollective/data/base.rb, line 13
    def initialize
      @name = self.class.to_s.split("::").last.downcase
      @ddl = DDL.new(@name, :data)
      @result = Result.new
      @timeout = @ddl.meta[:timeout] || 1

      startup_hook
    end

query(&block) click to toggle source

    # File lib/mcollective/data/base.rb, line 42
    def self.query(&block)
      self.module_eval { define_method("query_data", &block) }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.