import ipaddress
import logging
-import json
import re
import socket
from typing import cast, Dict, List, Any, Union, Optional, TYPE_CHECKING, Tuple
log.debug("Successfully fetched %s info: %s", cluster_id, r)
return r
- def show_nfs_cluster_info(self, cluster_id: Optional[str] = None) -> Tuple[int, str, str]:
+ def show_nfs_cluster_info(self, cluster_id: Optional[str] = None) -> Dict[str, Any]:
try:
if cluster_id and cluster_id not in available_clusters(self.mgr):
raise ClusterNotFound()
res = self._show_nfs_cluster_info(cluster_id)
if res:
info_res[cluster_id] = res
- return (0, json.dumps(info_res, indent=4), '')
+ return info_res
except Exception as e:
- return exception_handler(e, "Failed to show info for cluster")
+ log.exception("Failed to show info for cluster")
+ raise ErrorResponse.wrap(e)
def get_nfs_cluster_config(self, cluster_id: str) -> Tuple[int, str, str]:
try:
return self.nfs.list_nfs_cluster()
@CLICommand('nfs cluster info', perm='r')
- def _cmd_nfs_cluster_info(self, cluster_id: Optional[str] = None) -> Tuple[int, str, str]:
+ @object_format.Responder()
+ def _cmd_nfs_cluster_info(self, cluster_id: Optional[str] = None) -> Dict[str, Any]:
"""Displays NFS Cluster info"""
return self.nfs.show_nfs_cluster_info(cluster_id=cluster_id)
nfs_mod = Module('nfs', '', '')
cluster = NFSCluster(nfs_mod)
- rc, out, err = cluster.show_nfs_cluster_info(self.cluster_id)
- assert rc == 0
- assert json.loads(out) == {"foo": {"virtual_ip": None, "backend": []}}
+ out = cluster.show_nfs_cluster_info(self.cluster_id)
+ assert out == {"foo": {"virtual_ip": None, "backend": []}}
def test_cluster_info(self):
self._do_mock_test(self._do_test_cluster_info)