From b77c3eef7803c77f3596347dd1ca145e118e80b3 Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Thu, 11 Jun 2020 10:48:56 +0530 Subject: [PATCH] mgr/volumes/nfs: Add nfs cluster ls command This commands provides list of deployed nfs clusters. Fixes: https://tracker.ceph.com/issues/45742 Signed-off-by: Varsha Rao --- doc/cephfs/fs-nfs-exports.rst | 9 +++++++++ src/pybind/mgr/volumes/fs/nfs.py | 7 +++++++ src/pybind/mgr/volumes/module.py | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/doc/cephfs/fs-nfs-exports.rst b/doc/cephfs/fs-nfs-exports.rst index 5776d77f166..ae1744da180 100644 --- a/doc/cephfs/fs-nfs-exports.rst +++ b/doc/cephfs/fs-nfs-exports.rst @@ -45,6 +45,15 @@ Delete NFS Ganesha Cluster This deletes the deployed cluster. +List NFS Ganesha Cluster +======================== + +.. code:: bash + + $ ceph nfs cluster ls + +This lists deployed clusters. + Create CephFS Export ==================== diff --git a/src/pybind/mgr/volumes/fs/nfs.py b/src/pybind/mgr/volumes/fs/nfs.py index 89d2edff48b..c58dfe0480f 100644 --- a/src/pybind/mgr/volumes/fs/nfs.py +++ b/src/pybind/mgr/volumes/fs/nfs.py @@ -683,3 +683,10 @@ class NFSCluster: except Exception as e: log.warning("Failed to delete NFS Cluster") return -errno.EINVAL, "", str(e) + + def list_nfs_cluster(self): + try: + return 0, '\n'.join(available_clusters(self.mgr)), "" + except Exception as e: + log.warning("Failed to list NFS Cluster") + return -errno.EINVAL, "", str(e) diff --git a/src/pybind/mgr/volumes/module.py b/src/pybind/mgr/volumes/module.py index 93ad6e1423b..7fb465fbd8e 100644 --- a/src/pybind/mgr/volumes/module.py +++ b/src/pybind/mgr/volumes/module.py @@ -305,6 +305,11 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): 'desc': "Deletes an NFS Cluster", 'perm': 'rw' }, + { + 'cmd': 'nfs cluster ls ', + 'desc': "List NFS Clusters", + 'perm': 'r' + }, # volume ls [recursive] # subvolume ls # volume authorize/deauthorize @@ -517,3 +522,6 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): def _cmd_nfs_cluster_delete(self, inbuf, cmd): return self.nfs.delete_nfs_cluster(cluster_id=cmd['clusterid']) + + def _cmd_nfs_cluster_ls(self, inbuf, cmd): + return self.nfs.list_nfs_cluster()