From: Avan Thakkar Date: Wed, 28 Aug 2024 14:30:10 +0000 (+0530) Subject: mgr/nfs: ensure user_id for create_export_from_dict X-Git-Tag: v20.0.0~1047^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d02b94d8200a681f14d868387d155f081400ef34;p=ceph.git mgr/nfs: ensure user_id for create_export_from_dict Signed-off-by: Avan Thakkar --- diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index a7e0576efe44..3ba75e60b5cf 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -77,8 +77,7 @@ def validate_cephfs_path(mgr: 'Module', fs_name: str, path: str) -> None: raise NFSException(e.args[1], -e.args[0]) -def _validate_cmount_path(mgr: 'Module', fs_name: str, cmount_path: str, path: str) -> None: - validate_cephfs_path(mgr, fs_name, cmount_path) +def _validate_cmount_path(cmount_path: str, path: str) -> None: if cmount_path not in path: raise ValueError( f"Invalid cmount_path: '{cmount_path}'. The path '{path}' is not within the mount path. " @@ -679,7 +678,7 @@ class ExportMgr: validate_cephfs_path(self.mgr, fs_name, path) if fsal["cmount_path"] != "/": - _validate_cmount_path(self.mgr, fsal["cmount_path"], path) # type: ignore + _validate_cmount_path(fsal["cmount_path"], path) # type: ignore user_id = f"nfs.{get_user_id(cluster_id, fs_name, fsal['cmount_path'])}" if "user_id" in fsal and fsal["user_id"] != user_id: @@ -691,6 +690,8 @@ class ExportMgr: ex_dict["fsal"] = fsal ex_dict["cluster_id"] = cluster_id export = Export.from_dict(ex_id, ex_dict) + if export.fsal.name == NFS_GANESHA_SUPPORTED_FSALS[0]: + self._ensure_cephfs_export_user(export) export.validate(self.mgr) log.debug("Successfully created %s export-%s from dict for cluster %s", fsal_type, ex_id, cluster_id) @@ -710,7 +711,7 @@ class ExportMgr: validate_cephfs_path(self.mgr, fs_name, path) if cmount_path != "/": - _validate_cmount_path(self.mgr, cmount_path, path) # type: ignore + _validate_cmount_path(cmount_path, path) # type: ignore pseudo_path = normalize_path(pseudo_path)