From 2450447b45110ea98237618eda777e4e9285c6bd Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 26 May 2021 13:59:18 -0400 Subject: [PATCH] mgr/nfs: add --squash to 'nfs export create' Signed-off-by: Sage Weil --- src/pybind/mgr/nfs/export.py | 31 ++++++++++++++++--------------- src/pybind/mgr/nfs/module.py | 18 +++++++++++------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index 6db66ed798b9e..cc8c8c657bc0e 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -430,7 +430,7 @@ class FSExport(ExportMgr): log.info("Export user created is {}".format(json_res[0]['entity'])) return json_res[0]['entity'], json_res[0]['key'] - def create_export(self, fs_name, cluster_id, pseudo_path, read_only, path): + def create_export(self, fs_name, cluster_id, pseudo_path, read_only, path, squash): if not check_fs(self.mgr, fs_name): raise FSNotFound(fs_name) @@ -448,24 +448,25 @@ class FSExport(ExportMgr): if read_only: access_type = "RO" ex_dict = { - 'path': self.format_path(path), - 'pseudo': pseudo_path, - 'cluster_id': cluster_id, - 'access_type': access_type, - 'fsal': {"name": "CEPH", "user_id": user_id, - "fs_name": fs_name, "sec_label_xattr": ""}, - 'clients': [] - } + 'path': self.format_path(path), + 'pseudo': pseudo_path, + 'cluster_id': cluster_id, + 'access_type': access_type, + 'squash': squash, + 'fsal': {"name": "CEPH", "user_id": user_id, + "fs_name": fs_name, "sec_label_xattr": ""}, + 'clients': [] + } export = Export.from_dict(ex_id, ex_dict) export.fsal.cephx_key = key self._save_export(export) result = { - "bind": pseudo_path, - "fs": fs_name, - "path": path, - "cluster": cluster_id, - "mode": access_type, - } + "bind": pseudo_path, + "fs": fs_name, + "path": path, + "cluster": cluster_id, + "mode": access_type, + } return (0, json.dumps(result, indent=4), '') return 0, "", "Export already exists" diff --git a/src/pybind/mgr/nfs/module.py b/src/pybind/mgr/nfs/module.py index 0ebb92e968b21..1a0abedef14d3 100644 --- a/src/pybind/mgr/nfs/module.py +++ b/src/pybind/mgr/nfs/module.py @@ -24,17 +24,21 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): self.inited = True @CLICommand('nfs export create cephfs', perm='rw') - def _cmd_nfs_export_create_cephfs(self, - fsname: str, - clusterid: str, - binding: str, - path: str = '/', - readonly: bool = False) -> Tuple[int, str, str]: + def _cmd_nfs_export_create_cephfs( + self, + fsname: str, + clusterid: str, + binding: str, + path: str = '/', + readonly: bool = False, + squash: str = 'none', + ) -> Tuple[int, str, str]: """Create a cephfs export""" # TODO Extend export creation for rgw. return self.export_mgr.create_export(fsal_type='cephfs', fs_name=fsname, cluster_id=clusterid, pseudo_path=binding, - read_only=readonly, path=path) + read_only=readonly, path=path, + squash=squash) @CLICommand('nfs export rm', perm='rw') def _cmd_nfs_export_rm(self, clusterid: str, binding: str) -> Tuple[int, str, str]: -- 2.39.5