class HammerCLIForeman::SSH::Command
Constants
- DEFAULT_PER_PAGE
Public Instance Methods
execute()
click to toggle source
# File lib/hammer_cli_foreman/ssh.rb, line 30 def execute 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(:on_error => :warn) do |session| 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.rb, line 23 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.rb, line 69 def host_ips @host_ips ||= hosts.map { |h| h['ip'] } end
host_names()
click to toggle source
# File lib/hammer_cli_foreman/ssh.rb, line 61 def host_names @host_names ||= hosts.map { |h| h['name'] } end
hosts()
click to toggle source
# File lib/hammer_cli_foreman/ssh.rb, line 57 def hosts @hosts ||= response['results'] end
response()
click to toggle source
# File lib/hammer_cli_foreman/ssh.rb, line 53 def response @response ||= send_request end
targets()
click to toggle source
# File lib/hammer_cli_foreman/ssh.rb, line 65 def targets (use_dns?.nil? || use_dns?) ? host_names : host_ips end