Sha256: 6384eb073766b000972b24adcf6ca554cf28be4890dc443e87fc1172aa5c900e

Contents?: true

Size: 847 Bytes

Versions: 11

Compression:

Stored size: 847 Bytes

Contents

require "log4r"

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

        def call(env)
          # Destroy the server and remove the tracking ID
          env[:ui].info(I18n.t("vagrant_shell.terminating"))
          output = %x{ #{env[:machine].provider_config.script} terminate-instance #{env[:machine].id}}
          if $?.to_i > 0
            raise Errors::ShellError, :message => "Failure: #{env[:machine].provider_config.script} terminate-instance #{env[:machine].id}"
          end

          puts output

          env[:machine].id = nil

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vagrant-shell-0.2.22 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.21 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.20 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.19 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.17 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.16 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.15 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.13 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.12 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.9 lib/vagrant-shell/action/terminate_instance.rb
vagrant-shell-0.2.8 lib/vagrant-shell/action/terminate_instance.rb