mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
call stale_volume_remove only if configured libvirt pool exists (#1095)
Move message about removing stale volume unless there is one to be removed.
This commit is contained in:
committed by
GitHub
parent
5e1445f7df
commit
304a2a055c
@@ -16,13 +16,19 @@ module VagrantPlugins
|
|||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
# Remove stale server volume
|
# Remove stale server volume
|
||||||
env[:ui].info(I18n.t('vagrant_libvirt.remove_stale_volume'))
|
|
||||||
|
|
||||||
config = env[:machine].provider_config
|
config = env[:machine].provider_config
|
||||||
# Check for storage pool, where box image should be created
|
# Check for storage pool, where box image should be created
|
||||||
fog_pool = ProviderLibvirt::Util::Collection.find_matching(
|
fog_pool = ProviderLibvirt::Util::Collection.find_matching(
|
||||||
env[:machine].provider.driver.connection.pools.all, config.storage_pool_name
|
env[:machine].provider.driver.connection.pools.all, config.storage_pool_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
env[:result] = nil
|
||||||
|
|
||||||
|
if not fog_pool
|
||||||
|
@logger.debug("**** Pool #{config.storage_pool_name} not found")
|
||||||
|
return @app.call(env)
|
||||||
|
end
|
||||||
|
|
||||||
@logger.debug("**** Pool #{fog_pool.name}")
|
@logger.debug("**** Pool #{fog_pool.name}")
|
||||||
|
|
||||||
# This is name of newly created image for vm.
|
# This is name of newly created image for vm.
|
||||||
@@ -34,13 +40,11 @@ module VagrantPlugins
|
|||||||
env[:machine].provider.driver.connection.volumes.all, name
|
env[:machine].provider.driver.connection.volumes.all, name
|
||||||
)
|
)
|
||||||
if box_volume && box_volume.pool_name == fog_pool.name
|
if box_volume && box_volume.pool_name == fog_pool.name
|
||||||
|
env[:ui].info(I18n.t('vagrant_libvirt.remove_stale_volume'))
|
||||||
@logger.info("Deleting volume #{box_volume.key}")
|
@logger.info("Deleting volume #{box_volume.key}")
|
||||||
box_volume.destroy
|
box_volume.destroy
|
||||||
env[:result] = box_volume
|
env[:result] = box_volume
|
||||||
else
|
|
||||||
env[:result] = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Continue the middleware chain.
|
# Continue the middleware chain.
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user