Class: VagrantPlugins::Shell::Action::TerminateInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-shell/action/terminate_instance.rb

Overview

This terminates the running instance.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ TerminateInstance

Returns a new instance of TerminateInstance.



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

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

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  # Destroy the server and remove the tracking ID
  env[:ui].info(I18n.t("vagrant_shell.terminating"))
  output = %x{ #{env[:machine].provider_config.script} terminate-instance #{env[:machine].id}}
  if $?.to_i > 0
    raise Errors::ShellError, :message => "Failure: #{env[:machine].provider_config.script} terminate-instance #{env[:machine].id}"
  end

  puts output

  env[:machine].id = nil

  @app.call(env)
end