Example #1
0
    def test_mount_existing_fs_fails(self):
        fs = filesystem.FileSystemsModel()
        fsd = filesystem.FileSystemModel()

        create_file(self)

        fstype = 'local'
        blkdev = '/testfile'
        mntpt = '/test'
        persistent = False

        with RollbackContext() as rollback:
            fs.create({
                'type': fstype,
                'blk_dev': blkdev,
                'mount_point': mntpt,
                'persistent': persistent
            })
            rollback.prependDefer(fsd.delete, mntpt)

            with self.assertRaises(InvalidParameter):
                fs.create({
                    'type': fstype,
                    'blk_dev': blkdev,
                    'mount_point': mntpt,
                    'persistent': persistent
                })

        delete_file(self)
Example #2
0
    def test_mount_local_fs(self):
        fs = filesystem.FileSystemsModel()
        fsd = filesystem.FileSystemModel()

        create_file(self)

        fstype = 'local'
        blkdev = '/testfile'
        mntpt = '/test'
        persistent = False

        fs_list = fs.get_list()
        with RollbackContext() as rollback:
            fs.create({
                'type': fstype,
                'blk_dev': blkdev,
                'mount_point': mntpt,
                'persistent': persistent
            })
            rollback.prependDefer(fsd.delete, mntpt)

            new_fs_list = fs.get_list()
            self.assertEqual(len(new_fs_list), len(fs_list) + 1)

        delete_file(self)