Class: Kontena::Plugin::Vagrant::Nodes::SshCommand

Inherits:
Command
  • Object
show all
Includes:
Cli::Common, Cli::GridOptions
Defined in:
lib/kontena/plugin/vagrant/nodes/ssh_command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kontena/plugin/vagrant/nodes/ssh_command.rb', line 9

def execute
  require_api_url
  require_current_grid

  require 'shellwords'
  require_relative '../../../machine/vagrant'

  vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
  abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)

  cmd = "vagrant ssh"
  if self.commands_list && !self.commands_list.empty?
    cmd << " -c '#{self.commands_list.shelljoin}'" 
  end
  Dir.chdir(vagrant_path) do
    system(cmd)
  end
end