Class: VagrantPlugins::G5K::Action::RunInstance

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Util::Retryable
Defined in:
lib/vagrant-g5k/action/run_instance.rb

Overview

This runs the configured instance.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ RunInstance

Returns a new instance of RunInstance.



13
14
15
16
# File 'lib/vagrant-g5k/action/run_instance.rb', line 13

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

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
# File 'lib/vagrant-g5k/action/run_instance.rb', line 18

def call(env)
  # Note: here we are sure that we have to start the vm
  conn = env[:g5k_connection]
  conn.launch_vm(env)
  @app.call(env)
end

#recover(env) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/vagrant-g5k/action/run_instance.rb', line 25

def recover(env)
  return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)

  if ![:not_created, :shutdown].include?(env[:machine].provider.state.id)
    # Undo the import
    terminate(env)
  end
end

#terminate(env) ⇒ Object



34
35
36
# File 'lib/vagrant-g5k/action/run_instance.rb', line 34

def terminate(env)
 @logger.info("Terminate the machine")
end