Class: MCollective::Util::Playbook::Nodes::McollectiveNodes

Inherits:
Object
  • Object
show all
Defined in:
lib/mcollective/util/playbook/nodes/mcollective_nodes.rb

Instance Method Summary collapse

Constructor Details

#initializeMcollectiveNodes



6
7
8
9
10
11
12
13
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 6

def initialize
  @discovery_method = "mc"
  @agents = []
  @facts = []
  @classes = []
  @identity = []
  @compound = nil
end

Instance Method Details

#client(from_cache: true) ⇒ RPC::Client

Creates and cache an RPC::Client for the configured agent



24
25
26
27
28
29
30
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 24

def client(from_cache: true)
  if from_cache
    @_rpc_client ||= create_and_configure_client
  else
    create_and_configure_client
  end
end

#create_and_configure_clientRPC::Client

TODO:

discovery

Creates a new RPC::Client and configures it with the configured settings



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 36

def create_and_configure_client
  client = RPC::Client.new(@agents[0], :configfile => Util.config_file_for_user, :options => Util.default_options)
  client.progress = false
  client.discovery_method = @discovery_method

  @classes.each do |filter|
    client.class_filter(filter)
  end

  @facts.each do |filter|
    client.fact_filter(filter)
  end

  @agents.each do |filter|
    client.agent_filter(filter)
  end

  @identity.each do |filter|
    client.identity_filter(filter)
  end

  client.compound_filter(@compound) if @compound

  client
end

#discoverObject



79
80
81
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 79

def discover
  client.discover
end

#from_hash(data) ⇒ McollectiveNodes

Initialize the nodes source from a hash



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 66

def from_hash(data)
  @discovery_method = data.fetch("discovery_method", "mc")
  @agents = data.fetch("agents", ["rpcutil"])
  @facts = data.fetch("facts", [])
  @classes = data.fetch("classes", [])
  @identity = data.fetch("identities", [])
  @compound = data["compound"]

  @_rpc_client = nil

  self
end

#prepareObject



15
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 15

def prepare; end

#validate_configuration!Object



18
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 18

def validate_configuration!; end