Class: Dopi::Command::Mco::Rpc

Inherits:
Dopi::Command show all
Includes:
Dopi::CommandParser::ExitCode, MCollective::RPC
Defined in:
lib/dopi/command/mco/rpc.rb

Instance Attribute Summary

Attributes inherited from Dopi::Command

#hash, #is_verify_command, #node

Instance Method Summary collapse

Methods included from Dopi::CommandParser::ExitCode

#check_exit_code, #expect_exit_codes, #validate_exit_code

Methods inherited from Dopi::Command

create_plugin_instance, delete_plugin_default, delete_plugin_defaults, inherited, #initialize, #load_state, #merged_hash, #meta_run, #meta_valid?, plugin_defaults, set_plugin_defaults, #state_hash, wipe_plugin_defaults

Methods included from State

#delete_on_signal, #on_signal, #reset_signals, #send_signal, #signal_procs, #signals, #state, #state_add_child, #state_auto_evaluate_children, #state_auto_evaluate_children=, #state_changed, #state_children, #state_children_done?, #state_children_failed?, #state_children_partial?, #state_children_ready?, #state_children_running?, #state_children_running_noop?, #state_children_starting?, #state_done?, #state_fail, #state_failed?, #state_finish, #state_partial?, #state_ready, #state_ready?, #state_reset, #state_reset_with_children, #state_run, #state_run_noop, #state_running?, #state_running_noop?, #state_start, #state_starting?, #to_yaml_properties, #update, #update_mutex

Constructor Details

This class inherits a constructor from Dopi::Command

Instance Method Details

#actionObject



62
63
64
65
# File 'lib/dopi/command/mco/rpc.rb', line 62

def action
  @action ||= action_valid? ?
    hash[:action] : nil
end

#agentObject



51
52
53
54
# File 'lib/dopi/command/mco/rpc.rb', line 51

def agent
  @agent ||= agent_valid? ?
    hash[:agent] : nil
end

#argumentsObject



67
68
69
70
# File 'lib/dopi/command/mco/rpc.rb', line 67

def arguments
  @arguments ||= arguments_valid? ?
    hash[:arguments] : {}
end

#optionsObject



56
57
58
59
60
# File 'lib/dopi/command/mco/rpc.rb', line 56

def options
  @options ||= options_valid? ?
    options_defaults.merge(hash[:options]) :
    options_defaults
end

#runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dopi/command/mco/rpc.rb', line 26

def run
  result_ok = true
  flags = {
    :configfile      => DopCommon.config.mco_config,
    :options         => options,
    :exit_on_failure => false
  }
  mc = rpcclient(agent, flags)
  results = mc.custom_request(action, arguments, [@node.name], {'identity' => @node.name})
  if results.empty?
    log(:error, "No answer from node recieved")
    result_ok = false
  else
    result_ok = false unless parse_mco_result(results.first)
  end
  mc.disconnect
  result_ok
end

#run_noopObject



45
46
47
48
49
# File 'lib/dopi/command/mco/rpc.rb', line 45

def run_noop
  log(:info, "(NOOP) command #{name}: agent: #{agent}")
  log(:info, "(NOOP) command #{name}: options: #{options}")
  log(:info, "(NOOP) command #{name}: arguments: #{arguments}")
end

#validateObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dopi/command/mco/rpc.rb', line 13

def validate
  log_validation_method('options_valid?', CommandParsingError)
  log_validation_method('arguments_valid?', CommandParsingError)
  # Skip validation in subclasses that overwrite the non optional methods
  unless Dopi::Command::Mco::Rpc > self.class && self.method(:agent).owner == self.class
    log_validation_method('agent_valid?', CommandParsingError)
  end
  unless Dopi::Command::Mco::Rpc > self.class && self.method(:action).owner == self.class
    log_validation_method('action_valid?', CommandParsingError)
  end
  validate_exit_code
end