mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Check for empty result from fog-libvirt volumes
The fog-libvirt volumes filter behaves differently than the others in that it returns an empty volume object if nothing is found. This has the potential to change in the future so guard against an empty result as well by checking if the assigned first element is nil.
This commit is contained in:
parent
86aac4ce9c
commit
34d933deea
@ -28,7 +28,7 @@ module VagrantPlugins
|
||||
domain_volume = env[:machine].provider.driver.connection.volumes.all(
|
||||
name: @name
|
||||
).first
|
||||
raise Errors::DomainVolumeExists if domain_volume.id
|
||||
raise Errors::DomainVolumeExists if domain_volume && domain_volume.id
|
||||
|
||||
# Get path to backing image - box volume.
|
||||
box_volume = env[:machine].provider.driver.connection.volumes.all(
|
||||
|
@ -63,9 +63,10 @@ module VagrantPlugins
|
||||
# locking all subsequent actions as well.
|
||||
@@lock.synchronize do
|
||||
# Don't continue if image already exists in storage pool.
|
||||
break if env[:machine].provider.driver.connection.volumes.all(
|
||||
box_volume = env[:machine].provider.driver.connection.volumes.all(
|
||||
name: env[:box_volume_name]
|
||||
).first.id
|
||||
).first
|
||||
break if box_volume && box_volume.id
|
||||
|
||||
# Box is not available as a storage pool volume. Create and upload
|
||||
# it as a copy of local box image.
|
||||
|
Loading…
Reference in New Issue
Block a user