Sha256: 29c24d760b08aba5e220905227d4aaa24dd550f8eb6d2b46a898e78a25089d81

Contents?: true

Size: 687 Bytes

Versions: 4

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

require 'log4r'
require 'json'

module VagrantPlugins
  module Packet
    module Action
      # This terminates the running instance.
      class TerminateInstance
        def initialize(app, _env)
          @app    = app
          @logger = Log4r::Logger.new('vagrant_packet::action::terminate_instance')
        end

        def call(env)
          server = env[:packet_compute].devices.get(env[:machine].id)

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-packet-0.1.4 lib/vagrant-packet/action/terminate_instance.rb
vagrant-packet-0.1.3 lib/vagrant-packet/action/terminate_instance.rb
vagrant-packet-0.1.2 lib/vagrant-packet/action/terminate_instance.rb
vagrant-packet-0.1.1 lib/vagrant-packet/action/terminate_instance.rb