Skip to content

Commit cc7b69f

Browse files
committed
mgr/nfs: add a helper to validate cephfs path
Fixes: https://tracker.ceph.com/issues/62077 Signed-off-by: Dhairya Parmar <[email protected]>
1 parent 774ce9f commit cc7b69f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/pybind/mgr/nfs/export.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ def normalize_path(path: str) -> str:
7171
return path
7272

7373

74+
def validate_cephfs_path(mgr: 'Module', fs_name: str, path: str) -> None:
75+
try:
76+
cephfs_path_is_dir(mgr, fs_name, path)
77+
except NotADirectoryError:
78+
raise NFSException(f"path {path} is not a dir", -errno.ENOTDIR)
79+
except cephfs.ObjectNotFound:
80+
raise NFSObjectNotFound(f"path {path} does not exist")
81+
except cephfs.Error as e:
82+
raise NFSException(e.args[1], -e.args[0])
83+
84+
7485
class NFSRados:
7586
def __init__(self, rados: 'Rados', namespace: str) -> None:
7687
self.rados = rados

0 commit comments

Comments
 (0)