From: John Mulligan Date: Fri, 6 May 2022 13:59:02 +0000 (-0400) Subject: mgr/nfs: convert _cmd_nfs_cluster_config_reset to EmptyResponder decorator X-Git-Tag: v18.1.0~491^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=40d36a98b51a8f986fa67d8d385fbee5849e6fdb;p=ceph.git mgr/nfs: convert _cmd_nfs_cluster_config_reset to EmptyResponder decorator Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/nfs/cluster.py b/src/pybind/mgr/nfs/cluster.py index c9ddffabb457..3a113c43f93f 100644 --- a/src/pybind/mgr/nfs/cluster.py +++ b/src/pybind/mgr/nfs/cluster.py @@ -255,22 +255,22 @@ class NFSCluster: log.exception(f"Setting NFS-Ganesha Config failed for {cluster_id}") raise ErrorResponse.wrap(e) - def reset_nfs_cluster_config(self, cluster_id: str) -> Tuple[int, str, str]: + def reset_nfs_cluster_config(self, cluster_id: str) -> None: try: if cluster_id in available_clusters(self.mgr): rados_obj = self._rados(cluster_id) if not rados_obj.check_user_config(): - return 0, "", "NFS-Ganesha User Config does not exist" + raise NonFatalError("NFS-Ganesha User Config does not exist") rados_obj.remove_obj(user_conf_obj_name(cluster_id), conf_obj_name(cluster_id)) restart_nfs_service(self.mgr, cluster_id) - return 0, "NFS-Ganesha Config Reset Successfully", "" + return raise ClusterNotFound() except NotImplementedError: - return 0, "NFS-Ganesha Config Removed Successfully "\ - "(Manual Restart of NFS PODS required)", "" + raise ManualRestartRequired("NFS-Ganesha Config Removed Successfully") except Exception as e: - return exception_handler(e, f"Resetting NFS-Ganesha Config failed for {cluster_id}") + log.exception(f"Resetting NFS-Ganesha Config failed for {cluster_id}") + raise ErrorResponse.wrap(e) def _rados(self, cluster_id: str) -> NFSRados: """Return a new NFSRados object for the given cluster id.""" diff --git a/src/pybind/mgr/nfs/module.py b/src/pybind/mgr/nfs/module.py index 7e129591cf16..d6505eb84742 100644 --- a/src/pybind/mgr/nfs/module.py +++ b/src/pybind/mgr/nfs/module.py @@ -164,7 +164,8 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): return self.nfs.set_nfs_cluster_config(cluster_id=cluster_id, nfs_config=inbuf) @CLICommand('nfs cluster config reset', perm='rw') - def _cmd_nfs_cluster_config_reset(self, cluster_id: str) -> Tuple[int, str, str]: + @object_format.EmptyResponder() + def _cmd_nfs_cluster_config_reset(self, cluster_id: str) -> None: """Reset NFS-Ganesha Config to default""" return self.nfs.reset_nfs_cluster_config(cluster_id=cluster_id)