Class: VagrantPlugins::ProviderLibvirt::Action::SetupComplete

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-libvirt/action/cleanup_on_failure.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ SetupComplete

Returns a new instance of SetupComplete.



56
57
58
59
# File 'lib/vagrant-libvirt/action/cleanup_on_failure.rb', line 56

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

Instance Method Details

#call(env) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/vagrant-libvirt/action/cleanup_on_failure.rb', line 61

def call(env)
  if env['vagrant-libvirt.complete'].nil? or !env['vagrant-libvirt.complete'].respond_to? :call
    raise Errors::CallChainError, require_action: CleanupOnFailure.name, current_action: SetupComplete.name
  end

  @logger.debug('Marking provider setup as completed')
  # mark provider as finished setup so that any failure after this
  # point doesn't result in destroying or shutting down the VM
  env['vagrant-libvirt.complete'].call

  @app.call(env)
end