Sha256: e34877f4cd8d86c89db06199edef649b3f554b70d39ee96a0a9e5255bf74a192

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

require "log4r"
require "json"
require "fileutils"

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

        def call(env)
          stop_instance(env)
          # Remove the tracking ID
          env[:ui].info(I18n.t("vagrant_xhyve.terminating"))
          FileUtils.rm_rf(env[:machine].data_dir)

          @app.call(env)
        end

        def stop_instance(env)
          halt_env = env.dup
          env[:action_runner].run(Action.action_halt, halt_env)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-xhyve-0.4.1 lib/vagrant-xhyve/action/terminate_instance.rb
vagrant-xhyve-0.4.0 lib/vagrant-xhyve/action/terminate_instance.rb
vagrant-xhyve-0.3.0 lib/vagrant-xhyve/action/terminate_instance.rb