Sha256: f169fe37b428fd818d306436bdb78b9f90f15636e901810d76708bf3fbbda8fa

Contents?: true

Size: 954 Bytes

Versions: 17

Compression:

Stored size: 954 Bytes

Contents

require 'log4r'

module VagrantPlugins
  module ProviderLibvirt
    module Action
      # Resume suspended domain.
      class ResumeDomain
        def initialize(app, _env)
          @logger = Log4r::Logger.new('vagrant_libvirt::action::resume_domain')
          @app = app
        end

        def call(env)
          env[:ui].info(I18n.t('vagrant_libvirt.resuming_domain'))

          domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
          raise Errors::NoDomainError if domain.nil?

          libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
          config = env[:machine].provider_config
          if config.suspend_mode == 'managedsave'
            domain.start
          else
            domain.resume
          end

          @logger.info("Machine #{env[:machine].id} is resumed.")

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
vagrant-libvirt-0.5.3 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.5.2 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.5.1 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.5.0 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.4.1 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.4.0 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.3.0 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.2.1 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.1.2 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.1.0 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.0.45 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.0.43 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.0.42 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.0.40 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.0.39 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.0.38 lib/vagrant-libvirt/action/resume_domain.rb
vagrant-libvirt-0.0.37 lib/vagrant-libvirt/action/resume_domain.rb