core: HandleBox reloads machine from proper Vagrantfile

This commit is contained in:
Mitchell Hashimoto 2014-02-07 11:51:04 -08:00
parent 46a42eb9c2
commit 2846850306
1 changed files with 18 additions and 13 deletions

View File

@ -32,13 +32,23 @@ module Vagrant
lock = @@small_locks[machine.config.vm.box] lock = @@small_locks[machine.config.vm.box]
end end
box_updated = false
lock.synchronize do lock.synchronize do
if machine.box
@logger.info("Machine already has box. HandleBox will not run.")
next
end
handle_box(env) handle_box(env)
box_updated = true
end end
# Reload the environment and set the VM to be the new loaded VM. if box_updated
env[:machine] = env[:machine].env.machine( # Reload the environment and set the VM to be the new loaded VM.
env[:machine].name, env[:machine].provider_name, true) env[:machine] = machine.vagrantfile.machine(
machine.name, machine.provider_name,
machine.env.boxes, machine.data_dir, machine.env)
end
@app.call(env) @app.call(env)
end end
@ -46,17 +56,12 @@ module Vagrant
def handle_box(env) def handle_box(env)
machine = env[:machine] machine = env[:machine]
if machine.box
@logger.info("Machine already has box. HandleBox will not run.")
return
end
# Determine the set of formats that this box can be in # Determine the set of formats that this box can be in
box_download_ca_cert = env[:machine].config.vm.box_download_ca_cert box_download_ca_cert = machine.config.vm.box_download_ca_cert
box_download_client_cert = env[:machine].config.vm.box_download_client_cert box_download_client_cert = machine.config.vm.box_download_client_cert
box_download_insecure = env[:machine].config.vm.box_download_insecure box_download_insecure = machine.config.vm.box_download_insecure
box_formats = env[:machine].provider_options[:box_format] || box_formats = machine.provider_options[:box_format] ||
env[:machine].provider_name machine.provider_name
env[:ui].output(I18n.t( env[:ui].output(I18n.t(
"vagrant.box_auto_adding", name: machine.config.vm.box)) "vagrant.box_auto_adding", name: machine.config.vm.box))