From b5465ddab20cb6dd49a9a8f5a77e1192170494d0 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Tue, 19 Mar 2013 02:38:31 -0300 Subject: [PATCH] Add middleware to force ssh disconnect --- lib/vagrant-lxc/action.rb | 2 ++ lib/vagrant-lxc/action/disconnect.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 lib/vagrant-lxc/action/disconnect.rb diff --git a/lib/vagrant-lxc/action.rb b/lib/vagrant-lxc/action.rb index 714309b..93826a5 100644 --- a/lib/vagrant-lxc/action.rb +++ b/lib/vagrant-lxc/action.rb @@ -6,6 +6,7 @@ require 'vagrant-lxc/action/check_running' require 'vagrant-lxc/action/create' require 'vagrant-lxc/action/created' require 'vagrant-lxc/action/destroy' +require 'vagrant-lxc/action/disconnect' require 'vagrant-lxc/action/forced_halt' require 'vagrant-lxc/action/handle_box_metadata' require 'vagrant-lxc/action/is_running' @@ -123,6 +124,7 @@ module Vagrant # b.use CheckLXC b.use Vagrant::Action::Builtin::Call, Created do |env, b2| if env[:result] + b2.use Disconnect b2.use Vagrant::Action::Builtin::Call, Vagrant::Action::Builtin::GracefulHalt, :stopped, :running do |env2, b3| if !env2[:result] && env2[:machine].provider.state.running? b3.use ForcedHalt diff --git a/lib/vagrant-lxc/action/disconnect.rb b/lib/vagrant-lxc/action/disconnect.rb new file mode 100644 index 0000000..5ad86f0 --- /dev/null +++ b/lib/vagrant-lxc/action/disconnect.rb @@ -0,0 +1,14 @@ +module Vagrant + module LXC + module Action + class Disconnect < BaseAction + def call(env) + @app.call env + # FIXME: Vagrant >= 1.1.3 should not need this + # https://github.com/mitchellh/vagrant/compare/715539eac30bc9ae62ddbb6337d13f036f7b774d...ec1bae0#L2R128 + env[:machine].instance_variable_set(:@communicator, nil) + end + end + end + end +end