Class: VagrantPlugins::AWS::Action::StopInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-aws/action/stop_instance.rb

Overview

This stops the running instance.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ StopInstance

Returns a new instance of StopInstance.



8
9
10
11
# File 'lib/vagrant-aws/action/stop_instance.rb', line 8

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

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-aws/action/stop_instance.rb', line 13

def call(env)
  server = env[:aws_compute].servers.get(env[:machine].id)

  if env[:machine].state.id == :stopped
    env[:ui].info(I18n.t("vagrant_aws.already_status", :status => env[:machine].state.id))
  else
    env[:ui].info(I18n.t("vagrant_aws.stopping"))
    server.stop(!!env[:force_halt])
  end

  @app.call(env)
end