Class: VagrantPlugins::ProviderLibvirt::Action::SuspendDomain
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderLibvirt::Action::SuspendDomain
- Defined in:
- lib/vagrant-libvirt/action/suspend_domain.rb
Overview
Suspend domain.
Instance Method Summary collapse
-
#call(env) ⇒ Object
make pause.
-
#initialize(app, _env) ⇒ SuspendDomain
constructor
A new instance of SuspendDomain.
Constructor Details
#initialize(app, _env) ⇒ SuspendDomain
Returns a new instance of SuspendDomain.
10 11 12 13 |
# File 'lib/vagrant-libvirt/action/suspend_domain.rb', line 10 def initialize(app, _env) @logger = Log4r::Logger.new('vagrant_libvirt::action::suspend_domain') @app = app end |
Instance Method Details
#call(env) ⇒ Object
make pause
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vagrant-libvirt/action/suspend_domain.rb', line 16 def call(env) env[:ui].info(I18n.t('vagrant_libvirt.suspending_domain')) domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s) raise Errors::NoDomainError if domain.nil? config = env[:machine].provider_config if config.suspend_mode == 'managedsave' libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id) begin libvirt_domain.managed_save rescue => e env[:ui].error("Error doing a managed save for domain. It may have entered a paused state. Check the output of `virsh managedsave DOMAIN_NAME --verbose` on the VM host, error: #{e.}") end else domain.suspend end @logger.info("Machine #{env[:machine].id} is suspended ") @app.call(env) end |