Class: PuppetWebhook::Mcollective
- Inherits:
-
Object
- Object
- PuppetWebhook::Mcollective
- Includes:
- MCollective::RPC
- Defined in:
- lib/plugins/mcollective.rb
Overview
Creates an Mcollective Agent object for running MCO agents
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
- #client ⇒ Object
-
#initialize(agent, command, timeouts = nil, options = nil, nodes = [], **args) ⇒ Mcollective
constructor
rubocop:disable Metrics/ParameterLists.
- #run ⇒ Object
Constructor Details
#initialize(agent, command, timeouts = nil, options = nil, nodes = [], **args) ⇒ Mcollective
rubocop:disable Metrics/ParameterLists
9 10 11 12 13 14 15 16 17 |
# File 'lib/plugins/mcollective.rb', line 9 def initialize(agent, command, timeouts = nil, = nil, nodes = [], **args) # rubocop:disable Metrics/ParameterLists @agent = agent @command = command @timeout = timeouts[:timeout] || '120' @dtimeout = timeouts[:dtimeout] || '10' @options = @nodes = nodes @args = args end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
6 7 8 |
# File 'lib/plugins/mcollective.rb', line 6 def results @results end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
6 7 8 |
# File 'lib/plugins/mcollective.rb', line 6 def stats @stats end |
Instance Method Details
#client ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/plugins/mcollective.rb', line 31 def client client = MCollective::RPC::Client.new(@agent, config_file: MCollective::Util.config_file_for_user, options: MCollective::Util.) # rubocop:disable Metrics/LineLength client.config = @options if @options client.timeout = @timeout if @timeout client.discovery_timeout = @dtimeout if @dtimeout client.progress = false client end |
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/plugins/mcollective.rb', line 19 def run LOGGER.info("Starting request for #{@agent}##{@command}") begin @results = client.send(@command, @args) rescue StandardError => e LOGGER.error("Error: #{e}") end @stats = client.stats end |