mirror of
https://github.com/ceph/ceph
synced 2025-01-01 08:32:24 +00:00
mgr/nfs: convert _cmd_nfs_cluster_ls to use Responder decorator
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
fdac9f71e4
commit
b53ffbf865
@ -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')
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user