]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: Update nfs cluster and export interface
authorVarsha Rao <varao@redhat.com>
Wed, 1 Apr 2020 16:01:26 +0000 (21:31 +0530)
committerVarsha Rao <varao@redhat.com>
Wed, 8 Apr 2020 11:51:17 +0000 (17:21 +0530)
Instead of prefixing 'fs' to the commands, type is added for easy extension to
create rgw exports.

$ ceph nfs cluster create <type=cephfs> [--size=1] <clusterid>
$ ceph nfs export create <type=cephfs> <fsname> <binding> [--readonly] [--path=/path/in/cephfs] [--attach=<clusterid>]

Signed-off-by: Varsha Rao <varao@redhat.com>
doc/cephfs/fs-nfs-exports.rst
src/pybind/mgr/volumes/fs/nfs.py
src/pybind/mgr/volumes/module.py
src/vstart.sh

index fa8bb8403c4e43afb29f4dbaeb4999a90402a636..aa9f69de0f90405d670c4ec248713622a7db8e19 100644 (file)
@@ -17,12 +17,13 @@ Create NFS Ganesha Cluster
 
 .. code:: bash
 
-    $ ceph fs nfs cluster create [--size=1] <cluster_id>
+    $ ceph nfs cluster create <type=cephfs> [--size=1] <clusterid>
 
 This creates a common recovery pool for all Ganesha daemons, new user based on
 cluster_id and common ganesha config rados object.
 
-Here size denotes the number of ganesha daemons within a cluster.
+Here size denotes the number of ganesha daemons within a cluster and type is
+export type. Currently only CephFS is supported.
 
 .. note:: This does not setup ganesha recovery database and start the daemons.
           It needs to be done manually if not using vstart for creating
@@ -34,10 +35,11 @@ Create CephFS Export
 
 .. code:: bash
 
-    $ ceph fs nfs export create <fsname> <binding> [--readonly] [--path=/path/in/cephfs] [--attach=<cluster_id>]
+    $ ceph nfs export create <type=cephfs> <fsname> <binding> [--readonly] [--path=/path/in/cephfs] [--attach=<clusterid>]
 
 It creates export rados objects containing the export block. Here binding is
-the pseudo root name.
+the pseudo root name and type is export type. Currently only CephFS is
+supported.
 
 Configuring NFS-Ganesha to export CephFS with vstart
 ====================================================
index a6740b83503c5abe852f2cd651560ec2f97f0c6b..b7e19f4b8822ec0b48ef3ff71da920e8193cfc30 100644 (file)
@@ -273,7 +273,9 @@ class FSExport(object):
         self._write_raw_config(conf_block, "export-{}".format(export.export_id))
         self._update_common_conf(export.export_id)
 
-    def create_export(self, fs_name, pseudo_path, read_only, path, cluster_id):
+    def create_export(self, export_type, fs_name, pseudo_path, read_only, path, cluster_id):
+        if export_type != 'cephfs':
+            return -errno.EINVAL,"", f"Invalid export type: {export_type}"
         #TODO Check if valid cluster
         if cluster_id not in self.exports:
             self.exports[cluster_id] = []
@@ -339,7 +341,10 @@ class NFSCluster:
                     "write configuration into rados object %s/%s/nfs-conf\n",
                     self.pool_name, self.pool_ns)
 
-    def create_nfs_cluster(self, size):
+    def create_nfs_cluster(self, export_type, size):
+        if export_type != 'cephfs':
+            return -errno.EINVAL,"", f"Invalid export type: {export_type}"
+
         pool_list = [p['pool_name'] for p in self.mgr.get_osdmap().dump().get('pools', [])]
         client = 'client.%s' % self.cluster_id
 
index 75cbaf44ceecc734a25b324936e363bc785316ef..a5cbe960f7dc97e99798a4586214e6815545616e 100644 (file)
@@ -216,7 +216,8 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
             'perm': 'r'
         },
         {
-            'cmd': 'fs nfs export create '
+            'cmd': 'nfs export create '
+            'name=type,type=CephString '
             'name=fsname,type=CephString '
             'name=binding,type=CephString '
             'name=readonly,type=CephBool,req=false '
@@ -232,9 +233,10 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
             'perm': 'rw'
         },
         {
-            'cmd': 'fs nfs cluster create '
-                   'name=size,type=CephInt,req=false '
-                   'name=cluster_id,type=CephString ',
+            'cmd': 'nfs cluster create '
+                   'name=type,type=CephString '
+                   'name=clusterid,type=CephString '
+                   'name=size,type=CephInt,req=false ',
             'desc': "Create an NFS Cluster",
             'perm': 'rw'
         },
@@ -403,14 +405,15 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
         return self.vc.clone_cancel(
             vol_name=cmd['vol_name'], clone_name=cmd['clone_name'],  group_name=cmd.get('group_name', None))
 
-    def _cmd_fs_nfs_export_create(self, inbuf, cmd):
-        return self.fs_export.create_export(fs_name=cmd['fsname'],
+    def _cmd_nfs_export_create(self, inbuf, cmd):
+        #TODO Extend export creation for rgw.
+        return self.fs_export.create_export(export_type=cmd['type'], fs_name=cmd['fsname'],
                 pseudo_path=cmd['binding'], read_only=cmd.get('readonly', False),
                 path=cmd.get('path', '/'), cluster_id=cmd.get('attach','None'))
 
     def _cmd_fs_nfs_export_delete(self, inbuf, cmd):
             return self.fs_export.delete_export(cmd['export_id'])
 
-    def _cmd_fs_nfs_cluster_create(self, inbuf, cmd):
-            nfs_cluster_obj = NFSCluster(self, cmd['cluster_id'])
-            return nfs_cluster_obj.create_nfs_cluster(size=cmd.get('size', 1))
+    def _cmd_nfs_cluster_create(self, inbuf, cmd):
+            nfs_cluster_obj = NFSCluster(self, cmd['clusterid'])
+            return nfs_cluster_obj.create_nfs_cluster(export_type=cmd['type'], size=cmd.get('size', 1))
index ffef573b51ee33df143aa684f9a7814c052a0fe4..11db9555cd817e2267ee0c52f48af815ea711b5e 100755 (executable)
@@ -1095,7 +1095,7 @@ start_ganesha() {
             osd "allow rw pool=$pool_name namespace=$namespace, allow rw tag cephfs data=a" \
             mds "allow rw path=/" \
             >> "$keyring_fn"
-        prun ceph_adm fs nfs cluster create $name
+        prun ceph_adm nfs cluster create cephfs $name
 
         echo "NFS_CORE_PARAM {
             Enable_NLM = false;
@@ -1136,7 +1136,7 @@ start_ganesha() {
         pid file = $ganesha_dir/ganesha.pid
 EOF
 
-        prun ceph_adm fs nfs export create "a" "/cephfs" --attach=$name
+        prun ceph_adm nfs export create cephfs "a" "/cephfs" --attach=$name
         prun ganesha-rados-grace -p $pool_name -n $namespace add $name
         prun ganesha-rados-grace -p $pool_name -n $namespace