class Kontena::Plugin::Vagrant::Nodes::SshCommand

Public Instance Methods

execute() click to toggle source
# 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