Commit a7881b3c authored by Julien Muchembled's avatar Julien Muchembled

neoctl: fix commands expecting an UUID

parent 86f64828
...@@ -18,7 +18,7 @@ from operator import itemgetter ...@@ -18,7 +18,7 @@ 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, \
ZERO_TID UUID_NAMESPACES, ZERO_TID
action_dict = { action_dict = {
'print': { 'print': {
...@@ -37,6 +37,10 @@ action_dict = { ...@@ -37,6 +37,10 @@ action_dict = {
'drop': 'dropNode', 'drop': 'dropNode',
} }
uuid_int = (lambda ns: lambda uuid:
(ns[uuid[0]] << 24) + int(uuid[1:])
)(dict((str(k)[0], v) for k, v in UUID_NAMESPACES.iteritems()))
class TerminalNeoCTL(object): class TerminalNeoCTL(object):
def __init__(self, address): def __init__(self, address):
self.neoctl = NeoCTL(address) self.neoctl = NeoCTL(address)
...@@ -54,8 +58,7 @@ class TerminalNeoCTL(object): ...@@ -54,8 +58,7 @@ class TerminalNeoCTL(object):
def asClusterState(self, value): def asClusterState(self, value):
return getattr(ClusterStates, value.upper()) return getattr(ClusterStates, value.upper())
def asNode(self, value): asNode = staticmethod(uuid_int)
return bin(value)
def formatRowList(self, row_list): def formatRowList(self, row_list):
return '\n'.join('%03d | %s' % (offset, return '\n'.join('%03d | %s' % (offset,
...@@ -201,7 +204,7 @@ class TerminalNeoCTL(object): ...@@ -201,7 +204,7 @@ class TerminalNeoCTL(object):
except StopIteration: except StopIteration:
pass pass
break break
source = bin(source) if source else None source = self.asNode(source) if source else None
if partition: if partition:
partition_dict[int(partition)] = source partition_dict[int(partition)] = source
else: else:
......
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