`vagrant ssh` and update CHANGELOG before I forget

This commit is contained in:
Mitchell Hashimoto 2010-08-24 23:46:10 -07:00
parent 7c0fe570a5
commit d86884699e
2 changed files with 49 additions and 1 deletions

View File

@ -1,6 +1,12 @@
## 0.6.0 (unreleased)
- Converted CLI to use Thor. As a tradeoff, there are some backwards
incompatibilities:
* `vagrant package` - The `--include` flag now separates filenames
by spaces, instead of by commas. e.g. `vagrant package --include x y z`
* `vagrant ssh` - If you specify a command to execute using the `--execute`
flag, you may now only specify one command (before you were able to
specify an arbitrary amount). e.g. `vagrant ssh -e "echo hello"`
## 0.5.3 (August 23, 2010)

View File

@ -0,0 +1,42 @@
module Vagrant
module Command
class SSHCommand < Base
desc "SSH into the currently running Vagrant environment."
class_option :execute, :type => :string, :default => false, :aliases => "-e"
register "ssh"
def execute
if options[:execute]
ssh_execute
else
ssh_connect
end
end
protected
def ssh_execute
ssh_vm.ssh.execute do |ssh|
ssh_vm.env.ui.info "Execute: #{options[:execute]}"
ssh.exec!(options[:execute]) do |channel, type, data|
ssh_vm.env.ui.info "#{data}"
end
end
end
def ssh_connect
raise VMNotCreatedError.new("The VM must be created for SSH to work. Please run `vagrant up`.") if !ssh_vm.created?
ssh_vm.ssh.connect
end
def ssh_vm
@ssh_vm ||= begin
vm = self.name.nil? && env.multivm? ? env.primary_vm
raise MultiVMTargetRequired.new("A target or primary VM must be specified for SSH in a multi-vm environment.") if !vm && target_vms.length > 1
vm = target_vms.first if !vm
vm
end
end
end
end
end