Пример #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
Пример #2
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