Commit 3b5272b3 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Fix informations displayed by neoctl tool.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1939 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 00addec6
...@@ -61,6 +61,8 @@ class TerminalNeoCTL(object): ...@@ -61,6 +61,8 @@ class TerminalNeoCTL(object):
for (offset, cell_list) in row_list) for (offset, cell_list) in row_list)
def formatNodeList(self, node_list): def formatNodeList(self, node_list):
if not node_list:
return 'Empty list!'
result = [] result = []
for node_type, address, uuid, state in node_list: for node_type, address, uuid, state in node_list:
if address is None: if address is None:
...@@ -89,9 +91,8 @@ class TerminalNeoCTL(object): ...@@ -89,9 +91,8 @@ class TerminalNeoCTL(object):
max_offset = int(max_offset) max_offset = int(max_offset)
if node is not None: if node is not None:
node = self.asNode(node) node = self.asNode(node)
ptid, row_list = self.neoctl.getPartitionRowList(min_offset=min_offset, ptid, row_list = self.neoctl.getPartitionRowList(
max_offset=max_offset, min_offset=min_offset, max_offset=max_offset, node=node)
node=node)
# TODO: return ptid # TODO: return ptid
return self.formatRowList(row_list) return self.formatRowList(row_list)
...@@ -132,7 +133,7 @@ class TerminalNeoCTL(object): ...@@ -132,7 +133,7 @@ class TerminalNeoCTL(object):
update_partition_table = not(not(int(params[2]))) update_partition_table = not(not(int(params[2])))
else: else:
update_partition_table = False update_partition_table = False
self.neoctl.setNodeState(node, state, return self.neoctl.setNodeState(node, state,
update_partition_table=update_partition_table) update_partition_table=update_partition_table)
def setClusterState(self, params): def setClusterState(self, params):
...@@ -142,7 +143,7 @@ class TerminalNeoCTL(object): ...@@ -142,7 +143,7 @@ class TerminalNeoCTL(object):
state: state to put the cluster in state: state to put the cluster in
""" """
assert len(params) == 1 assert len(params) == 1
self.neoctl.setClusterState(self.asClusterState(params[0])) return self.neoctl.setClusterState(self.asClusterState(params[0]))
def startCluster(self, params): def startCluster(self, params):
""" """
...@@ -166,7 +167,7 @@ class TerminalNeoCTL(object): ...@@ -166,7 +167,7 @@ class TerminalNeoCTL(object):
uuid_list = [node[2] for node in node_list] uuid_list = [node[2] for node in node_list]
else: else:
uuid_list = [self.asNode(x) for x in params] uuid_list = [self.asNode(x) for x in params]
self.neoctl.enableStorageList(uuid_list) return self.neoctl.enableStorageList(uuid_list)
def dropNode(self, params): def dropNode(self, params):
""" """
...@@ -177,7 +178,7 @@ class TerminalNeoCTL(object): ...@@ -177,7 +178,7 @@ class TerminalNeoCTL(object):
set node state (node) DOWN set node state (node) DOWN
""" """
assert len(params) == 1 assert len(params) == 1
self.neoctl.dropNode(self.asNode(params[0])) return self.neoctl.dropNode(self.asNode(params[0]))
def getPrimary(self, params): def getPrimary(self, params):
""" """
...@@ -206,20 +207,15 @@ class Application(object): ...@@ -206,20 +207,15 @@ class Application(object):
isinstance(current_action, dict): isinstance(current_action, dict):
current_action = current_action.get(args[level]) current_action = current_action.get(args[level])
level += 1 level += 1
action = None
if isinstance(current_action, basestring): if isinstance(current_action, basestring):
action = getattr(self.neoctl, current_action, None) action = getattr(self.neoctl, current_action, None)
else:
action = None
if action is None: if action is None:
result = self.usage('unknown command') return self.usage('unknown command')
if result is None: try:
result = 'Ok' return action(args[level:])
else: except NotReadyException, message:
try: return 'ERROR: %s' % (message, )
result = action(args[level:])
except NotReadyException, message:
result = message
return result
def _usage(self, action_dict, level=0): def _usage(self, action_dict, level=0):
result = [] result = []
......
...@@ -72,6 +72,7 @@ class NeoCTL(object): ...@@ -72,6 +72,7 @@ class NeoCTL(object):
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.Error assert response[0] == Packets.Error
assert response[1] == ErrorCodes.ACK assert response[1] == ErrorCodes.ACK
return response[2]
def setClusterState(self, state): def setClusterState(self, state):
""" """
...@@ -81,7 +82,7 @@ class NeoCTL(object): ...@@ -81,7 +82,7 @@ class NeoCTL(object):
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.Error assert response[0] == Packets.Error
assert response[1] == ErrorCodes.ACK assert response[1] == ErrorCodes.ACK
return response[1] return response[2]
def setNodeState(self, node, state, update_partition_table=False): def setNodeState(self, node, state, update_partition_table=False):
""" """
...@@ -95,7 +96,7 @@ class NeoCTL(object): ...@@ -95,7 +96,7 @@ class NeoCTL(object):
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.Error assert response[0] == Packets.Error
assert response[1] == ErrorCodes.ACK assert response[1] == ErrorCodes.ACK
return response[1] return response[2]
def getClusterState(self): def getClusterState(self):
""" """
...@@ -113,7 +114,7 @@ class NeoCTL(object): ...@@ -113,7 +114,7 @@ class NeoCTL(object):
packet = Packets.AskNodeList(node_type) packet = Packets.AskNodeList(node_type)
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.AnswerNodeList assert response[0] == Packets.AnswerNodeList
return response[1] return response[1] # node_list
def getPartitionRowList(self, min_offset=0, max_offset=0, node=None): def getPartitionRowList(self, min_offset=0, max_offset=0, node=None):
""" """
...@@ -123,7 +124,7 @@ class NeoCTL(object): ...@@ -123,7 +124,7 @@ class NeoCTL(object):
packet = Packets.AskPartitionList(min_offset, max_offset, node) packet = Packets.AskPartitionList(min_offset, max_offset, node)
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.AnswerPartitionList assert response[0] == Packets.AnswerPartitionList
return (response[1], response[2]) return response[1:3] # ptid, row_list
def startCluster(self): def startCluster(self):
""" """
......
...@@ -40,10 +40,6 @@ handler = options.handler or "SocketConnector" ...@@ -40,10 +40,6 @@ handler = options.handler or "SocketConnector"
setupLog('NEOCTL', options.verbose) setupLog('NEOCTL', options.verbose)
from neo.neoctl.app import Application from neo.neoctl.app import Application
app = Application(address, port, handler)
result = app.execute(args) print Application(address, port, handler).execute(args)
if result is None:
print "failure"
sys.exit(1)
print result
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