Sha256: 49dc39665d0e2c9572b05322d0e5cb3998b771de9fe773ba6a62d9877ed24c0c

Contents?: true

Size: 543 Bytes

Versions: 5

Compression:

Stored size: 543 Bytes

Contents

module VagrantPlugins
  module Libvirt
    module Action
      # This can be used with "Call" built-in to check if the machine
      # is suspended and branch in the middleware.
      class IsSuspended
        def initialize(app, env)
          @app = app
        end

        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
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-libvirt-0.0.6 lib/vagrant-libvirt/action/is_suspended.rb
vagrant-libvirt-0.0.5 lib/vagrant-libvirt/action/is_suspended.rb
vagrant-libvirt-0.0.4 lib/vagrant-libvirt/action/is_suspended.rb
vagrant-libvirt-0.0.3 lib/vagrant-libvirt/action/is_suspended.rb
vagrant-libvirt-0.0.2 lib/vagrant-libvirt/action/is_suspended.rb