Class: VagrantPlugins::ProviderLibvirt::Action::IsSuspended
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderLibvirt::Action::IsSuspended
- Defined in:
- lib/vagrant-libvirt/action/is_suspended.rb
Overview
This can be used with “Call” built-in to check if the machine is suspended and branch in the middleware.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ IsSuspended
constructor
A new instance of IsSuspended.
Constructor Details
#initialize(app, env) ⇒ IsSuspended
Returns a new instance of IsSuspended.
7 8 9 |
# File 'lib/vagrant-libvirt/action/is_suspended.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_suspended.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 == 'paused' @app.call(env) end |