def getFileSystem(self, case_name, mount_root=None, read_only=False): """ @rtype: EnkfFs """ if mount_root is None: mount_root = self.__mount_root full_case_name = self.__createFullCaseName(mount_root, case_name) if not full_case_name in self.__fs_rotator: if not EnkfFs.exists(full_case_name): if self.__fs_rotator.atCapacity(): self.__fs_rotator.dropOldestFileSystem() if read_only: raise IOError("Tried to access non existing filesystem: '%s' in read-only mode" % full_case_name) EnkfFs.createFileSystem(full_case_name, self.__fs_type, self.__fs_arg) new_fs = EnkfFs(full_case_name, read_only) self.__fs_rotator.addFileSystem(new_fs, full_case_name) fs = self.__fs_rotator[full_case_name] if fs.isReadOnly() and not read_only: fs.setWritable() return fs
def test_create(self): with TestAreaContext("create_fs") as work_area: work_area.copy_parent_content(self.config_file) self.assertTrue(EnkfFs.exists(self.mount_point)) fs = EnkfFs(self.mount_point) self.assertEqual(1, fs.refCount()) fs.umount() self.assertFalse(EnkfFs.exists("newFS")) arg = None EnkfFs.createFileSystem("newFS", EnKFFSType.BLOCK_FS_DRIVER_ID, arg) self.assertTrue(EnkfFs.exists("newFS"))
def test_create2(self): with TestAreaContext("create_fs2") as work_area: work_area.copy_parent_content(self.config_file) new_fs = EnkfFs.createFileSystem("newFS", EnKFFSType.BLOCK_FS_DRIVER_ID, mount=True) self.assertTrue(isinstance(new_fs, EnkfFs))
def getFileSystem(self, case_name, mount_root=None): """ @rtype: EnkfFs """ if mount_root is None: mount_root = self.__mount_root full_case_name = self.__createFullCaseName(mount_root, case_name) if not full_case_name in self.__fs_rotator: if not EnkfFs.exists(full_case_name): if self.__fs_rotator.atCapacity(): self.__fs_rotator.dropOldestFileSystem() EnkfFs.createFileSystem(full_case_name, self.__fs_type, self.__fs_arg) new_fs = EnkfFs(full_case_name) self.__fs_rotator.addFileSystem(new_fs, full_case_name) fs = self.__fs_rotator[full_case_name] return fs
def test_create(self): with TestAreaContext("create_fs") as work_area: work_area.copy_parent_content(self.config_file) self.assertTrue(EnkfFs.exists(self.mount_point)) fs = EnkfFs(self.mount_point) self.assertEqual(1, fs.refCount()) fs.umount() self.assertFalse(EnkfFs.exists("newFS")) arg = None fs = EnkfFs.createFileSystem("newFS", EnKFFSType.BLOCK_FS_DRIVER_ID, arg) self.assertTrue(EnkfFs.exists("newFS")) self.assertTrue(fs is None) with TestAreaContext("create_fs2") as work_area: work_area.copy_parent_content(self.config_file) new_fs = EnkfFs.createFileSystem("newFS", EnKFFSType.BLOCK_FS_DRIVER_ID, mount=True) self.assertTrue(isinstance(new_fs, EnkfFs))
def test_create(self): with TestAreaContext("create_fs") as work_area: work_area.copy_parent_content(self.config_file) self.assertTrue(EnkfFs.exists(self.mount_point)) fs = EnkfFs(self.mount_point) self.assertEqual(1, fs.refCount()) fs.umount() self.assertFalse(EnkfFs.exists("newFS")) arg = None fs = EnkfFs.createFileSystem("newFS", EnKFFSType.BLOCK_FS_DRIVER_ID, arg) self.assertTrue(EnkfFs.exists("newFS")) self.assertTrue( fs is None ) with self.assertRaises(IOError): version = EnkfFs.diskVersion("does/not/exist") version = EnkfFs.diskVersion("newFS") self.assertTrue( version >= 106 )
def test_create(self): with TestAreaContext("create_fs") as work_area: work_area.copy_parent_content(self.config_file) self.assertTrue(EnkfFs.exists(self.mount_point)) fs = EnkfFs(self.mount_point) self.assertEqual(1, fs.refCount()) fs.umount() self.assertFalse(EnkfFs.exists("newFS")) arg = None fs = EnkfFs.createFileSystem("newFS", EnKFFSType.BLOCK_FS_DRIVER_ID, arg) self.assertTrue(EnkfFs.exists("newFS")) self.assertTrue(fs is None) with self.assertRaises(IOError): version = EnkfFs.diskVersion("does/not/exist") version = EnkfFs.diskVersion("newFS") self.assertTrue(version >= 106)
def test_create2(self): with TestAreaContext("create_fs2") as work_area: work_area.copy_parent_content(self.config_file) new_fs = EnkfFs.createFileSystem("newFS", EnKFFSType.BLOCK_FS_DRIVER_ID, mount = True) self.assertTrue( isinstance( new_fs , EnkfFs ))