Skip to content

Commit

Permalink
Remove suspend, resume, and halt hooks.
Browse files Browse the repository at this point in the history
This commits removes hooks that introduced dependencies to machine state
and therefore broke compatibility with all Vagrant providers.
  • Loading branch information
smdahlen committed Aug 22, 2013
1 parent 4136b1e commit 436b171
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
12 changes: 4 additions & 8 deletions lib/vagrant-hostmanager/action/update_all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ def initialize(app, env)
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?
Expand Down
12 changes: 0 additions & 12 deletions lib/vagrant-hostmanager/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ class Plugin < Vagrant.plugin('2')
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
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-hostmanager/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module VagrantPlugins
module HostManager
VERSION = '1.1.0'
VERSION = '1.2.0'
end
end

0 comments on commit 436b171

Please sign in to comment.