Class: VagrantPlugins::Registration::Action::UnregisterOnDestroy
- Inherits:
-
Object
- Object
- VagrantPlugins::Registration::Action::UnregisterOnDestroy
- Defined in:
- lib/vagrant-registration/action/unregister_on_destroy.rb
Overview
This unregisters the guest if the guest has registration capability
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ UnregisterOnDestroy
constructor
A new instance of UnregisterOnDestroy.
Constructor Details
#initialize(app, env) ⇒ UnregisterOnDestroy
Returns a new instance of UnregisterOnDestroy.
8 9 10 11 |
# File 'lib/vagrant-registration/action/unregister_on_destroy.rb', line 8 def initialize(app, env) @app = app @logger = Log4r::Logger.new('vagrant_registration::action::unregister_on_destroy') end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vagrant-registration/action/unregister_on_destroy.rb', line 13 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 |