Class: VagrantPlugins::TiktalikVagrant::Action::TerminateInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-tiktalik/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.



11
12
13
14
15
# File 'lib/vagrant-tiktalik/action/terminate_instance.rb', line 11

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant_tiktalik::action::terminate_instance")
  @config = env[:machine].provider_config
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-tiktalik/action/terminate_instance.rb', line 17

def call(env)
  # Destroy the server and remove the tracking ID
  env[:ui].info(I18n.t("vagrant_tiktalik.terminating"))

  t = Tiktalik
  t.api_key = @config.api_key
  t.api_secret_key = @config.api_secret
  t.ca_file = @config.ca_file

  i = Tiktalik::Computing::Instance
  instance = i.find env[:machine].id
  instance.destroy

  env[:machine].id = nil

  @app.call(env)
end