]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: convert _cmd_nfs_cluster_config_reset to EmptyResponder decorator
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 6 May 2022 13:59:02 +0000 (09:59 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 12 Jan 2023 18:44:11 +0000 (13:44 -0500)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/nfs/cluster.py
src/pybind/mgr/nfs/module.py

index c9ddffabb457c619a0534a88baf92aa2ff78386f..3a113c43f93f94990635eb3b0e3981c26cfbf116 100644 (file)
@@ -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."""
index 7e129591cf16be7b9b75a21131d4fc8f9be86658..d6505eb84742c96702db8a9492eeaff5754d9b43 100644 (file)
@@ -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)