Sha256: 96c61d25ed5a8a23e484346f6e811c29fd34c480c25604ed4cd333597c1d137a
Contents?: true
Size: 1.73 KB
Versions: 67
Compression:
Stored size: 1.73 KB
Contents
#!/usr/bin/env ruby require 'hybrid_platforms_conductor/executable' commands = [] timeout = nil concurrent_execution = false interactive = false executable = HybridPlatformsConductor::Executable.new do |opts| opts.on('-c', '--command CMD', 'Command to execute (can\'t be used with --interactive) (can be used several times, commands will be executed sequentially)') do |cmd| commands << cmd end opts.on('-f', '--commands-file FILE_NAME', 'Execute commands taken from a file (can\'t be used with --interactive) (can be used several times, commands will be executed sequentially)') do |file_name| commands << { file: file_name } end opts.on('-i', '--interactive', 'Run an interactive SSH session instead of executing a command (can\'t be used with --command or --commands-file)') do interactive = true end opts.on('-p', '--parallel', 'Execute the commands in parallel (put the standard output in files <hybrid-platforms-dir>/run_logs/*.stdout)') do concurrent_execution = true end opts.on('-t', '--timeout SECS', 'Timeout in seconds to wait for each command (defaults to no timeout)') do |nbr_secs| timeout = nbr_secs.to_i end end actions_executor = executable.actions_executor executable.parse_options! raise '--interactive or --command options have to be present' if commands.empty? && !interactive raise 'No node selected. Please use --node option to set at least one.' if executable.selected_nodes.empty? actions = [] actions << { remote_bash: commands } unless commands.empty? actions << { interactive: true } if interactive actions_executor.execute_actions( { executable.selected_nodes => actions }, timeout: timeout, concurrent: concurrent_execution, log_to_stdout: executable.log_debug? || !concurrent_execution )
Version data entries
67 entries across 67 versions & 1 rubygems