From: Sage Weil Date: Mon, 7 Jun 2021 20:52:30 +0000 (-0400) Subject: mgr/nfs: handle option addr/client block in create_export() X-Git-Tag: v17.1.0~1551^2~30 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d6d9e59ef76f33f0f9611acfb6406d849b9e29a8;p=ceph.git mgr/nfs: handle option addr/client block in create_export() Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index 56bd2a698dd09..c369bcc38f4ed 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -269,7 +269,18 @@ class ExportMgr: return path @export_cluster_checker - def create_export(self, **kwargs: Any) -> Tuple[int, str, str]: + def create_export(self, addr: Optional[List[str]] = None, **kwargs: Any) -> Tuple[int, str, str]: + # if addr(s) are provided, construct client list and adjust outer block + clients = [] + if addr: + clients = [{ + 'addresses': addr, + 'access_type': 'ro' if kwargs['read_only'] else 'rw', + 'squash': kwargs['squash'], + }] + kwargs['squash'] = 'none' + kwargs['clients'] = clients + try: fsal_type = kwargs.pop('fsal_type') if fsal_type == 'cephfs': diff --git a/src/pybind/mgr/nfs/module.py b/src/pybind/mgr/nfs/module.py index c4cda93214a7d..4a84eda3670c7 100644 --- a/src/pybind/mgr/nfs/module.py +++ b/src/pybind/mgr/nfs/module.py @@ -36,18 +36,10 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): squash: str = 'none', ) -> Tuple[int, str, str]: """Create a cephfs export""" - clients = [] - if addr: - clients = [{ - 'addresses': addr, - 'access_type': 'ro' if readonly else 'rw', - 'squash': squash, - }] - squash = 'none' return self.export_mgr.create_export(fsal_type='cephfs', fs_name=fsname, cluster_id=cluster_id, pseudo_path=binding, read_only=readonly, path=path, - squash=squash, clients=clients) + squash=squash, addr=addr) @CLICommand('nfs export create rgw', perm='rw') def _cmd_rgw_export_create_cephfs( @@ -60,20 +52,11 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): realm: Optional[str] = None, ) -> Tuple[int, str, str]: """Create an RGW export""" - clients = [] - squash = 'none' - if addr: - clients = [{ - 'addresses': addr, - 'access_type': 'ro' if readonly else 'rw', - 'squash': squash, - }] - squash = 'none' return self.export_mgr.create_export(fsal_type='rgw', bucket=bucket, realm=realm, cluster_id=cluster_id, pseudo_path=binding, - read_only=readonly, squash=squash, - clients=clients) + read_only=readonly, squash='none', + addr=addr) @CLICommand('nfs export import', perm='rw') def _cmd_nfs_export_import(self,