Class: VagrantPlugins::ProviderKvm::Action::CheckRunning

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

Overview

This middleware checks that the VM is running, and raises an exception if it is not, notifying the user that the VM must be running.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ CheckRunning

Returns a new instance of CheckRunning.



7
8
9
# File 'lib/vagrant-kvm/action/check_running.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_running.rb', line 11

def call(env)
  if env[:machine].state.id != :running
    raise Vagrant::Errors::VMNotRunningError
  end

  @app.call(env)
end