]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: convert _cmd_nfs_cluster_ls to use Responder decorator
authorJohn Mulligan <jmulligan@redhat.com>
Sat, 7 May 2022 14:29:33 +0000 (10:29 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 12 Jan 2023 18:44:10 +0000 (13:44 -0500)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/nfs/cluster.py
src/pybind/mgr/nfs/module.py
src/pybind/mgr/nfs/tests/test_nfs.py

index 2b640754afb1cb0dc966f958dd56693e761952aa..b14879dd408ca99168762c98a8ab6ccfce7bb21b 100644 (file)
@@ -7,6 +7,7 @@ from typing import cast, Dict, List, Any, Union, Optional, TYPE_CHECKING, Tuple
 
 from mgr_module import NFS_POOL_NAME as POOL_NAME
 from ceph.deployment.service_spec import NFSServiceSpec, PlacementSpec, IngressSpec
+from object_format import ErrorResponse
 
 import orchestrator
 
@@ -148,11 +149,12 @@ class NFSCluster:
         except Exception as e:
             return exception_handler(e, f"Failed to delete NFS Cluster {cluster_id}")
 
-    def list_nfs_cluster(self) -> Tuple[int, str, str]:
+    def list_nfs_cluster(self) -> List[str]:
         try:
-            return 0, '\n'.join(available_clusters(self.mgr)), ""
+            return available_clusters(self.mgr)
         except Exception as e:
-            return exception_handler(e, "Failed to list NFS Cluster")
+            log.exception("Failed to list NFS Cluster")
+            raise ErrorResponse.wrap(e)
 
     def _show_nfs_cluster_info(self, cluster_id: str) -> Dict[str, Any]:
         completion = self.mgr.list_daemons(daemon_type='nfs')
index 891cf47692c12449644785b0b31ae9ffeee120c6..036fd8a773f40dc183785ab388219a0f12b74bdb 100644 (file)
@@ -132,7 +132,8 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
         return self.nfs.delete_nfs_cluster(cluster_id=cluster_id)
 
     @CLICommand('nfs cluster ls', perm='r')
-    def _cmd_nfs_cluster_ls(self) -> Tuple[int, str, str]:
+    @object_format.Responder()
+    def _cmd_nfs_cluster_ls(self) -> List[str]:
         """List NFS Clusters"""
         return self.nfs.list_nfs_cluster()
 
index 6fdf6d1583b6e3bd533ed76723afca3adee2c023..494760cf57c8eb666b896141a6e0a31ad1c76a49 100644 (file)
@@ -1078,9 +1078,8 @@ NFS_CORE_PARAM {
         nfs_mod = Module('nfs', '', '')
         cluster = NFSCluster(nfs_mod)
 
-        rc, out, err = cluster.list_nfs_cluster()
-        assert rc == 0
-        assert out == self.cluster_id
+        out = cluster.list_nfs_cluster()
+        assert out[0] == self.cluster_id
 
     def test_cluster_ls(self):
         self._do_mock_test(self._do_test_cluster_ls)