コード例 #1
0
ファイル: test_filesystems.py プロジェクト: lcorreia/ginger
    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)
コード例 #2
0
ファイル: test_filesystems.py プロジェクト: lcorreia/ginger
    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)
コード例 #3
0
ファイル: test_filesystems.py プロジェクト: lcorreia/ginger
    def test_nfs_mount_missing_share(self):
        fs = filesystem.FileSystemsModel()
        fstype = 'nfs'
        server = 'localhost'
        mntpt = '/test'

        params = {'type': fstype, 'server': server, 'mount_point': mntpt}

        self.assertRaises(MissingParameter, fs.create, params)
コード例 #4
0
ファイル: test_filesystems.py プロジェクト: lcorreia/ginger
    def test_nfs_mount_missing_mountpoint(self):
        fs = filesystem.FileSystemsModel()
        fstype = 'nfs'
        server = 'localhost'
        share = '/var/ftp/nfs1'

        params = {'type': fstype, 'server': server, 'share': share}

        self.assertRaises(MissingParameter, fs.create, params)
コード例 #5
0
ファイル: test_filesystems.py プロジェクト: lcorreia/ginger
    def test_nfs_mount_missing_server(self):
        fs = filesystem.FileSystemsModel()
        fstype = 'nfs'
        share = '/var/ftp/nfs1'
        mntpt = '/test'

        params = {'type': fstype, 'share': share, 'mount_point': mntpt}

        self.assertRaises(MissingParameter, fs.create, params)
コード例 #6
0
ファイル: test_filesystems.py プロジェクト: lcorreia/ginger
    def test_nfs_mount_missing_type(self):
        fs = filesystem.FileSystemsModel()
        server = 'localhost'
        share = '/var/ftp/nfs1'
        mntpt = '/test'

        params = {'server': server, 'share': share, 'mount_point': mntpt}

        self.assertRaises(MissingParameter, fs.create, params)
コード例 #7
0
    def test_nfs_mount_missing_server(self):
        fs = filesystem.FileSystemsModel()
        fstype = 'nfs'
        share = NFSSHARE
        mntpt = TESTDIR

        params = {'type': fstype, 'share': share, 'mount_point': mntpt}

        self.assertRaises(MissingParameter, fs.create, params)
コード例 #8
0
    def test_nfs_mount_invalid_type(self):
        fs = filesystem.FileSystemsModel()
        fstype = 'invalid'
        server = 'localhost'
        share = '/var/ftp/nfs1'
        mntpt = '/test'

        params = {'type': fstype, 'server': server,
                  'share': share, 'mount_point': mntpt}

        self.assertRaises(InvalidParameter, fs.create, params)
コード例 #9
0
    def test_nfs_mount(self, mock_make_persist, mock_nfsmount):
        fs = filesystem.FileSystemsModel()
        fstype = 'nfs'
        server = 'localhost'
        share = '/var/ftp/nfs1'
        mntpt = '/test'
        mntopts = ''

        fs.create({'type': fstype, 'server': server,
                   'share': share, 'mount_point': mntpt,
                   'mount_options': mntopts})

        mock_nfsmount.assert_called_once_with(server, share, mntpt, mntopts)
        mock_make_persist.assert_called_once_with(server + ':' + share,
                                                  mntpt, mntopts)
コード例 #10
0
ファイル: test_filesystems.py プロジェクト: lcorreia/ginger
 def test_get_fs_list(self):
     fs = filesystem.FileSystemsModel()
     fs_list = fs.get_list()
     self.assertGreaterEqual(len(fs_list), 0)