Commit 9111aa13 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Change NodeManager.log() implementation, display one node per line with (or

without) it's UUID and bind address if available. Implement '__gt__' to sort
nodes per UUID by default.
Reduce log verbosity by displaying nodes only one time per manager update.


git-svn-id: https://svn.erp5.org/repos/neo/trunk@1323 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent cc2d5e26
...@@ -295,28 +295,21 @@ class NodeManager(object): ...@@ -295,28 +295,21 @@ class NodeManager(object):
node.setState(state) node.setState(state)
self.add(node) self.add(node)
logging.info('create node %s %s %s %s' % log_args) logging.info('create node %s %s %s %s' % log_args)
self.log() self.log()
def log(self): def log(self):
logging.debug('Node manager : %d nodes' % len(self._node_set)) logging.debug('Node manager : %d nodes' % len(self._node_set))
node_with_uuid = set(sorted(self._uuid_dict.values())) for node in sorted(list(self._node_set)):
node_without_uuid = self._node_set - node_with_uuid uuid = dump(node.getUUID()) or '-' * 32
for node in node_with_uuid | node_without_uuid: address = node.getAddress() or ''
if node.getUUID() is not None: if address:
uuid = dump(node.getUUID()) address = '%s:%d' % address
else: logging.debug(' * %32s | %17s | %22s | %s' % (
uuid = '-' * 32 uuid, node.getType(), address, node.getState()))
args = (
uuid, def __gt__(self, node):
node.getType(), # sort per UUID if defined
node.getState() if self._uuid is not None:
) return self._uuid > node.uuid
logging.debug('nm: %s : %s/%s' % args) return self._address > node._address
for address, node in sorted(self._address_dict.items()):
args = (
address,
node.getType(),
node.getState()
)
logging.debug('nm: %s : %s/%s' % args)
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