Class: Kontena::Cli::Master::SshCommand
Instance Attribute Summary
#arguments, #exit_code, #result
Instance Method Summary
collapse
Methods included from Common
#access_token=, #add_master, #any_key_to_continue, #any_key_to_continue_with_timeout, #api_url, #api_url=, #clear_current_grid, #client, #cloud_auth?, #cloud_client, #config, #confirm, #confirm_command, #current_grid, #current_master_index, #display_account_login_info, #display_login_info, display_logo, #display_master_login_info, #error, exit_with_error, #kontena_account, #logger, #pastel, #print, #prompt, #puts, #require_api_url, #require_token, #reset_client, #reset_cloud_client, #running_quiet?, #running_silent?, #running_verbose?, #spin_if, #spinner, #sprint, #sputs, #stdin_input, #use_refresh_token, #vfakespinner, #vputs, #vspinner, #warning
banner, callback_matcher, #help_requested?, inherited, load_subcommand, requires_current_account_token, requires_current_account_token?, requires_current_grid, requires_current_grid?, requires_current_master, requires_current_master?, requires_current_master_token, requires_current_master_token?, #run, #run_callbacks, #verify_current_account_token, #verify_current_grid, #verify_current_master, #verify_current_master_token
Instance Method Details
#execute ⇒ Object
60
61
62
|
# File 'lib/kontena/cli/master/ssh_command.rb', line 60
def execute
master_is_vagrant? ? run_vagrant_ssh : run_ssh
end
|
#master_host ⇒ Object
13
14
15
16
|
# File 'lib/kontena/cli/master/ssh_command.rb', line 13
def master_host
require 'uri'
URI.parse(current_master.url).host
end
|
#master_is_vagrant? ⇒ Boolean
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/kontena/cli/master/ssh_command.rb', line 31
def master_is_vagrant?
if master_provider_vagrant?
unless vagrant_plugin_installed?
exit_with_error 'You need to install vagrant plugin to ssh into this master. Use: kontena plugin install vagrant'
end
logger.debug { "Master config server.provider is vagrant" }
true
elsif vagrant_plugin_installed? && current_master.url.include?('192.168.66.')
logger.debug { "Vagrant plugin installed and current_master url looks like vagrant" }
true
else
logger.debug { "Assuming non-vagrant master host" }
false
end
end
|
#master_provider_vagrant? ⇒ Boolean
18
19
20
21
22
23
24
25
|
# File 'lib/kontena/cli/master/ssh_command.rb', line 18
def master_provider_vagrant?
require 'kontena/cli/master/config/get_command'
cmd = Kontena::Cli::Master::Config::GetCommand.new([])
cmd.parse(['server.provider'])
cmd.response['server.provider'] == 'vagrant'
rescue => ex
false
end
|
#run_ssh ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/kontena/cli/master/ssh_command.rb', line 47
def run_ssh
cmd = ['ssh']
cmd << "#{user}@#{master_host}"
cmd += ["-i", identity_file] if identity_file
cmd += commands_list
logger.debug { "Executing #{cmd.inspect}" }
exec(*cmd)
end
|
#run_vagrant_ssh ⇒ Object
56
57
58
|
# File 'lib/kontena/cli/master/ssh_command.rb', line 56
def run_vagrant_ssh
Kontena.run!(['vagrant', 'master', 'ssh'] + commands_list)
end
|
#vagrant_plugin_installed? ⇒ Boolean
27
28
29
|
# File 'lib/kontena/cli/master/ssh_command.rb', line 27
def vagrant_plugin_installed?
Kontena::PluginManager.instance.plugins.any? { |plugin| plugin.name == 'kontena-plugin-vagrant' }
end
|