Skip to content

Commit

Permalink
migrate UpdateAll action to use Updater class and remove hosts_file.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
pbitty committed Jul 22, 2014
1 parent 5581f1c commit 2e54e3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 219 deletions.
8 changes: 4 additions & 4 deletions lib/vagrant-hostmanager/action/update_all.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require 'vagrant-hostmanager/hosts_file'
require 'vagrant-hostmanager/hosts_file/updater'
require 'vagrant-hostmanager/util'

module VagrantPlugins
module HostManager
module Action
class UpdateAll
include HostsFile

def initialize(app, env)
@app = app
@machine = env[:machine]
@global_env = @machine.env
@provider = @machine.provider_name
@config = Util.get_config(@global_env)
@updater = HostsFile::Updater.new(@global_env, @provider)
@logger = Log4r::Logger.new('vagrant::hostmanager::update_all')
end

Expand All @@ -31,14 +31,14 @@ def call(env)
@global_env.active_machines.each do |name, p|
if p == @provider
machine = @global_env.machine(name, p)
update_guest(machine)
@updater.update_guest(machine)
end
end

# update /etc/hosts files on host if enabled
if @machine.config.hostmanager.manage_host?
env[:ui].info I18n.t('vagrant_hostmanager.action.update_host')
update_host
@updater.update_host
end
end
end
Expand Down
213 changes: 0 additions & 213 deletions lib/vagrant-hostmanager/hosts_file.rb

This file was deleted.

4 changes: 2 additions & 2 deletions lib/vagrant-hostmanager/hosts_file/updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def update_content(file_content, resolving_machine, include_id)
def get_hosts_file_entry(machine, resolving_machine)
ip = get_ip_address(machine, resolving_machine)
host = machine.config.vm.hostname || machine.name
aliases = machine.config.hostmanager.aliases.join(' ').chomp
aliases = machine.config.hostmanager.aliases
if ip != nil
"#{ip}\t#{host} #{aliases}\n"
"#{ip}\t#{host}\n" + aliases.map{|a| "#{ip}\t#{a}"}.join("\n") + "\n"
end
end

Expand Down

0 comments on commit 2e54e3f

Please sign in to comment.