Class: VagrantPlugins::ProviderKvm::Action::CheckCreated

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-kvm/action/check_created.rb

Overview

This middleware checks that the VM is created, and raises an exception if it is not, notifying the user that creation is required.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ CheckCreated

Returns a new instance of CheckCreated.



7
8
9
# File 'lib/vagrant-kvm/action/check_created.rb', line 7

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/vagrant-kvm/action/check_created.rb', line 11

def call(env)
  if env[:machine].state.id == :not_created
    raise Vagrant::Errors::VMNotCreatedError
  end

  @app.call(env)
end