def call(env)
config = env[:machine].provider_config
@@lock.synchronize do
break if ProviderLibvirt::Util::Collection.find_matching(
env[:machine].provider.driver.connection.pools.all, config.storage_pool_name)
@logger.info("No storage pool '#{config.storage_pool_name}' is available.")
raise Errors::NoStoragePool if config.storage_pool_name != 'default'
@logger.info("Creating storage pool 'default'")
begin
libvirt_pool = env[:machine].provider.driver.connection.client.define_storage_pool_xml(
to_xml('default_storage_pool'))
libvirt_pool.build
libvirt_pool.create
rescue => e
raise Errors::CreatingStoragePoolError,
:error_message => e.message
end
raise Errors::NoStoragePool if !libvirt_pool
end
@app.call(env)
end