From c6219655f5e3d2a8a6bce3b90225c441021f817f Mon Sep 17 00:00:00 2001 From: januzis Date: Wed, 12 Mar 2014 11:51:14 +0100 Subject: [PATCH] Replaced deprecated config_global with vagrantfile.config --- lib/vagrant-hostmanager/action/update_all.rb | 10 +++++++++- lib/vagrant-hostmanager/action/update_host.rb | 10 +++++++++- lib/vagrant-hostmanager/hosts_file.rb | 2 +- lib/vagrant-hostmanager/provisioner.rb | 10 +++++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/vagrant-hostmanager/action/update_all.rb b/lib/vagrant-hostmanager/action/update_all.rb index 7dcdcbe..d2671d9 100644 --- a/lib/vagrant-hostmanager/action/update_all.rb +++ b/lib/vagrant-hostmanager/action/update_all.rb @@ -11,6 +11,14 @@ module VagrantPlugins @machine = env[:machine] @global_env = @machine.env @provider = @machine.provider_name + + # config_global is deprecated from v1.5 + if Gem::Version.new(::Vagrant::VERSION) >= Gem::Version.new('1.5') + @config = @global_env.vagrantfile.config + else + @config = @global_env.config_global + end + @logger = Log4r::Logger.new('vagrant::hostmanager::update_all') end @@ -21,7 +29,7 @@ module VagrantPlugins 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? + return @app.call(env) unless @config.hostmanager.enabled? @logger.info 'Updating /etc/hosts file automatically' @app.call(env) diff --git a/lib/vagrant-hostmanager/action/update_host.rb b/lib/vagrant-hostmanager/action/update_host.rb index 5418953..8d48255 100644 --- a/lib/vagrant-hostmanager/action/update_host.rb +++ b/lib/vagrant-hostmanager/action/update_host.rb @@ -10,11 +10,19 @@ module VagrantPlugins @app = app @global_env = env[:global_env] @provider = env[:provider] + + # config_global is deprecated from v1.5 + if Gem::Version.new(::Vagrant::VERSION) >= Gem::Version.new('1.5') + @config = @global_env.vagrantfile.config + else + @config = @global_env.config_global + end + @logger = Log4r::Logger.new('vagrant::hostmanager::update_host') end def call(env) - if @global_env.config_global.hostmanager.manage_host? + if @config.hostmanager.manage_host? env[:ui].info I18n.t('vagrant_hostmanager.action.update_host') update_host end diff --git a/lib/vagrant-hostmanager/hosts_file.rb b/lib/vagrant-hostmanager/hosts_file.rb index 0dc7a2e..582ba53 100644 --- a/lib/vagrant-hostmanager/hosts_file.rb +++ b/lib/vagrant-hostmanager/hosts_file.rb @@ -101,7 +101,7 @@ module VagrantPlugins end def get_machines - if @global_env.config_global.hostmanager.include_offline? + if @config.hostmanager.include_offline? machines = @global_env.machine_names else machines = @global_env.active_machines diff --git a/lib/vagrant-hostmanager/provisioner.rb b/lib/vagrant-hostmanager/provisioner.rb index 4c5397e..afe027a 100644 --- a/lib/vagrant-hostmanager/provisioner.rb +++ b/lib/vagrant-hostmanager/provisioner.rb @@ -7,11 +7,19 @@ module VagrantPlugins super(machine, config) @global_env = machine.env @provider = machine.provider_name + + # config_global is deprecated from v1.5 + if Gem::Version.new(::Vagrant::VERSION) >= Gem::Version.new('1.5') + @config = @global_env.vagrantfile.config + else + @config = @global_env.config_global + end + end def provision update_guest(@machine) - if @global_env.config_global.hostmanager.manage_host? + if @config.hostmanager.manage_host? update_host end end