constants.DT_PLAIN: "",
constants.DT_RBD: ".rbd",
constants.DT_EXT: ".ext",
+ constants.DT_FILE: ".file",
+ constants.DT_SHARED_FILE: ".sharedfile",
}
elif template_name in (constants.DT_FILE, constants.DT_SHARED_FILE):
logical_id_fn = \
lambda _, disk_index, disk: (file_driver,
- "%s/disk%d" % (file_storage_dir,
- disk_index))
+ "%s/%s" % (file_storage_dir,
+ names[idx]))
elif template_name == constants.DT_BLOCK:
logical_id_fn = \
lambda idx, disk_index, disk: (constants.BLOCKDEV_DRIVER_MANUAL,
import os
+import re
import unittest
import tempfile
import shutil
req_file_storage=self._AllowFileStorage,
req_shr_file_storage=self._AllowFileStorage)
- self.assertEqual(map(operator.attrgetter("logical_id"), result), [
- (constants.FD_BLKTAP, "/tmp/disk2"),
- (constants.FD_BLKTAP, "/tmp/disk3"),
- (constants.FD_BLKTAP, "/tmp/disk4"),
- ])
+ for (idx, disk) in enumerate(result):
+ (file_driver, file_storage_dir) = disk.logical_id
+ dir_fmt = r"^/tmp/.*\.%s\.disk%d$" % (disk_template, idx + 2)
+ self.assertEqual(file_driver, constants.FD_BLKTAP)
+ # FIXME: use assertIsNotNone when py 2.7 is minimum supported version
+ self.assertNotEqual(re.match(dir_fmt, file_storage_dir), None)
def testBlock(self):
disk_info = [{