Class: Rig::Command::Ssh

Inherits:
Abstract
  • Object
show all
Defined in:
lib/rig/command/ssh.rb

Instance Method Summary collapse

Methods inherited from Abstract

#instance_list, #print_table

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rig/command/ssh.rb', line 6

def execute
  #user = Rig.config[:ssh][:user] rescue nil
  unless user
    puts "must set rig:ssh:user in configuration."
    exit(1)
  end

  list = Rig::Model::Instance.find_by_nick(name)
  if list.count == 0
    puts "server not found."
  elsif list.count > 1
    puts "query returned more than one server:"
    instance_list(list)
  else
    server = list.first
    puts "connecting as #{user} to: #{server.tags['Name']} (#{server.public_ip_address})"
    exec("ssh #{user}@#{server.public_ip_address}")
  end
end