Class: Expectacle::Thrower

Inherits:
ThrowerBase show all
Defined in:
lib/expectacle/thrower.rb,
lib/expectacle/thrower_utils.rb,
lib/expectacle/thrower_preview.rb

Overview

Thrower logic(command list operation)

Instance Attribute Summary

Attributes inherited from ThrowerBase

#base_dir, #logger

Instance Method Summary collapse

Methods inherited from ThrowerBase

#commands_dir, #hosts_dir, #initialize, #opts_dir, #prompts_dir

Constructor Details

This class inherits a constructor from Expectacle::ThrowerBase

Instance Method Details

#preview_parameter(hosts, commands) ⇒ Object

Preview all parameters for all hosts.

Parameters:

  • hosts (Array<Hash>)

    Host parameters (read from host list file).

  • commands (Array<String>)

    Commands (read from command list file).



11
12
13
# File 'lib/expectacle/thrower_preview.rb', line 11

def preview_parameter(hosts, commands)
  print YAML.dump(previewed_data(hosts, commands))
end

#previewed_data(hosts, commands) ⇒ Object

Preview all parameters for all hosts (for testing)

Parameters:

  • hosts (Array<Hash>)

    Host parameters (read from host list file).

  • commands (Array<String>)

    Commands (read from command list file).



18
19
20
21
22
23
24
# File 'lib/expectacle/thrower_preview.rb', line 18

def previewed_data(hosts, commands)
  @commands = commands
  hosts.map do |each|
    @host_param = each
    preview_command_for_host
  end
end

#run_command_for_all_hosts(hosts, commands) ⇒ Object

Run(exec) commands for all hosts.

Parameters:

  • hosts (Array<Hash>)

    Host parameters (read from host list file).

  • commands (Array<String>)

    Commands (read from command list file).



15
16
17
18
19
20
21
22
23
# File 'lib/expectacle/thrower.rb', line 15

def run_command_for_all_hosts(hosts, commands)
  hosts.each do |each|
    @commands = commands.dup # Notice: @commands will be decremented.
    @commands_len = @commands.length
    @auth_count = 0
    @host_param = each
    run_command_for_host
  end
end