From ea783268522fd8d4b7e293023ea447a6e5f1145e Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 5 May 2022 15:48:59 -0400 Subject: [PATCH] mgr/nfs: convert _cmd_nfs_cluster_rm to use EmptyResponder decorator Signed-off-by: John Mulligan --- src/pybind/mgr/nfs/cluster.py | 9 +++++---- src/pybind/mgr/nfs/export.py | 3 ++- src/pybind/mgr/nfs/module.py | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/nfs/cluster.py b/src/pybind/mgr/nfs/cluster.py index 0c072c7b31d..9a65158c0f1 100644 --- a/src/pybind/mgr/nfs/cluster.py +++ b/src/pybind/mgr/nfs/cluster.py @@ -137,7 +137,7 @@ class NFSCluster: log.exception(f"NFS Cluster {cluster_id} could not be created") raise ErrorResponse.wrap(e) - def delete_nfs_cluster(self, cluster_id: str) -> Tuple[int, str, str]: + def delete_nfs_cluster(self, cluster_id: str) -> None: try: cluster_list = available_clusters(self.mgr) if cluster_id in cluster_list: @@ -147,10 +147,11 @@ class NFSCluster: completion = self.mgr.remove_service('nfs.' + cluster_id) orchestrator.raise_if_exception(completion) self.delete_config_obj(cluster_id) - return 0, "", "" - return 0, "", "Cluster does not exist" + return + raise NonFatalError("Cluster does not exist") except Exception as e: - return exception_handler(e, f"Failed to delete NFS Cluster {cluster_id}") + log.exception(f"Failed to delete NFS Cluster {cluster_id}") + raise ErrorResponse.wrap(e) def list_nfs_cluster(self) -> List[str]: try: diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index a040b94018f..652171af8a3 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -411,7 +411,8 @@ class ExportMgr: return self.create_rgw_export(**kwargs) raise NotImplementedError() except Exception as e: - log.exception(f"Failed to create {kwargs['pseudo_path']} export for {kwargs['cluster_id']}") + log.exception( + f"Failed to create {kwargs['pseudo_path']} export for {kwargs['cluster_id']}") raise ErrorResponse.wrap(e) def delete_export(self, diff --git a/src/pybind/mgr/nfs/module.py b/src/pybind/mgr/nfs/module.py index 1be52f9512a..ec0cd83dd93 100644 --- a/src/pybind/mgr/nfs/module.py +++ b/src/pybind/mgr/nfs/module.py @@ -127,12 +127,14 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): port=port) @CLICommand('nfs cluster rm', perm='rw') - def _cmd_nfs_cluster_rm(self, cluster_id: str) -> Tuple[int, str, str]: + @object_format.EmptyResponder() + def _cmd_nfs_cluster_rm(self, cluster_id: str) -> None: """Removes an NFS Cluster""" return self.nfs.delete_nfs_cluster(cluster_id=cluster_id) @CLICommand('nfs cluster delete', perm='rw') - def _cmd_nfs_cluster_delete(self, cluster_id: str) -> Tuple[int, str, str]: + @object_format.EmptyResponder() + def _cmd_nfs_cluster_delete(self, cluster_id: str) -> None: """Removes an NFS Cluster (DEPRECATED)""" return self.nfs.delete_nfs_cluster(cluster_id=cluster_id) -- 2.39.5