Sha256: 0dd8c9ee356cc51dc572ce0a2aa09354e98dddaf8de44f179201b30c972220c2
Contents?: true
Size: 1.32 KB
Versions: 7
Compression:
Stored size: 1.32 KB
Contents
require_relative "execute_local" require_relative "execute_ssh" require_relative "execute_telnet" class ExecuteManager def initialize(parent) @parent = parent # READ: @config, cmd = action[:command] # WRITE: @action, @result, @session # my_execute, encode_and_split methods? end def call(host) start_time = Time.now run_on(host) action[:duration] = (Time.now - start_time).round(3) end private def action @parent.action end def config @parent.config end def log(...) @parent.log(...) end def run_on(host) protocol = config.get("#{host}_protocol".to_sym) ip = config.get("#{host}_ip".to_sym) if protocol.to_s.downcase == "local" || host.to_s == "localhost" # Protocol force => local ExecuteLocal.new(@parent).call elsif protocol.to_s.downcase == "ssh" # Protocol force => ssh ExecuteSSH.new(@parent).call(host) elsif protocol.to_s.downcase == "telnet" # Protocol force => telnet ExecuteTelnet.new(@parent).call(host) elsif ip.to_s.downcase == "localhost" || ip.to_s.include?("127.0.0.") # run_cmd_localhost ExecuteLocal.new(@parent).call elsif ip == "NODATA" log("#{host} IP not found!", :error) else # run_cmd_remote_ssh host ExecuteSSH.new(@parent).call(host) end end end
Version data entries
7 entries across 7 versions & 1 rubygems