Skip to content

Commit

Permalink
mgr/volumes: Update nfs cluster and export interface
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
varshar16 committed Apr 8, 2020
1 parent 34ba1cc commit a84d4b0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
10 changes: 6 additions & 4 deletions doc/cephfs/fs-nfs-exports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
====================================================
Expand Down
9 changes: 7 additions & 2 deletions src/pybind/mgr/volumes/fs/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ def _save_export(self, export):
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] = []
Expand Down Expand Up @@ -339,7 +341,10 @@ def create_empty_rados_obj(self):
"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

Expand Down
21 changes: 12 additions & 9 deletions src/pybind/mgr/volumes/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand All @@ -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'
},
Expand Down Expand Up @@ -403,14 +405,15 @@ def _cmd_fs_clone_cancel(self, inbuf, cmd):
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))
4 changes: 2 additions & 2 deletions src/vstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit a84d4b0

Please sign in to comment.