Class: VagrantPlugins::Google::Action::TerminateInstance

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



21
22
23
24
# File 'lib/vagrant-google/action/terminate_instance.rb', line 21

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

Instance Method Details

#call(env) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/vagrant-google/action/terminate_instance.rb', line 26

def call(env)
  server = env[:google_compute].servers.get(env[:machine].id, env[:machine].provider_config.zone)

  # Destroy the server and remove the tracking ID
  env[:ui].info(I18n.t("vagrant_google.terminating"))
  server.destroy if not server.nil?
  env[:machine].id = nil

  @app.call(env)
end