Add storage.pool_exists

This commit is contained in:
Bahtiar `kalkin-` Gadimov 2015-11-07 19:32:03 +01:00
parent 8e0207a199
commit d1685a13df
2 changed files with 18 additions and 0 deletions

View File

@ -291,6 +291,15 @@ def _get_pool_klass(name, config=None):
return klass
def pool_exists(name):
""" Check if the specified pool exists """
try:
_get_pool_klass(name)
return True
except StoragePoolException:
return False
class StoragePoolException(QubesException):
pass

View File

@ -52,6 +52,15 @@ class TC_00_Storage(SystemTestsMixin, QubesTestCase):
result = qubes.storage._get_pool_klass('default')
self.assertTrue(result is XenPool)
def test_004_pool_exists_default(self):
""" Expect the default pool to exists """
self.assertTrue(qubes.storage.pool_exists('default'))
def test_005_pool_exists_random(self):
""" Expect this pool to not a exist """
self.assertFalse(
qubes.storage.pool_exists('asdh312096r832598213iudhas'))
class TC_01_Storage(SystemTestsMixin, QubesTestCase):