Class: VagrantPlugins::Skytap::Action::StopEnvironment

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

Overview

Stops the Skytap environment and waits until stopped.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ StopEnvironment

Returns a new instance of StopEnvironment.



42
43
44
45
46
# File 'lib/vagrant-skytap/action/stop_environment.rb', line 42

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

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



40
41
42
# File 'lib/vagrant-skytap/action/stop_environment.rb', line 40

def env
  @env
end

Instance Method Details

#call(env) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/vagrant-skytap/action/stop_environment.rb', line 48

def call(env)
  environment = env[:environment]
  if env[:force_halt]
    environment.poweroff!
  else
    begin
      environment.stop!
    rescue Errors::InstanceReadyTimeout
      @logger.info(I18n.t("vagrant_skytap.graceful_halt_environment_failed"))
      environment.poweroff!
    end
  end
  @app.call(env)
end