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.



20
21
22
23
24
# File 'lib/vagrant-skytap/action/stop_environment.rb', line 20

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.



18
19
20
# File 'lib/vagrant-skytap/action/stop_environment.rb', line 18

def env
  @env
end

Instance Method Details

#call(env) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vagrant-skytap/action/stop_environment.rb', line 26

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