Class: VagrantPlugins::Libvirt::Action::IsRunning
- Inherits:
-
Object
- Object
- VagrantPlugins::Libvirt::Action::IsRunning
- Defined in:
- lib/vagrant-libvirt/action/is_running.rb
Overview
This can be used with “Call” built-in to check if the machine is running and branch in the middleware.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ IsRunning
constructor
A new instance of IsRunning.
Constructor Details
#initialize(app, env) ⇒ IsRunning
Returns a new instance of IsRunning.
7 8 9 |
# File 'lib/vagrant-libvirt/action/is_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-libvirt/action/is_running.rb', line 11 def call(env) domain = env[:libvirt_compute].servers.get(env[:machine].id.to_s) raise Errors::NoDomainError if domain == nil env[:result] = domain.state.to_s == 'running' @app.call(env) end |