Commit 76671a6f authored by Grégory Wisniewski's avatar Grégory Wisniewski

Use class-check to known the node type.


git-svn-id: https://svn.erp5.org/repos/neo/trunk@1311 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent dd38109e
......@@ -82,16 +82,16 @@ class Node(object):
return '%s (%s:%s)' % (dump(uuid), address, port)
def isMaster(self):
return False
return isinstance(self, MasterNode)
def isStorage(self):
return False
return isinstance(self, StorageNode)
def isClient(self):
return False
return isinstance(self, ClientNode)
def isAdmin(self):
return False
return isinstance(self, AdminNode)
class MasterNode(Node):
......@@ -100,39 +100,24 @@ class MasterNode(Node):
def getType(self):
return protocol.MASTER_NODE_TYPE
def isMaster(self):
return True
class StorageNode(Node):
"""This class represents a storage node."""
def getType(self):
return protocol.STORAGE_NODE_TYPE
def isStorage(self):
return True
class ClientNode(Node):
"""This class represents a client node."""
def getType(self):
return protocol.CLIENT_NODE_TYPE
def isClient(self):
return True
class AdminNode(Node):
"""This class represents an admin node."""
def getType(self):
return protocol.ADMIN_NODE_TYPE
def isAdmin(self):
return True
NODE_TYPE_MAPPING = {
protocol.MASTER_NODE_TYPE: MasterNode,
......
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