From 7dcefb158d2999715856ffa12cce9b92e6a12b23 Mon Sep 17 00:00:00 2001 From: Ramana Raja Date: Fri, 5 Jun 2020 16:08:14 +0530 Subject: [PATCH] mgr/volumes/nfs: get export in a nfs cluster Fixes: https://tracker.ceph.com/issues/45741 Signed-off-by: Ramana Raja --- src/pybind/mgr/volumes/fs/nfs.py | 13 +++++++++++++ src/pybind/mgr/volumes/module.py | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/pybind/mgr/volumes/fs/nfs.py b/src/pybind/mgr/volumes/fs/nfs.py index 8e973028703..f32b30a5452 100644 --- a/src/pybind/mgr/volumes/fs/nfs.py +++ b/src/pybind/mgr/volumes/fs/nfs.py @@ -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) diff --git a/src/pybind/mgr/volumes/module.py b/src/pybind/mgr/volumes/module.py index 2c106bda542..93ad6e1423b 100644 --- a/src/pybind/mgr/volumes/module.py +++ b/src/pybind/mgr/volumes/module.py @@ -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))