]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: add --addr to 'nfs export create'
authorSage Weil <sage@newdream.net>
Wed, 26 May 2021 18:37:34 +0000 (14:37 -0400)
committerSebastian Wagner <sewagner@redhat.com>
Thu, 9 Sep 2021 14:17:45 +0000 (16:17 +0200)
Ganesha exports can have multiple client blocks with addresses and
access modes/squash behavior.  This cannot easily be exposed via a CLI.
However, providing no client address restriction is pretty useful to users
since it allows full access to the mount point with no restrictions.

Add an --addr argument that creates a single client block.  Set the top
export-level access_type to 'none' and squash to 'none' in this case.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 137090dac07f95c3af0b09afc19da210b085019b)

src/pybind/mgr/nfs/export.py
src/pybind/mgr/nfs/module.py

index cc8c8c657bc0e8ada1af6904ffc5f4acab48f96c..4469389ab61b1688e23e3ec748613c937eaecc31 100644 (file)
@@ -430,7 +430,8 @@ 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, squash):
+    def create_export(self, fs_name, cluster_id, pseudo_path, read_only, path, squash,
+                      clients=[]):
         if not check_fs(self.mgr, fs_name):
             raise FSNotFound(fs_name)
 
@@ -444,9 +445,12 @@ class FSExport(ExportMgr):
             ex_id = self._gen_export_id()
             user_id = f"{cluster_id}{ex_id}"
             user_out, key = self._create_user_key(user_id, path, fs_name, read_only)
-            access_type = "RW"
-            if read_only:
+            if clients:
+                access_type = "none"
+            elif read_only:
                 access_type = "RO"
+            else:
+                access_type = "RW"
             ex_dict = {
                 'path': self.format_path(path),
                 'pseudo': pseudo_path,
@@ -455,7 +459,7 @@ class FSExport(ExportMgr):
                 'squash': squash,
                 'fsal': {"name": "CEPH", "user_id": user_id,
                          "fs_name": fs_name, "sec_label_xattr": ""},
-                'clients': []
+                'clients': clients
             }
             export = Export.from_dict(ex_id, ex_dict)
             export.fsal.cephx_key = key
index 1a0abedef14d36be138676f8e14f5d1acb75e6bf..ebb95cd91ef35e7b40a59c1fc91ba62e9212a01e 100644 (file)
@@ -29,16 +29,25 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
             fsname: str,
             clusterid: str,
             binding: str,
-            path: str = '/',
-            readonly: bool = False,
+            path: Optional[str] = '/',
+            readonly: Optional[bool] = False,
+            addr: Optional[str] = None,
             squash: str = 'none',
     ) -> Tuple[int, str, str]:
         """Create a cephfs export"""
         # TODO Extend export creation for rgw.
+        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=clusterid, pseudo_path=binding,
                                              read_only=readonly, path=path,
-                                             squash=squash)
+                                             squash=squash, clients=clients)
 
     @CLICommand('nfs export rm', perm='rw')
     def _cmd_nfs_export_rm(self, clusterid: str, binding: str) -> Tuple[int, str, str]: