Class: VagrantPlugins::Google::Action::TerminateInstance
- Inherits:
-
Object
- Object
- VagrantPlugins::Google::Action::TerminateInstance
- Defined in:
- lib/vagrant-google/action/terminate_instance.rb
Overview
This terminates the running instance.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ TerminateInstance
constructor
A new instance of TerminateInstance.
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 36 |
# 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 # destroy() is called with 'false' to disable asynchronous execution. env[:ui].info(I18n.t("vagrant_google.terminating")) server.destroy(false) unless server.nil? env[:machine].id = nil @app.call(env) end |