From db2734a50fd3babd43892af0437edbe9a8130c99 Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Thu, 23 Apr 2020 21:16:16 +0530 Subject: [PATCH] mgr/volumes: Add nfs cluster delete interface $ ceph nfs cluster delete This deletes the deployed cluster. Signed-off-by: Varsha Rao --- doc/cephfs/fs-nfs-exports.rst | 9 +++++++++ src/pybind/mgr/volumes/fs/nfs.py | 13 ++++++++++++- src/pybind/mgr/volumes/module.py | 11 +++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/doc/cephfs/fs-nfs-exports.rst b/doc/cephfs/fs-nfs-exports.rst index e92935223b9..82353fb622a 100644 --- a/doc/cephfs/fs-nfs-exports.rst +++ b/doc/cephfs/fs-nfs-exports.rst @@ -36,6 +36,15 @@ Update NFS Ganesha Cluster This updates the deployed cluster according to the placement value. +Delete NFS Ganesha Cluster +========================== + +.. code:: bash + + $ ceph nfs cluster delete + +This deletes the deployed cluster. + Create CephFS Export ==================== diff --git a/src/pybind/mgr/volumes/fs/nfs.py b/src/pybind/mgr/volumes/fs/nfs.py index d136362f965..12a802d2a96 100644 --- a/src/pybind/mgr/volumes/fs/nfs.py +++ b/src/pybind/mgr/volumes/fs/nfs.py @@ -396,4 +396,15 @@ class NFSCluster: return 0, "", "NFS Cluster Updated Successfully" def delete_nfs_cluster(self): - raise NotImplementedError() + if self.check_cluster_exists(): + try: + completion = self.mgr.remove_service('nfs.' + self.cluster_id) + self.mgr._orchestrator_wait([completion]) + orchestrator.raise_if_exception(completion) + except Exception as e: + log.exception("Failed to delete NFS Cluster") + return -errno.EINVAL, "", str(e) + else: + log.warn("Cluster does not exist") + + return 0, "", "NFS Cluster Deleted Successfully" diff --git a/src/pybind/mgr/volumes/module.py b/src/pybind/mgr/volumes/module.py index bae930dc910..ba9d11a9dd8 100644 --- a/src/pybind/mgr/volumes/module.py +++ b/src/pybind/mgr/volumes/module.py @@ -254,6 +254,12 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): 'desc': "Updates an NFS Cluster", 'perm': 'rw' }, + { + 'cmd': 'nfs cluster delete ' + 'name=clusterid,type=CephString ', + 'desc': "Deletes an NFS Cluster", + 'perm': 'rw' + }, # volume ls [recursive] # subvolume ls # volume authorize/deauthorize @@ -437,6 +443,11 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): nfs_cluster_obj = NFSCluster(self, cmd['clusterid']) return nfs_cluster_obj.create_nfs_cluster(export_type=cmd['type'], placement=cmd.get('placement', None)) + def _cmd_nfs_cluster_update(self, inbuf, cmd): nfs_cluster_obj = NFSCluster(self, cmd['clusterid']) return nfs_cluster_obj.update_nfs_cluster(placement=cmd['placement']) + + def _cmd_nfs_cluster_delete(self, inbuf, cmd): + nfs_cluster_obj = NFSCluster(self, cmd['clusterid']) + return nfs_cluster_obj.delete_nfs_cluster() -- 2.39.5