class HammerCLIForemanSsh::Command
Constants
- DEFAULT_PER_PAGE
Public Instance Methods
execute()
click to toggle source
# File lib/hammer_cli_foreman_ssh/ssh.rb, line 33 def execute signal_usage_error(_("specify 1 or more concurrent hosts")) if (!concurrent.nil? && concurrent < 1) puts _("About to execute: #{command} as user #{user}\n" + "on the following #{hosts.size} hosts: #{host_names.join(', ')}") unless prompt? == false || ask(_('Continue, (y/N)')).downcase == 'y' warn _('aborting per user request') return HammerCLI::EX_OK end ssh_options = { :user => user, :auth_methods => ['publickey'] } ssh_options[:keys] = [identity_file] unless identity_file.to_s.empty? Net::SSH::Multi.start(:concurrent_connections => concurrent, :on_error => :warn) do |session| logger.info(_("executing on #{concurrent} concurrent host(s)")) if concurrent.to_i > 0 targets.each { |s| session.use s, ssh_options } session.exec command session.loop end HammerCLI::EX_OK end
request_params()
click to toggle source
Calls superclass method
# File lib/hammer_cli_foreman_ssh/ssh.rb, line 26 def request_params params = super params['search'] ||= search params['per_page'] ||= HammerCLI::Settings.get(:ui, :per_page) || DEFAULT_PER_PAGE params end
Private Instance Methods
host_ips()
click to toggle source
# File lib/hammer_cli_foreman_ssh/ssh.rb, line 75 def host_ips @host_ips ||= hosts.map { |h| h['ip'] } end
host_names()
click to toggle source
# File lib/hammer_cli_foreman_ssh/ssh.rb, line 67 def host_names @host_names ||= hosts.map { |h| h['name'] } end
hosts()
click to toggle source
# File lib/hammer_cli_foreman_ssh/ssh.rb, line 63 def hosts @hosts ||= response['results'] end
response()
click to toggle source
# File lib/hammer_cli_foreman_ssh/ssh.rb, line 59 def response @response ||= send_request end
targets()
click to toggle source
# File lib/hammer_cli_foreman_ssh/ssh.rb, line 71 def targets (use_dns?.nil? || use_dns?) ? host_names : host_ips end