Sha256: d7d76a3b51336e6d6bafd7171d849fe28603da15151527310b8fde78f9af7654

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

require "log4r"

module VagrantPlugins
  module Registration
    module Action
      # This unregisters the guest if the guest plugin supports it
      class Unregister

        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_registration::action::unregister")
        end

        def call(env)
          guest = env[:machine].guest

          if guest.capability?(:unregister) && guest.capability?(:subscription_manager)
            if !env[:machine].config.registration.skip
              env[:ui].info("Unregistering box with vagrant-registration...")
              @logger.info("registration_unregister capability exists on ")
              result = guest.capability(:unregister)
              @logger.info("called registration_unregister capability on ")
            else
              @logger.debug("unregistration is skipped due to configuration")
            end
          else
            @logger.debug("unregistration is skipped due to missing guest capability")
          end

          @app.call(env)

        # Guest might not be available after halting, so log the exception and continue
        rescue => e
          @logger.info(e)
          @logger.debug("guest is not available, ignore unregistration")
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-registration-0.0.11 lib/vagrant-registration/action/unregister.rb
vagrant-registration-0.0.10 lib/vagrant-registration/action/unregister.rb
vagrant-registration-0.0.9 lib/vagrant-registration/action/unregister.rb
vagrant-registration-0.0.8 lib/vagrant-registration/action/unregister.rb
vagrant-registration-0.0.7 lib/vagrant-registration/action/unregister.rb