Skip to content

Commit c5e3b5e

Browse files
committed
Merge pull request #81 from januzis/vagrant-1.5-support
Replaced deprecated config_global with vagrantfile.config to support vagrant 1.5 API
2 parents 56ce9f8 + 5a22784 commit c5e3b5e

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

lib/vagrant-hostmanager/action/update_all.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ def initialize(app, env)
1111
@machine = env[:machine]
1212
@global_env = @machine.env
1313
@provider = @machine.provider_name
14+
15+
# config_global is deprecated from v1.5
16+
if Gem::Version.new(::Vagrant::VERSION) >= Gem::Version.new('1.5')
17+
@config = @global_env.vagrantfile.config
18+
else
19+
@config = @global_env.config_global
20+
end
21+
1422
@logger = Log4r::Logger.new('vagrant::hostmanager::update_all')
1523
end
1624

@@ -21,7 +29,7 @@ def call(env)
2129
return @app.call(env) if !@machine.id && env[:machine_action] == :destroy
2230

2331
# check config to see if the hosts file should be update automatically
24-
return @app.call(env) unless @global_env.config_global.hostmanager.enabled?
32+
return @app.call(env) unless @config.hostmanager.enabled?
2533
@logger.info 'Updating /etc/hosts file automatically'
2634

2735
@app.call(env)

lib/vagrant-hostmanager/action/update_guest.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ def initialize(app, env)
1111
@machine = env[:machine]
1212
@global_env = @machine.env
1313
@provider = env[:provider]
14+
15+
# config_global is deprecated from v1.5
16+
if Gem::Version.new(::Vagrant::VERSION) >= Gem::Version.new('1.5')
17+
@config = @global_env.vagrantfile.config
18+
else
19+
@config = @global_env.config_global
20+
end
21+
1422
@logger = Log4r::Logger.new('vagrant::hostmanager::update_guest')
1523
end
1624

lib/vagrant-hostmanager/action/update_host.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ def initialize(app, env)
1010
@app = app
1111
@global_env = env[:global_env]
1212
@provider = env[:provider]
13+
14+
# config_global is deprecated from v1.5
15+
if Gem::Version.new(::Vagrant::VERSION) >= Gem::Version.new('1.5')
16+
@config = @global_env.vagrantfile.config
17+
else
18+
@config = @global_env.config_global
19+
end
20+
1321
@logger = Log4r::Logger.new('vagrant::hostmanager::update_host')
1422
end
1523

1624
def call(env)
17-
if @global_env.config_global.hostmanager.manage_host?
25+
if @config.hostmanager.manage_host?
1826
env[:ui].info I18n.t('vagrant_hostmanager.action.update_host')
1927
update_host
2028
end

lib/vagrant-hostmanager/hosts_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def get_ip_address(machine, resolving_machine)
101101
end
102102

103103
def get_machines
104-
if @global_env.config_global.hostmanager.include_offline?
104+
if @config.hostmanager.include_offline?
105105
machines = @global_env.machine_names
106106
else
107107
machines = @global_env.active_machines

lib/vagrant-hostmanager/provisioner.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ def initialize(machine, config)
77
super(machine, config)
88
@global_env = machine.env
99
@provider = machine.provider_name
10+
11+
# config_global is deprecated from v1.5
12+
if Gem::Version.new(::Vagrant::VERSION) >= Gem::Version.new('1.5')
13+
@config = @global_env.vagrantfile.config
14+
else
15+
@config = @global_env.config_global
16+
end
17+
1018
end
1119

1220
def provision
1321
update_guest(@machine)
14-
if @global_env.config_global.hostmanager.manage_host?
22+
if @config.hostmanager.manage_host?
1523
update_host
1624
end
1725
end

0 commit comments

Comments
 (0)