From 436b171f531be9c4e4b8a61b23d2cbaaa9588ba5 Mon Sep 17 00:00:00 2001 From: Shawn Dahlen Date: Thu, 22 Aug 2013 17:12:33 -0400 Subject: [PATCH] Remove suspend, resume, and halt hooks. This commits removes hooks that introduced dependencies to machine state and therefore broke compatibility with all Vagrant providers. --- README.md | 7 +++++-- lib/vagrant-hostmanager/action/update_all.rb | 12 ++++-------- lib/vagrant-hostmanager/plugin.rb | 12 ------------ lib/vagrant-hostmanager/version.rb | 2 +- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 502191f..ef7b583 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ file on guest machines (and optionally the host). Its goal is to enable resolution of multi-machine environments deployed with a cloud provider where IP addresses are not known in advance. +*NOTE:* Version 1.1 of the plugin prematurely introduced a feature to hook into +commands other than `vagrant up` and `vagrant destroy`. Version 1.1 broke support for some providers. Version 1.2 reverts this feature until a suitable implementation supporting all providers is available. + Installation ------------ Install the plugin following the typical Vagrant 1.1 procedure: @@ -18,8 +21,8 @@ command: $ vagrant hostmanager -The plugin hooks into the `vagrant up`, `vagrant destroy`, `vagrant halt`, -`vagrant resume` and `vagrant suspend` commands automatically. +The plugin hooks into the `vagrant up` and `vagrant destroy` commands +automatically. When a machine enters or exits the running state , all active machines with the same provider will have their `/etc/hosts` file updated accordingly. Set the `hostmanager.enabled` attribute to `true` in the diff --git a/lib/vagrant-hostmanager/action/update_all.rb b/lib/vagrant-hostmanager/action/update_all.rb index 9d5e026..7dcdcbe 100644 --- a/lib/vagrant-hostmanager/action/update_all.rb +++ b/lib/vagrant-hostmanager/action/update_all.rb @@ -15,14 +15,10 @@ module VagrantPlugins end def call(env) - # skip if machine is running and the action is resume or up - return @app.call(env) if @machine.state.id == :running && [:resume, :up].include?(env[:machine_action]) - # skip if machine is not running and the action is destroy, halt or suspend - return @app.call(env) if @machine.state.id != :running && [:destroy, :halt, :suspend].include?(env[:machine_action]) - # skip if machine is not saved and the action is resume - return @app.call(env) if @machine.state.id != :saved && env[:machine_action] == :resume - # skip if machine is not running and the action is suspend - return @app.call(env) if @machine.state.id != :running && env[:machine_action] == :suspend + # skip if machine is already active on up action + return @app.call(env) if @machine.id && env[:machine_action] == :up + # skip if machine is not active on destroy action + return @app.call(env) if !@machine.id && env[:machine_action] == :destroy # check config to see if the hosts file should be update automatically return @app.call(env) unless @global_env.config_global.hostmanager.enabled? diff --git a/lib/vagrant-hostmanager/plugin.rb b/lib/vagrant-hostmanager/plugin.rb index 06cc166..8369d19 100644 --- a/lib/vagrant-hostmanager/plugin.rb +++ b/lib/vagrant-hostmanager/plugin.rb @@ -24,18 +24,6 @@ module VagrantPlugins hook.prepend(Action.update_all) end - action_hook(:hostmanager, :machine_action_halt) do |hook| - hook.prepend(Action.update_all) - end - - action_hook(:hostmanager, :machine_action_resume) do |hook| - hook.prepend(Action.update_all) - end - - action_hook(:hostmanager, :machine_action_suspend) do |hook| - hook.prepend(Action.update_all) - end - provisioner(:hostmanager) do require_relative 'provisioner' Provisioner diff --git a/lib/vagrant-hostmanager/version.rb b/lib/vagrant-hostmanager/version.rb index 1d13d77..08f82c5 100644 --- a/lib/vagrant-hostmanager/version.rb +++ b/lib/vagrant-hostmanager/version.rb @@ -1,5 +1,5 @@ module VagrantPlugins module HostManager - VERSION = '1.1.0' + VERSION = '1.2.0' end end