mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
commit
2d088d43df
@ -18,9 +18,15 @@ module VagrantPlugins
|
|||||||
|
|
||||||
def read_state(libvirt, machine)
|
def read_state(libvirt, machine)
|
||||||
return :not_created if machine.id.nil?
|
return :not_created if machine.id.nil?
|
||||||
|
|
||||||
|
begin
|
||||||
|
server = libvirt.servers.get(machine.id)
|
||||||
|
rescue Libvirt::RetrieveError => e
|
||||||
|
server = nil
|
||||||
|
@logger.debug('Machine not found #{e}.')
|
||||||
|
end
|
||||||
# Find the machine
|
# Find the machine
|
||||||
server = libvirt.servers.get(machine.id)
|
|
||||||
if server.nil? || [:'shutting-down', :terminated].include?(server.state.to_sym)
|
if server.nil? || [:'shutting-down', :terminated].include?(server.state.to_sym)
|
||||||
# The machine can't be found
|
# The machine can't be found
|
||||||
@logger.info('Machine not found or terminated, assuming it got destroyed.')
|
@logger.info('Machine not found or terminated, assuming it got destroyed.')
|
||||||
|
@ -21,10 +21,16 @@ module VagrantPlugins
|
|||||||
env[:domain_name] << '_'
|
env[:domain_name] << '_'
|
||||||
env[:domain_name] << env[:machine].name.to_s
|
env[:domain_name] << env[:machine].name.to_s
|
||||||
|
|
||||||
|
begin
|
||||||
@logger.info("Looking for domain #{env[:domain_name]} through list #{env[:libvirt_compute].servers.all}")
|
@logger.info("Looking for domain #{env[:domain_name]} through list #{env[:libvirt_compute].servers.all}")
|
||||||
# Check if the domain name is not already taken
|
# Check if the domain name is not already taken
|
||||||
domain = ProviderLibvirt::Util::Collection.find_matching(
|
|
||||||
|
domain = ProviderLibvirt::Util::Collection.find_matching(
|
||||||
env[:libvirt_compute].servers.all, env[:domain_name])
|
env[:libvirt_compute].servers.all, env[:domain_name])
|
||||||
|
rescue Fog::Errors::Error => e
|
||||||
|
@logger.info("#{e}")
|
||||||
|
domain = nil
|
||||||
|
end
|
||||||
|
|
||||||
@logger.info("Looking for domain #{env[:domain_name]}")
|
@logger.info("Looking for domain #{env[:domain_name]}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user