Commit 3d837577 authored by Aurel's avatar Aurel

implement "neoctl print cluster" call


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@710 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent e6ebedf3
......@@ -81,6 +81,7 @@ class Application(object):
self.monitoring_handler = MasterMonitoringEventHandler(self)
self.request_handler = MasterRequestEventHandler(self)
self.dispatcher = Dispatcher()
self.cluster_state = None
def run(self):
"""Make sure that the status is sane and start a loop."""
......
......@@ -114,6 +114,14 @@ class AdminEventHandler(BaseEventHandler):
msg_id = master_conn.ask(protocol.addPendingNodes(uuid_list))
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
def handleAskClusterState(self, conn, packet):
if self.app.cluster_state is None:
# required it from PMN first
msg_id = self.app.master_conn.ask(protocol.askClusterState())
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
return
conn.answer(protocol.answerClusterState(self.app.cluster_state), packet)
class MasterEventHandler(BaseEventHandler):
""" This class is just used to dispacth message to right handler"""
......@@ -205,6 +213,10 @@ class MasterBaseEventHandler(BaseEventHandler):
EventHandler.peerBroken(self, conn)
@decorators.identification_required
def handleNotifyClusterInformation(self, con, packet, cluster_state):
self.app.cluster_state = cluster_state
@decorators.identification_required
def handleNotifyNodeInformation(self, conn, packet, node_list):
uuid = conn.getUUID()
......@@ -273,6 +285,7 @@ class MasterRequestEventHandler(MasterBaseEventHandler):
def handleAnswerClusterState(self, conn, packet, state):
logging.info("handleAnswerClusterState for a conn")
self.app.cluster_state = state
client_conn, kw = self.app.dispatcher.retrieve(packet.getId())
client_conn.notify(protocol.answerClusterState(state), kw['msg_id'])
......
......@@ -98,6 +98,8 @@ class Application(object):
if node_type is None:
return 'unknown node type'
p = protocol.askNodeList(node_type)
elif print_type == "cluster":
p = protocol.askClusterState()
else:
return "unknown command options"
elif command == "set":
......
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