/usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.0.43/lib/vagrant-libvirt/action/halt_domain.rb is in vagrant-libvirt 0.0.43-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | require 'log4r'
module VagrantPlugins
module ProviderLibvirt
module Action
# Halt the domain.
class HaltDomain
def initialize(app, _env)
@logger = Log4r::Logger.new('vagrant_libvirt::action::halt_domain')
@app = app
end
def call(env)
env[:ui].info(I18n.t('vagrant_libvirt.halt_domain'))
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
raise Errors::NoDomainError if domain.nil?
begin
env[:machine].guest.capability(:halt)
rescue
@logger.info('Trying libvirt graceful shutdown.')
domain.shutdown
end
begin
domain.wait_for(30) do
!ready?
end
rescue Fog::Errors::TimeoutError
@logger.info('VM is still running. Calling force poweroff.')
domain.poweroff
end
@app.call(env)
end
end
end
end
end
|