Esempio n. 1
0
 def test_export_from_to_dict(self, block):
     blocks = GaneshaConfParser(block).parse()
     export = Export.from_export_block(blocks[0], self.cluster_id)
     j = export.to_dict()
     export2 = Export.from_dict(j['export_id'], j)
     j2 = export2.to_dict()
     assert j == j2
Esempio n. 2
0
 def test_export_from_to_export_block(self, block):
     blocks = GaneshaConfParser(block).parse()
     export = Export.from_export_block(blocks[0], self.cluster_id)
     newblock = export.to_export_block()
     export2 = Export.from_export_block(newblock, self.cluster_id)
     newblock2 = export2.to_export_block()
     assert newblock == newblock2
Esempio n. 3
0
 def test_export_validate(self, block):
     cluster_id = 'foo'
     blocks = GaneshaConfParser(block).parse()
     export = Export.from_export_block(blocks[0], cluster_id)
     nfs_mod = Module('nfs', '', '')
     with mock.patch('nfs.export_utils.check_fs', return_value=True):
         export.validate(nfs_mod)
Esempio n. 4
0
    def _do_test_config_from_dict(self) -> None:
        export = Export.from_dict(
            1, {
                'export_id':
                1,
                'path':
                '/',
                'cluster_id':
                self.cluster_id,
                'pseudo':
                '/cephfs_a',
                'access_type':
                'RW',
                'squash':
                'root_squash',
                'security_label':
                True,
                'protocols': [4],
                'transports': ['TCP', 'UDP'],
                'clients': [{
                    'addresses': ["192.168.0.10", "192.168.1.0/8"],
                    'access_type': None,
                    'squash': 'no_root_squash'
                }, {
                    'addresses': ["192.168.0.0/16"],
                    'access_type': 'RO',
                    'squash': 'all_squash'
                }],
                'fsal': {
                    'name': 'CEPH',
                    'user_id': 'ganesha',
                    'fs_name': 'a',
                    'sec_label_xattr': 'security.selinux'
                }
            })

        assert export.export_id == 1
        assert export.path == "/"
        assert export.pseudo == "/cephfs_a"
        assert export.access_type == "RW"
        assert export.squash == "root_squash"
        assert set(export.protocols) == {4}
        assert set(export.transports) == {"TCP", "UDP"}
        assert export.fsal.name == "CEPH"
        assert export.fsal.user_id == "ganesha"
        assert export.fsal.fs_name == "a"
        assert export.fsal.sec_label_xattr == 'security.selinux'
        assert len(export.clients) == 2
        assert export.clients[0].addresses == \
            ["192.168.0.10", "192.168.1.0/8"]
        assert export.clients[0].squash == "no_root_squash"
        assert export.clients[0].access_type is None
        assert export.clients[1].addresses == ["192.168.0.0/16"]
        assert export.clients[1].squash == "all_squash"
        assert export.clients[1].access_type == "RO"
        assert export.cluster_id == self.cluster_id
        assert export.attr_expiration_time == 0
        assert export.security_label

        export = Export.from_dict(
            2, {
                'export_id': 2,
                'path': 'bucket',
                'pseudo': '/rgw',
                'cluster_id': self.cluster_id,
                'access_type': 'RW',
                'squash': 'all_squash',
                'security_label': False,
                'protocols': [4, 3],
                'transports': ['TCP', 'UDP'],
                'clients': [],
                'fsal': {
                    'name': 'RGW',
                    'rgw_user_id': 'rgw.foo.bucket'
                }
            })

        assert export.export_id == 2
        assert export.path == "bucket"
        assert export.pseudo == "/rgw"
        assert export.access_type == "RW"
        assert export.squash == "all_squash"
        assert set(export.protocols) == {4, 3}
        assert set(export.transports) == {"TCP", "UDP"}
        assert export.fsal.name == "RGW"
        #        assert export.fsal.rgw_user_id == "testuser"
        #        assert export.fsal.access_key is None
        #        assert export.fsal.secret_key is None
        assert len(export.clients) == 0
        assert export.cluster_id == self.cluster_id
Esempio n. 5
0
 def test_export_parser_2(self) -> None:
     blocks = GaneshaConfParser(self.export_2).parse()
     assert isinstance(blocks, list)
     assert len(blocks) == 1
     export = Export.from_export_block(blocks[0], self.cluster_id)
     self._validate_export_2(export)
Esempio n. 6
0
 def test_export_parser_1(self) -> None:
     blocks = GaneshaConfParser(self.export_1).parse()
     assert isinstance(blocks, list)
     assert len(blocks) == 1
     export = Export.from_export_block(blocks[0], '_default_')
     self._validate_export_1(export)