Sha256: 2e97ac2a366526b5293684d64451c55aef6d4c5a1802329bcbcc65a100a9d7d6

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require "log4r"

module VagrantPlugins
  module Google
    module Action
      # This terminates the running instance.
      class TerminateInstance
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_google::action::terminate_instance")
        end

        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
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vagrant-google-1.0.0 lib/vagrant-google/action/terminate_instance.rb
vagrant-google-1.0.0.rc0 lib/vagrant-google/action/terminate_instance.rb
vagrant-google-0.2.5 lib/vagrant-google/action/terminate_instance.rb
vagrant-google-0.2.5.rc0 lib/vagrant-google/action/terminate_instance.rb
vagrant-google-0.2.4 lib/vagrant-google/action/terminate_instance.rb
vagrant-google-0.2.3 lib/vagrant-google/action/terminate_instance.rb
vagrant-google-0.2.2 lib/vagrant-google/action/terminate_instance.rb