Beispiel #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
Beispiel #2
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)
Beispiel #3
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
Beispiel #4
0
 def test_daemon_conf_parser_a(self) -> None:
     blocks = GaneshaConfParser(self.conf_nodea).parse()
     assert isinstance(blocks, list)
     assert len(blocks) == 2
     assert blocks[0].block_name == "%url"
     assert blocks[0].values['value'] == "rados://ganesha/ns/export-2"
     assert blocks[1].block_name == "%url"
     assert blocks[1].values['value'] == "rados://ganesha/ns/export-1"
Beispiel #5
0
 def test_daemon_conf_parser(self) -> None:
     blocks = GaneshaConfParser(self.conf_nfs_foo).parse()
     assert isinstance(blocks, list)
     assert len(blocks) == 2
     assert blocks[0].block_name == "%url"
     assert blocks[0].values[
         'value'] == f"rados://{NFS_POOL_NAME}/{self.cluster_id}/export-1"
     assert blocks[1].block_name == "%url"
     assert blocks[1].values[
         'value'] == f"rados://{NFS_POOL_NAME}/{self.cluster_id}/export-2"
Beispiel #6
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)
Beispiel #7
0
    def test_parse_daemon_raw_config(self) -> None:
        expected_daemon_config = [
            RawBlock('NFS_CORE_PARAM',
                     values={
                         "enable_nlm": False,
                         "enable_rquota": False,
                         "protocols": 4,
                         "nfs_port": 14000
                     }),
            RawBlock('MDCACHE', values={"dir_chunk": 0}),
            RawBlock('NFSV4',
                     values={
                         "recoverybackend": "rados_cluster",
                         "minor_versions": [1, 2]
                     }),
            RawBlock('RADOS_KV',
                     values={
                         "pool": NFS_POOL_NAME,
                         "namespace": "vstart",
                         "userid": "vstart",
                         "nodeid": "a"
                     }),
            RawBlock('RADOS_URLS',
                     values={
                         "userid":
                         "vstart",
                         "watch_url":
                         f"'rados://{NFS_POOL_NAME}/vstart/conf-nfs.vstart'"
                     }),
            RawBlock('%url',
                     values={
                         "value":
                         f"rados://{NFS_POOL_NAME}/vstart/conf-nfs.vstart"
                     })
        ]
        daemon_raw_config = """
NFS_CORE_PARAM {
            Enable_NLM = false;
            Enable_RQUOTA = false;
            Protocols = 4;
            NFS_Port = 14000;
        }

        MDCACHE {
           Dir_Chunk = 0;
        }

        NFSv4 {
           RecoveryBackend = rados_cluster;
           Minor_Versions = 1, 2;
        }

        RADOS_KV {
           pool = {};
           namespace = vstart;
           UserId = vstart;
           nodeid = a;
        }

        RADOS_URLS {
       Userid = vstart;
       watch_url = 'rados://{}/vstart/conf-nfs.vstart';
        }

    %url rados://{}/vstart/conf-nfs.vstart
""".replace('{}', NFS_POOL_NAME)
        daemon_config = GaneshaConfParser(daemon_raw_config).parse()
        assert daemon_config == expected_daemon_config
Beispiel #8
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)