Class: MCollective::DDL::DiscoveryDDL

Inherits:
Base
  • Object
show all
Defined in:
lib/mcollective/ddl/discoveryddl.rb

Overview

DDL for discovery plugins, a full example can be seen below

metadata :name => “mc”,

:description => "MCollective Broadcast based discovery",
:author      => "R.I.Pienaar <[email protected]>",
:license     => "ASL 2.0",
:version     => "0.1",
:url         => "https://docs.puppetlabs.com/mcollective/",
:timeout     => 2

discovery do

capabilities [:classes, :facts, :identity, :agents, :compound]

end

Instance Attribute Summary

Attributes inherited from Base

#entities, #meta, #pluginname, #plugintype, #requirements, #usage

Instance Method Summary collapse

Methods inherited from Base

#findddlfile, #help, #initialize, #input, #loadddlfile, #metadata, #output, #requires, #template_for_plugintype, #validate_input_argument, #validate_requirements

Constructor Details

This class inherits a constructor from MCollective::DDL::Base

Instance Method Details

#capabilities(*caps) ⇒ Object

records valid capabilities for discovery plugins



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mcollective/ddl/discoveryddl.rb', line 22

def capabilities(*caps)
  caps = [caps].flatten

  raise "Discovery plugin capabilities can't be empty" if caps.empty?

  caps.each do |cap|
    if [:classes, :facts, :identity, :agents, :compound].include?(cap)
      @entities[:discovery][:capabilities] << cap
    else
      raise "%s is not a valid capability, valid capabilities are :classes, :facts, :identity, :agents and :compound" % cap
    end
  end
end

#discovery(&block) ⇒ Object

Creates the definition for new discovery plugins

discovery do
   capabilities [:classes, :facts, :identity, :agents, :compound]
end


41
42
43
44
45
46
47
48
49
# File 'lib/mcollective/ddl/discoveryddl.rb', line 41

def discovery(&block)
  raise "Discovery plugins can only have one definition" if @entities[:discovery]

  @entities[:discovery] = {:capabilities => []}

  @current_entity = :discovery
  block.call if block_given?
  @current_entity = nil
end

#discovery_interfaceObject



17
18
19
# File 'lib/mcollective/ddl/discoveryddl.rb', line 17

def discovery_interface
  @entities[:discovery]
end