Don't disable networks on halt/destroy.
This commit is contained in:
parent
c32ab0442c
commit
e19788701e
|
@ -6,6 +6,8 @@
|
||||||
- Changed the unused host only network destroy mechanism to check for
|
- Changed the unused host only network destroy mechanism to check for
|
||||||
uselessness after the VM is destroyed. This should result in more accurate
|
uselessness after the VM is destroyed. This should result in more accurate
|
||||||
checks.
|
checks.
|
||||||
|
- Networks are no longer disabled upon halt/destroy. With the above
|
||||||
|
change, its unnecessary.
|
||||||
|
|
||||||
## 0.6.9 (December 21, 2010)
|
## 0.6.9 (December 21, 2010)
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ module Vagrant
|
||||||
register(:halt, Builder.new do
|
register(:halt, Builder.new do
|
||||||
use VM::DiscardState
|
use VM::DiscardState
|
||||||
use VM::Halt
|
use VM::Halt
|
||||||
use VM::DisableNetworks
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
# suspend - Suspends the VM
|
# suspend - Suspends the VM
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
module Vagrant
|
|
||||||
class Action
|
|
||||||
module VM
|
|
||||||
# Middleware to disable all host only networks on the
|
|
||||||
# VM
|
|
||||||
class DisableNetworks
|
|
||||||
def initialize(app, env)
|
|
||||||
@app = app
|
|
||||||
@env = env
|
|
||||||
end
|
|
||||||
|
|
||||||
def call(env)
|
|
||||||
if env["vm"].created?
|
|
||||||
logged = false
|
|
||||||
|
|
||||||
env["vm"].vm.network_adapters.each do |adapter|
|
|
||||||
next if adapter.attachment_type != :host_only
|
|
||||||
|
|
||||||
if !logged
|
|
||||||
env.ui.info I18n.t("vagrant.actions.vm.disable_networks.disabling")
|
|
||||||
logged = true
|
|
||||||
end
|
|
||||||
|
|
||||||
adapter.enabled = false
|
|
||||||
adapter.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@app.call(env)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,48 +0,0 @@
|
||||||
require "test_helper"
|
|
||||||
|
|
||||||
class DisableNetworksVMActionTest < Test::Unit::TestCase
|
|
||||||
setup do
|
|
||||||
@klass = Vagrant::Action::VM::DisableNetworks
|
|
||||||
@app, @env = action_env
|
|
||||||
|
|
||||||
@vm = mock("vm")
|
|
||||||
@env.env.stubs(:vm).returns(@vm)
|
|
||||||
|
|
||||||
@internal_vm = mock("internal")
|
|
||||||
@vm.stubs(:created?).returns(true)
|
|
||||||
@vm.stubs(:vm).returns(@internal_vm)
|
|
||||||
@internal_vm.stubs(:network_adapters).returns([])
|
|
||||||
|
|
||||||
@instance = @klass.new(@app, @env)
|
|
||||||
end
|
|
||||||
|
|
||||||
def mock_adapter(type)
|
|
||||||
adapter = mock("adapter")
|
|
||||||
adapter.stubs(:attachment_type).returns(type)
|
|
||||||
|
|
||||||
if type == :host_only
|
|
||||||
adapter.expects(:enabled=).with(false)
|
|
||||||
adapter.expects(:save)
|
|
||||||
end
|
|
||||||
|
|
||||||
@internal_vm.network_adapters << adapter
|
|
||||||
end
|
|
||||||
|
|
||||||
should "do nothing if VM is not created" do
|
|
||||||
@vm.stubs(:created?).returns(false)
|
|
||||||
@vm.expects(:vm).never
|
|
||||||
|
|
||||||
@app.expects(:call).with(@env).once
|
|
||||||
@instance.call(@env)
|
|
||||||
end
|
|
||||||
|
|
||||||
should "remove all network adapters and continue chain" do
|
|
||||||
mock_adapter(:bridged)
|
|
||||||
mock_adapter(:host_only)
|
|
||||||
mock_adapter(:host_only)
|
|
||||||
|
|
||||||
@app.expects(:call).with(@env).once
|
|
||||||
|
|
||||||
@instance.call(@env)
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in New Issue