### Home Classes Methods

### In Files

- lib/mcollective/data.rb
- lib/mcollective/data/base.rb
- lib/mcollective/data/result.rb

### Namespace

- CLASS MCollective::Data::Base
- CLASS MCollective::Data::Result

### Methods

- ::[]
- ::ddl
- ::ddl_has_output?
- ::ddl_transform_input
- ::ddl_validate
- ::load_data_sources
- ::method_missing
- ::pluginname

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

### Public Class Methods

[](plugin) click to toggle source

    # File lib/mcollective/data.rb, line 26
    def self.[](plugin)
      PluginManager[pluginname(plugin)]
    end

ddl(plugin) click to toggle source

    # File lib/mcollective/data.rb, line 37
    def self.ddl(plugin)
      DDL.new(pluginname(plugin), :data)
    end

ddl_has_output?(ddl, output) click to toggle source

    # File lib/mcollective/data.rb, line 58
    def self.ddl_has_output?(ddl, output)
      ddl.entities[:data][:output].include?(output.to_sym) rescue false
    end

ddl_transform_input(ddl, input) click to toggle source

For an input where the DDL requests a boolean or some number this will convert the input to the right type where possible else just returns the origin input unedited

if anything here goes wrong just return the input value this is not really the end of the world or anything since all that will happen is that DDL validation will fail and the user will get an error, no need to be too defensive here

    # File lib/mcollective/data.rb, line 70
    def self.ddl_transform_input(ddl, input)
      begin
        type = ddl.entities[:data][:input][:query][:type]

        case type
          when :boolean
            return DDL.string_to_boolean(input)

          when :number, :integer, :float
            return DDL.string_to_number(input)
        end
      rescue
      end

      return input
    end

ddl_validate(ddl, argument) click to toggle source

    # File lib/mcollective/data.rb, line 41
    def self.ddl_validate(ddl, argument)
      name = ddl.meta[:name]
      query = ddl.entities[:data]

      raise DDLValidationError, "No dataquery has been defined in the DDL for data plugin #{name}" unless query

      input = query[:input]
      output = query[:output]

      raise DDLValidationError, "No :query input has been defined in the DDL for data plugin #{name}" unless input[:query]
      raise DDLValidationError, "No output has been defined in the DDL for data plugin #{name}" if output.keys.empty?

      return true if argument.nil? && input[:query][:optional]

      ddl.validate_input_argument(input, :query, argument)
    end

load_data_sources() click to toggle source

    # File lib/mcollective/data.rb, line 6
    def self.load_data_sources
      PluginManager.find_and_load("data")

      PluginManager.grep(/_data$/).each do |plugin|
        begin
          unless PluginManager[plugin].class.activate?
            Log.debug("Disabling data plugin %s due to plugin activation policy" % plugin)
            PluginManager.delete(plugin)
          end
        rescue Exception => e
          Log.debug("Disabling data plugin %s due to exception #{e.class}: #{e}" % plugin)
          PluginManager.delete(plugin)
        end
      end
    end

method_missing(method, *args) click to toggle source

Data.package(“httpd”).architecture

    # File lib/mcollective/data.rb, line 31
    def self.method_missing(method, *args)
      super unless PluginManager.include?(pluginname(method))

      PluginManager[pluginname(method)].lookup(args.first)
    end

pluginname(plugin) click to toggle source

    # File lib/mcollective/data.rb, line 22
    def self.pluginname(plugin)
      plugin.to_s =~ /_data$/ ? plugin.to_s.downcase : "%s_data" % plugin.to_s.downcase
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.