Commit 5707d952 authored by Aurel's avatar Aurel

add new parameter to SET_NODE_STATE in order to tell if we want to

modify the partition table or not
add two new type message to manage the cluster state


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@595 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent aa52ab68
...@@ -281,6 +281,12 @@ packet_types = Enum({ ...@@ -281,6 +281,12 @@ packet_types = Enum({
# Answer state of the node # Answer state of the node
'ANSWER_NODE_STATE': 0x8023, 'ANSWER_NODE_STATE': 0x8023,
# Set the cluster state
'SET_CLUSTER_STATE': 0x0024,
# Answer state of the cluster
'ANSWER_CLUSTER_STATE': 0x8024,
}) })
# Error codes. # Error codes.
...@@ -987,7 +993,7 @@ decode_table[ANSWER_NODE_LIST] = _decodeAnswerNodeList ...@@ -987,7 +993,7 @@ decode_table[ANSWER_NODE_LIST] = _decodeAnswerNodeList
def _decodeSetNodeState(body): def _decodeSetNodeState(body):
try: try:
uuid, state = unpack('!16sH', body) uuid, state, modify = unpack('!16sHB', body)
state = node_states.get(state) state = node_states.get(state)
if state not in VALID_NODE_STATE_LIST: if state not in VALID_NODE_STATE_LIST:
raise ProtocolError(self, 'invalid node state %d' % state) raise ProtocolError(self, 'invalid node state %d' % state)
...@@ -995,7 +1001,7 @@ def _decodeSetNodeState(body): ...@@ -995,7 +1001,7 @@ def _decodeSetNodeState(body):
raise raise
except: except:
raise ProtocolError(self, 'invalid set node state') raise ProtocolError(self, 'invalid set node state')
return (uuid, state) return (uuid, state, modify)
decode_table[SET_NODE_STATE] = _decodeSetNodeState decode_table[SET_NODE_STATE] = _decodeSetNodeState
def _decodeAnswerNodeState(body): def _decodeAnswerNodeState(body):
...@@ -1013,6 +1019,36 @@ def _decodeAnswerNodeState(body): ...@@ -1013,6 +1019,36 @@ def _decodeAnswerNodeState(body):
decode_table[ANSWER_NODE_STATE] = _decodeAnswerNodeState decode_table[ANSWER_NODE_STATE] = _decodeAnswerNodeState
def _decodeSetClusterState(body):
try:
state, len_name = unpack('!HL', body)
name = body[8:]
if len_name != len(name):
raise PacketMalformedError('invalid name size')
state = cluster_states.get(state)
if state not in VALID_CLUSTER_STATE_LIST:
raise ProtocolError(self, 'invalid cluster state %d' % state)
except ProtocolError:
raise
except:
raise ProtocolError(self, 'invalid set node state')
return (uuid, state, modify)
decode_table[SET_CLUSTER_STATE] = _decodeSetClusterState
def _decodeAnswerClusterState(body):
try:
state = unpack('!H', body)
state = cluster_states.get(state)
if state not in VALID_CLUSTER_STATE_LIST:
raise ProtocolError(self, 'invalid cluster state %d' % state)
except ProtocolError:
raise
except:
raise
raise ProtocolError(self, 'invalid answer node state')
return (uuid, state)
decode_table[ANSWER_CLUSTER_STATE] = _decodeAnswerClusterState
# Packet encoding # Packet encoding
def _error(error_code, error_message): def _error(error_code, error_message):
...@@ -1288,8 +1324,8 @@ def answerNodeList(node_list): ...@@ -1288,8 +1324,8 @@ def answerNodeList(node_list):
body = ''.join(body) body = ''.join(body)
return Packet(ANSWER_NODE_LIST, body) return Packet(ANSWER_NODE_LIST, body)
def setNodeState(uuid, state): def setNodeState(uuid, state, modify_partition_table):
body = [pack('!16sH', uuid, state)] body = [pack('!16sHB', uuid, state, modify_partition_table)]
body = ''.join(body) body = ''.join(body)
return Packet(SET_NODE_STATE, body) return Packet(SET_NODE_STATE, body)
...@@ -1297,3 +1333,13 @@ def answerNodeState(uuid, state): ...@@ -1297,3 +1333,13 @@ def answerNodeState(uuid, state):
body = [pack('!16sH', uuid, state)] body = [pack('!16sH', uuid, state)]
body = ''.join(body) body = ''.join(body)
return Packet(ANSWER_NODE_STATE, body) return Packet(ANSWER_NODE_STATE, body)
def setClusterState(name, state):
body = [pack('!HL', state, len(name))+name]
body = ''.join(body)
return Packet(SET_CLUSTER_STATE, body)
def answerClusterState(state):
body = [pack('!H', uuid, state)]
body = ''.join(body)
return Packet(ANSWER_CLUSTER_STATE, body)
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