Show error if host only networking on Windows

This commit is contained in:
Mitchell Hashimoto 2010-12-21 19:52:41 -08:00
parent e98db8dc86
commit 2358130c0e
5 changed files with 39 additions and 3 deletions

View File

@ -10,6 +10,8 @@
- Enumerate VMs in a multi-VM environment in order they were defined. [GH-244] - Enumerate VMs in a multi-VM environment in order they were defined. [GH-244]
- Check for VM boot changed to use `timeout` library, which works better with Windows. - Check for VM boot changed to use `timeout` library, which works better with Windows.
- Show special error if VirtualBox not detected on 64-bit Windows. - Show special error if VirtualBox not detected on 64-bit Windows.
- Show error to Windows users attempting to use host only networking since
it doesn't work yet.
## 0.6.8 (November 30, 2010) ## 0.6.8 (November 30, 2010)

View File

@ -8,6 +8,10 @@ module Vagrant
@app = app @app = app
@env = env @env = env
if enable_network? && Util::Platform.windows?
raise Errors::NetworkNotImplemented
end
env["config"].vm.network_options.compact.each do |network_options| env["config"].vm.network_options.compact.each do |network_options|
raise Errors::NetworkCollision.new if !verify_no_bridge_collision(network_options) raise Errors::NetworkCollision.new if !verify_no_bridge_collision(network_options)
end end

View File

@ -183,6 +183,13 @@ module Vagrant
error_key(:not_found, "vagrant.actions.vm.network") error_key(:not_found, "vagrant.actions.vm.network")
end end
# Note: This is a temporary error for Windows users while host-only
# networking doesn't quite work.
class NetworkNotImplemented < VagrantError
status_code(49)
error_key(:windows_not_implemented, "vagrant.actions.vm.network")
end
class NFSHostRequired < VagrantError class NFSHostRequired < VagrantError
status_code(31) status_code(31)
error_key(:host_required, "vagrant.actions.vm.nfs") error_key(:host_required, "vagrant.actions.vm.nfs")

View File

@ -304,14 +304,19 @@ en:
This will cause your specified IP to be inaccessible. Please change This will cause your specified IP to be inaccessible. Please change
the IP or name of your host only network to not match that of the IP or name of your host only network to not match that of
a bridged or non-hostonly network. a bridged or non-hostonly network.
creating: Creating new host only network for environment... creating: "Creating new host only network for environment..."
enabling: Enabling host only network... enabling: "Enabling host only network..."
not_found: |- not_found: |-
The specified host network could not be found: '%{name}.' The specified host network could not be found: '%{name}.'
If the name specification is removed, Vagrant will create a new If the name specification is removed, Vagrant will create a new
host only network for you. Alternatively, please create the host only network for you. Alternatively, please create the
specified network manually. specified network manually.
preparing: Preparing host only network... preparing: "Preparing host only network..."
windows_not_implemented: |-
Host only networking is currently broken on Windows due to a bug
in jruby-win32ole. When the bug is fixed, a patch release for Vagrant
will be released to remove this error. Until then, please just use
forwarded ports.
nfs: nfs:
host_required: |- host_required: |-
A host class is required for NFS shared folders. By default, these A host class is required for NFS shared folders. By default, these

View File

@ -16,6 +16,24 @@ class NetworkVMActionTest < Test::Unit::TestCase
end end
context "initializing" do context "initializing" do
should "raise an error if on windows and networking is enabled" do
Vagrant::Util::Platform.stubs(:windows?).returns(true)
@env.env.config.vm.network("foo")
assert_raises(Vagrant::Errors::NetworkNotImplemented) {
@klass.new(@app, @env)
}
end
should "not raise an error if not on windows and networking is enabled" do
Vagrant::Util::Platform.stubs(:windows?).returns(false)
@env.env.config.vm.network("foo")
assert_nothing_raised {
@klass.new(@app, @env)
}
end
should "verify no bridge collisions for each network enabled" do should "verify no bridge collisions for each network enabled" do
@env.env.config.vm.network("foo") @env.env.config.vm.network("foo")
@klass.any_instance.expects(:verify_no_bridge_collision).returns(true).once.with() do |options| @klass.any_instance.expects(:verify_no_bridge_collision).returns(true).once.with() do |options|