Class: Vagrant::Action::VM::CheckBox

Inherits:
Object
  • Object
show all
Defined in:
lib/engineyard-local.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object

Raises:

  • (Errors::BoxNotSpecified)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/engineyard-local.rb', line 12

def call(env)
  box_name = env[:vm].config.vm.box
  raise Errors::BoxNotSpecified if !box_name

  if !env[:box_collection].find(box_name)
    box_url = env[:vm].config.vm.box_url
    raise Errors::BoxSpecifiedDoesntExist, :name => box_name if !box_url

    # Add the box then reload the box collection so that it becomes
    # aware of it.
    env[:ui].info I18n.t("vagrant.actions.vm.check_box.not_found", :name => box_name)
    env[:box_collection].add(box_name, box_url)

    # Reload the configuration for all our VMs, since this box
    # may be used for other VMs.
    env.env.vms.each do |name, vm|
      vm.env.reload_config!
    end

    # Reload the environment and set the VM to be the new loaded VM.
    env[:vm].env.reload!
    env[:vm] = env[:vm].env.vms[env[:vm].name]
  end

  @app.call(env)
end