Class: VagrantPlugins::Cloudstack::Action::TerminateInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-cloudstack/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-cloudstack/action/terminate_instance.rb', line 8

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

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-cloudstack/action/terminate_instance.rb', line 13

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

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

  @app.call(env)
end