]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: handle exceptions for cephfs_path_is_dir()
authorDhairya Parmar <dparmar@redhat.com>
Tue, 11 Apr 2023 10:09:00 +0000 (15:39 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Wed, 26 Apr 2023 10:20:18 +0000 (15:50 +0530)
in create_cephfs_export()

Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
src/pybind/mgr/nfs/export.py

index 935b12464e7b70336a847691f0d7ad2aab518aaa..5887c898fef9e08c6df12e539bde90ca643993a7 100644 (file)
@@ -12,6 +12,7 @@ from typing import (
     Set,
     cast)
 from os.path import normpath
+import cephfs
 
 from rados import TimedOut, ObjectNotFound, Rados, LIBRADOS_ALL_NSPACES
 
@@ -26,7 +27,7 @@ from .ganesha_conf import (
     RGWFSAL,
     RawBlock,
     format_block)
-from .exception import NFSException, NFSInvalidOperation, FSNotFound
+from .exception import NFSException, NFSInvalidOperation, FSNotFound, NFSObjectNotFound
 from .utils import (
     CONF_PREFIX,
     EXPORT_PREFIX,
@@ -36,7 +37,7 @@ from .utils import (
     conf_obj_name,
     available_clusters,
     check_fs,
-    restart_nfs_service, check_cephfs_path)
+    restart_nfs_service, cephfs_path_is_dir)
 
 if TYPE_CHECKING:
     from nfs.module import Module
@@ -659,7 +660,14 @@ class ExportMgr:
                              clients: list = [],
                              sectype: Optional[List[str]] = None) -> Dict[str, Any]:
 
-        check_cephfs_path(self.mgr, fs_name, path)
+        try:
+            cephfs_path_is_dir(self.mgr, fs_name, path)
+        except NotADirectoryError:
+            raise NFSException(f"path {path} is not a dir", -errno.ENOTDIR)
+        except cephfs.ObjectNotFound:
+            raise NFSObjectNotFound(f"path {path} does not exist")
+        except cephfs.Error as e:
+            raise NFSException(e.args[1], -e.args[0])
 
         pseudo_path = normalize_path(pseudo_path)