mgr/volumes/nfs: get export in a nfs cluster

Fixes: https://tracker.ceph.com/issues/45741
Signed-off-by: Ramana Raja <rraja@redhat.com>
This commit is contained in:
Ramana Raja 2020-06-05 16:08:14 +05:30 committed by Varsha Rao
parent 6f8d20f2cb
commit 7dcefb158d
2 changed files with 23 additions and 0 deletions

View File

@ -560,6 +560,19 @@ class FSExport(object):
return 0, json.dumps(result, indent=2), ''
def get_export(self, cluster_id, pseudo_path):
if not f"ganesha-{cluster_id}" in available_clusters(self.mgr):
return -errno.ENOENT, "", f"NFS cluster '{cluster_id}' not found"
export_dict = {}
for export in self.exports[cluster_id]:
if export.pseudo == pseudo_path:
export_dict = export.to_dict()
break
if not export_dict:
return (-errno.ENOENT, "",
f"export with pseudo path '{pseudo_path}' not found in NFS cluster '{cluster_id}'")
return 0, json.dumps(export_dict, indent=2), ''
def make_rados_url(self, obj):
if self.rados_namespace:
return "rados://{}/{}/{}".format(self.rados_pool, self.rados_namespace, obj)

View File

@ -277,6 +277,13 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
'desc': "List exports of a NFS cluster",
'perm': 'r'
},
{
'cmd': 'nfs export get '
'name=clusterid,type=CephString '
'name=binding,type=CephString ',
'desc': "Fetch a export of a NFS cluster given the pseudo path/binding",
'perm': 'r'
},
{
'cmd': 'nfs cluster create '
'name=type,type=CephString '
@ -498,6 +505,9 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
def _cmd_nfs_export_ls(self, inbuf, cmd):
return self.fs_export.list_exports(cluster_id=cmd['clusterid'], detailed=cmd.get('detailed', False))
def _cmd_nfs_export_get(self, inbuf, cmd):
return self.fs_export.get_export(cluster_id=cmd['clusterid'], pseudo_path=cmd['binding'])
def _cmd_nfs_cluster_create(self, inbuf, cmd):
return self.nfs.create_nfs_cluster(cluster_id=cmd['clusterid'], export_type=cmd['type'],
placement=cmd.get('placement', None))