Sha256: 82ab95de74eaf2ddd7a258103cb7f5446e4eb201b8f48e15101fac55349256fa

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require 'log4r'
require 'vagrant-local/util/timer'
require 'vagrant/util/retryable'

module VagrantPlugins
  module ProviderLocal
    module Action
      # This is used wait till the instance is booted
      class WaitTillBoot
        include Vagrant::Util::Retryable

        def initialize(app, _env)
          @logger = Log4r::Logger.new('vagrant_local::action::import')
          @app = app
        end

        def terminate(env)
          return unless env[:machine].state.id != :not_created

          # If we're not supposed to destroy on error then just return
          return unless env[:destroy_on_error]

          if env[:halt_on_error]
            halt_env = env.dup
            halt_env.delete(:interrupted)
            halt_env[:config_validate] = false
            env[:action_runner].run(Action.action_halt, halt_env)
          else
            destroy_env = env.dup
            destroy_env.delete(:interrupted)
            destroy_env[:config_validate] = false
            destroy_env[:force_confirm_destroy] = true
            env[:action_runner].run(Action.action_destroy, destroy_env)
          end
        end

        def call(env)
          @machine = env[:machine]
          @driver  = @machine.provider.driver
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-local-0.0.3 lib/vagrant-local/action/wait_till_boot.rb
vagrant-local-0.0.2 lib/vagrant-local/action/wait_till_boot.rb
vagrant-local-0.0.1 lib/vagrant-local/action/wait_till_boot.rb