SSH subcommand
This commit is contained in:
parent
0a1f2158f7
commit
4674b1983e
|
@ -0,0 +1,22 @@
|
|||
module Vagrant
|
||||
class Commands
|
||||
# Reload the environment. This is almost equivalent to the {up} command
|
||||
# except that it doesn't import the VM and do the initialize bootstrapping
|
||||
# of the instance. Instead, it forces a shutdown (if its running) of the
|
||||
# VM, updates the metadata (shared folders, forwarded ports), restarts
|
||||
# the VM, and then reruns the provisioning if enabled.
|
||||
class SSH < Base
|
||||
Base.subcommand "ssh", self
|
||||
description "SSH into the currently running environment"
|
||||
|
||||
def execute(args=[])
|
||||
env.require_persisted_vm
|
||||
env.ssh.connect
|
||||
end
|
||||
|
||||
def options_spec(opts)
|
||||
opts.banner = "Usage: vagrant ssh"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class CommandsSSHTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Commands::SSH
|
||||
|
||||
@persisted_vm = mock("persisted_vm")
|
||||
@persisted_vm.stubs(:execute!)
|
||||
|
||||
@env = mock_environment
|
||||
@env.stubs(:require_persisted_vm)
|
||||
@env.stubs(:vm).returns(@persisted_vm)
|
||||
|
||||
@instance = @klass.new(@env)
|
||||
end
|
||||
|
||||
context "executing" do
|
||||
setup do
|
||||
@env.ssh.stubs(:connect)
|
||||
end
|
||||
|
||||
should "require a persisted VM" do
|
||||
@env.expects(:require_persisted_vm).once
|
||||
@instance.execute
|
||||
end
|
||||
|
||||
should "connect to SSH" do
|
||||
@env.ssh.expects(:connect).once
|
||||
@instance.execute
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue