providers/docker: can force a host VM optionally

This commit is contained in:
Mitchell Hashimoto 2014-04-18 19:58:26 -07:00
parent 79793ab130
commit 8a76c2bc76
3 changed files with 10 additions and 4 deletions

View File

@ -22,6 +22,11 @@ module VagrantPlugins
# @return [Hash]
attr_accessor :env
# Force using a proxy VM, even on Linux hosts.
#
# @return [Boolean]
attr_accessor :force_host_vm
# True if the Docker container exposes SSH access. If this is true,
# then Vagrant can do a bunch more things like setting the hostname,
# provisioning, etc.
@ -66,6 +71,7 @@ module VagrantPlugins
@cmd = UNSET_VALUE
@create_args = []
@env = {}
@force_host_vm = UNSET_VALUE
@has_ssh = UNSET_VALUE
@image = UNSET_VALUE
@name = UNSET_VALUE
@ -100,6 +106,7 @@ module VagrantPlugins
@cmd = [] if @cmd == UNSET_VALUE
@create_args = [] if @create_args == UNSET_VALUE
@env ||= {}
@force_host_vm = false if @force_host_vm == UNSET_VALUE
@has_ssh = false if @has_ssh == UNSET_VALUE
@image = nil if @image == UNSET_VALUE
@name = nil if @name == UNSET_VALUE

View File

@ -118,10 +118,8 @@ module VagrantPlugins
# rather than directly on our system. Docker needs to run in a VM
# when we're not on Linux, or not on a Linux that supports Docker.
def host_vm?
# TODO: It'd be nice to also check if Docker supports the version
# of Linux that Vagrant is running on so that we can spin up a VM
# on old versions of Linux as well.
!Vagrant::Util::Platform.linux?
@machine.provider_config.force_host_vm ||
!Vagrant::Util::Platform.linux?
end
# Returns the SSH info for accessing the Container.

View File

@ -41,6 +41,7 @@ describe VagrantPlugins::DockerProvider::Config do
its(:build_dir) { should be_nil }
its(:cmd) { should eq([]) }
its(:env) { should eq({}) }
its(:force_host_vm) { should be_false }
its(:image) { should be_nil }
its(:name) { should be_nil }
its(:privileged) { should be_false }