XenStorage make sure subdirs exist in pool dir
This commit is contained in:
parent
58f23ca392
commit
0bc0bc9045
@ -271,8 +271,14 @@ class XenPool(Pool):
|
|||||||
assert vm is not None
|
assert vm is not None
|
||||||
assert dir is not None
|
assert dir is not None
|
||||||
|
|
||||||
if not os.path.exists(dir):
|
appvms_path = os.path.join(dir, 'appvms')
|
||||||
os.mkdir(dir)
|
servicevms_path = os.path.join(dir, 'servicevms')
|
||||||
|
vm_templates_path = os.path.join(dir, 'vm-templates')
|
||||||
|
|
||||||
|
self._create_dir_if_not_exists(dir)
|
||||||
|
self._create_dir_if_not_exists(appvms_path)
|
||||||
|
self._create_dir_if_not_exists(servicevms_path)
|
||||||
|
self._create_dir_if_not_exists(vm_templates_path)
|
||||||
|
|
||||||
self.vmdir = self._vmdir_path(vm, dir)
|
self.vmdir = self._vmdir_path(vm, dir)
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
@ -314,3 +320,10 @@ class XenPool(Pool):
|
|||||||
|
|
||||||
return os.path.join(pool_dir, subdir, vm.name)
|
return os.path.join(pool_dir, subdir, vm.name)
|
||||||
|
|
||||||
|
def _create_dir_if_not_exists(self, path):
|
||||||
|
""" Check if a directory exists in if not it is created.
|
||||||
|
|
||||||
|
This method does not create any parent directories.
|
||||||
|
"""
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.mkdir(path)
|
||||||
|
@ -134,7 +134,7 @@ class TC_01_Pool(SystemTestsMixin, QubesTestCase):
|
|||||||
self.assertTrue(qubes.storage.pool_exists('test-pool'))
|
self.assertTrue(qubes.storage.pool_exists('test-pool'))
|
||||||
|
|
||||||
def test_002_pool_dir_create(self):
|
def test_002_pool_dir_create(self):
|
||||||
""" Check if the storage pool dir was created """
|
""" Check if the storage pool dir and subdirs were created """
|
||||||
|
|
||||||
# The dir should not exists before
|
# The dir should not exists before
|
||||||
self.assertFalse(os.path.exists(self.POOL_DIR))
|
self.assertFalse(os.path.exists(self.POOL_DIR))
|
||||||
@ -145,6 +145,9 @@ class TC_01_Pool(SystemTestsMixin, QubesTestCase):
|
|||||||
pool_name='test-pool')
|
pool_name='test-pool')
|
||||||
|
|
||||||
self.assertTrue(os.path.exists(self.POOL_DIR))
|
self.assertTrue(os.path.exists(self.POOL_DIR))
|
||||||
|
self.assertTrue(os.path.exists(self.APPVMS_DIR))
|
||||||
|
self.assertTrue(os.path.exists(self.SERVICE_DIR))
|
||||||
|
self.assertTrue(os.path.exists(self.TEMPLATES_DIR))
|
||||||
|
|
||||||
def test_003_pool_dir(self):
|
def test_003_pool_dir(self):
|
||||||
""" Check if the vm storage pool_dir is the same as specified """
|
""" Check if the vm storage pool_dir is the same as specified """
|
||||||
|
Loading…
Reference in New Issue
Block a user