Commit 04922832 authored by Julien Muchembled's avatar Julien Muchembled

neoctl: improve output of 'print node'

parent 896900f1
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from operator import itemgetter
from .neoctl import NeoCTL, NotReadyException from .neoctl import NeoCTL, NotReadyException
from neo.lib.util import bin, p64 from neo.lib.util import bin, p64
from neo.lib.protocol import uuid_str, ClusterStates, NodeStates, NodeTypes, \ from neo.lib.protocol import uuid_str, ClusterStates, NodeStates, NodeTypes, \
...@@ -62,17 +63,14 @@ class TerminalNeoCTL(object): ...@@ -62,17 +63,14 @@ class TerminalNeoCTL(object):
for (uuid, state) in cell_list)) for (uuid, state) in cell_list))
for (offset, cell_list) in row_list) for (offset, cell_list) in row_list)
def formatNodeList(self, node_list): def formatNodeList(self, node_list, _sort_key=itemgetter(2, 0, 1)):
if not node_list: if not node_list:
return 'Empty list!' return 'Empty list!'
result = [] node_list.sort(key=_sort_key)
for node_type, address, uuid, state in node_list: return '\n'.join(
if address is None: '%s - %s - %s - %s' % (node_type, uuid_str(uuid),
address = (None, None) address and '%s:%s' % address, state)
ip, port = address for node_type, address, uuid, state in node_list)
result.append('%s - %s - %s:%s - %s' % (node_type, uuid_str(uuid),
ip, port, state))
return '\n'.join(result)
# Actual actions # Actual actions
def getPartitionRowList(self, params): def getPartitionRowList(self, params):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment