app: check DEFAULT_LVM_POOL variable for default pool

Allow to hint default_pool what is default storage pool - especially
useful for tests.
This commit is contained in:
Marek Marczykowski-Górecki 2017-12-01 02:56:01 +01:00
parent 749e8497e3
commit 2d830caab9
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -566,6 +566,15 @@ def _default_pool(app):
if 'default' in app.pools:
return app.pools['default']
else:
if 'DEFAULT_LVM_POOL' in os.environ:
thin_pool = os.environ['DEFAULT_LVM_POOL']
for pool in app.pools.values():
if pool.config.get('driver', None) != 'lvm_thin':
continue
print(pool.config['thin_pool'], thin_pool)
if pool.config['thin_pool'] == thin_pool:
return pool
# no DEFAULT_LVM_POOL, or pool not defined
rootfs = os.stat('/')
root_major = (rootfs.st_dev & 0xff00) >> 8
root_minor = rootfs.st_dev & 0xff