Sha256: eeba2901a253cca373e795e54ffa223e4767b5b0a2803ee622b46e7fb9050138

Contents?: true

Size: 741 Bytes

Versions: 6

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

require 'log4r'

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

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

          if env[:machine].state.id == :inactive
            env[:ui].info(I18n.t('vagrant_packet.already_status', status: env[:machine].state.id))
          else
            env[:ui].info(I18n.t('vagrant_packet.stopping'))
            server.stop
          end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-packet-0.1.6 lib/vagrant-packet/action/stop_instance.rb
vagrant-packet-0.1.5 lib/vagrant-packet/action/stop_instance.rb
vagrant-packet-0.1.4 lib/vagrant-packet/action/stop_instance.rb
vagrant-packet-0.1.3 lib/vagrant-packet/action/stop_instance.rb
vagrant-packet-0.1.2 lib/vagrant-packet/action/stop_instance.rb
vagrant-packet-0.1.1 lib/vagrant-packet/action/stop_instance.rb