Class: VagrantPlugins::Skytap::Action::RunEnvironment

Inherits:
Object
  • Object
show all
Includes:
ActionHelpers
Defined in:
lib/vagrant-skytap/action/run_environment.rb

Overview

Runs multiple VMs in parallel. Ensures that the REST call happens only once.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ActionHelpers

#current_vm

Constructor Details

#initialize(app, env) ⇒ RunEnvironment

Returns a new instance of RunEnvironment.



36
37
38
39
40
# File 'lib/vagrant-skytap/action/run_environment.rb', line 36

def initialize(app, env)
  @app = app
  @env = env
  @logger = Log4r::Logger.new("vagrant_skytap::action::run_environment")
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



34
35
36
# File 'lib/vagrant-skytap/action/run_environment.rb', line 34

def env
  @env
end

Instance Method Details

#call(env) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vagrant-skytap/action/run_environment.rb', line 42

def call(env)
  environment = env[:environment]
  vm_ids = vm_ids_to_run

  if current_vm(env).id == vm_ids.first
    env[:ui].info(I18n.t("vagrant_skytap.running_environment"))
    @logger.info("Running VMs: #{vm_ids}")
    environment.run!(vm_ids)
  end

  @app.call(env)
end

#vm_ids_to_runObject



55
56
57
# File 'lib/vagrant-skytap/action/run_environment.rb', line 55

def vm_ids_to_run
  @env[:initial_states].reject{|id, state| state == :running}.keys
end