Sha256: 7ec103490c9fe501949706dac020d0d366956687b0e9fe442f9234a3069fbb20
Contents?: true
Size: 1.81 KB
Versions: 6
Compression:
Stored size: 1.81 KB
Contents
require 'log4r' module VagrantPlugins module Registration module Action # This unregisters the guest if the guest has registration capability class UnregisterOnDestroy def initialize(app, env) @app = app @logger = Log4r::Logger.new('vagrant_registration::action::unregister_on_destroy') end def call(env) config = env[:machine].config.registration guest = env[:machine].guest if capabilities_provided?(guest) && manager_installed?(guest, env[:ui]) && !config.skip env[:ui].info I18n.t('registration.action.unregister.unregistration_info') guest.capability(:registration_unregister) end @logger.debug(I18n.t('registration.action.unregister.skip_due_config')) if config.skip @app.call(env) # Guest might not be available after halting, so log the exception and continue rescue => e @logger.info(e) @logger.debug I18n.t('registration.action.unregister.guest_unavailable') @app.call(env) end private # Check if registration capabilities are available def capabilities_provided?(guest) if guest.capability?(:registration_unregister) && guest.capability?(:registration_manager_installed) true else @logger.debug I18n.t('registration.action.unregister.skip_missing_guest_capability') false end end # Check if selected registration manager is installed def manager_installed?(guest, ui) if guest.capability(:registration_manager_installed, ui) true else @logger.debug I18n.t('registration.action.manager_not_found') false end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems