Primary VM is SSH by default on call to `vagrant ssh`
This commit is contained in:
parent
687b925d2e
commit
5f57766365
|
@ -16,11 +16,13 @@ module Vagrant
|
|||
|
||||
def ssh_connect(name)
|
||||
if name.nil? && env.multivm?
|
||||
error_and_exit(:ssh_multivm)
|
||||
return # for tests
|
||||
if env.primary_vm.nil?
|
||||
error_and_exit(:ssh_multivm)
|
||||
return # for tests
|
||||
end
|
||||
end
|
||||
|
||||
vm = name.nil? ? env.vms.values.first : env.vms[name.to_sym]
|
||||
vm = name.nil? ? env.primary_vm : env.vms[name.to_sym]
|
||||
if vm.nil?
|
||||
error_and_exit(:unknown_vm, :vm => name)
|
||||
return # for tests
|
||||
|
|
|
@ -153,6 +153,14 @@
|
|||
specific VM must be specified. This can be done by calling
|
||||
`vagrant ssh NAME` where NAME is a valid VM represented by
|
||||
your Vagrantfile.
|
||||
|
||||
Alternatively, if you mark one of your VMs as 'primary,'
|
||||
then Vagrant will default to that VM. This can be done by
|
||||
specifying `:primary => true` when defining the VM. Example:
|
||||
|
||||
config.vm.define(:foo, :primary => true) do |config|
|
||||
...
|
||||
end
|
||||
:ssh_config_multivm: |-
|
||||
Because this Vagrant environment represents multiple VMs, a
|
||||
specific VM must be specified. This can be done by calling
|
||||
|
|
|
@ -30,12 +30,25 @@ class CommandsSSHTest < Test::Unit::TestCase
|
|||
@env.stubs(:multivm?).returns(false)
|
||||
end
|
||||
|
||||
should "error and exit if no VM is specified and multivm" do
|
||||
should "error and exit if no VM is specified and multivm and no primary VM" do
|
||||
@env.stubs(:multivm?).returns(true)
|
||||
@env.stubs(:primary_vm).returns(nil)
|
||||
@instance.expects(:error_and_exit).with(:ssh_multivm).once
|
||||
@instance.ssh_connect(nil)
|
||||
end
|
||||
|
||||
should "use the primary VM if it exists and no name is specified" do
|
||||
vm = mock("vm")
|
||||
ssh = mock("ssh")
|
||||
vm.stubs(:created?).returns(true)
|
||||
vm.stubs(:ssh).returns(ssh)
|
||||
|
||||
@env.stubs(:multivm?).returns(true)
|
||||
@env.stubs(:primary_vm).returns(vm)
|
||||
ssh.expects(:connect).once
|
||||
@instance.ssh_connect(nil)
|
||||
end
|
||||
|
||||
should "error and exit if VM is nil" do
|
||||
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
||||
@instance.ssh_connect(:foo)
|
||||
|
|
Loading…
Reference in New Issue