Class: MCollective::Util::Playbook::Nodes::McollectiveNodes
- Inherits:
-
Object
- Object
- MCollective::Util::Playbook::Nodes::McollectiveNodes
- Defined in:
- lib/mcollective/util/playbook/nodes/mcollective_nodes.rb
Instance Method Summary collapse
-
#client(from_cache: true) ⇒ RPC::Client
Creates and cache an RPC::Client for the configured agent.
-
#create_and_configure_client ⇒ RPC::Client
Creates a new RPC::Client and configures it with the configured settings.
- #discover ⇒ Object
-
#from_hash(data) ⇒ McollectiveNodes
Initialize the nodes source from a hash.
-
#initialize ⇒ McollectiveNodes
constructor
A new instance of McollectiveNodes.
- #prepare ⇒ Object
- #validate_configuration! ⇒ Object
Constructor Details
#initialize ⇒ McollectiveNodes
Returns a new instance of McollectiveNodes.
6 7 8 9 10 11 12 13 14 |
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 6 def initialize @discovery_method = "mc" @agents = [] @facts = [] @classes = [] @identity = [] @federations = [] @compound = nil end |
Instance Method Details
#client(from_cache: true) ⇒ RPC::Client
Creates and cache an RPC::Client for the configured agent
25 26 27 28 29 30 31 |
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 25 def client(from_cache: true) if from_cache @_rpc_client ||= create_and_configure_client else create_and_configure_client end end |
#create_and_configure_client ⇒ RPC::Client
TODO:
discovery
Creates a new RPC::Client and configures it with the configured settings
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 37 def create_and_configure_client client = RPC::Client.new(@agents[0], :configfile => Util.config_file_for_user, :options => Util.) 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 |
#discover ⇒ Object
91 92 93 |
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 91 def discover client.discover end |
#from_hash(data) ⇒ McollectiveNodes
Initialize the nodes source from a hash
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 67 def from_hash(data) @config = Config.instance # Allow specifying federations at playbook execution time if data["federations"] if data["federations"].instance_of?(String) @config.federations = [data["federations"]] else @config.federations = data["federations"] end end @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 |
#prepare ⇒ Object
16 |
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 16 def prepare; end |
#validate_configuration! ⇒ Object
TODO:
19 |
# File 'lib/mcollective/util/playbook/nodes/mcollective_nodes.rb', line 19 def validate_configuration!; end |