Class: Flydata::Helper::Action::AgentAction

Inherits:
BaseAction
  • Object
show all
Defined in:
lib/flydata/helper/action/agent_action.rb

Direct Known Subclasses

Clear, Flush, Repair, Reset, RestartAgent, Resync, StopAgent

Constant Summary collapse

FLYDATA_CMD =
"#{Flydata::FLYDATA_CMD_PATH} %{sub_command}"

Instance Attribute Summary

Attributes inherited from BaseAction

#config

Instance Method Summary collapse

Methods inherited from BaseAction

#config_hash, #initialize

Constructor Details

This class inherits a constructor from Flydata::Helper::BaseAction

Instance Method Details

#execute(opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/flydata/helper/action/agent_action.rb', line 9

def execute(opts = {})
  sub_command = command(opts)
  cmd = FLYDATA_CMD % { sub_command: sub_command }
  log_info("Executing `#{cmd}`")
  o, e, s = Util::Shell.run_cmd(cmd)
  log_warn(e) if not e.to_s.empty?
  log_error("[error] Could not execute #{cmd}. Response status: #{s}") unless (s.to_i == 0)
end

#get_tables(opts) ⇒ Object

Override this. Needs to be implemented by the subclass def command(opts = {}) end



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/flydata/helper/action/agent_action.rb', line 22

def get_tables(opts)
  tables = config_hash(opts)[:tables]
  tables_str = case tables
               when Array
                 tables.join(' ')
               when String  # --all option
                 tables
               else
                 raise "Wrong tables parameter - tables:\"#{tables}\""
               end
  tables_str
end