X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FPeers.py;h=94d32049a98217fa6248a5cce4520f743a56e5df;hb=5cf6e6071879f41a9833b2dc402077908947b30d;hp=e4598dc192ff926f91db3cfb9e1d12b8c63d6600;hpb=5c85cde8979a8919505b22e8c7b573c85d86f7fb;p=plcapi.git diff --git a/PLC/Peers.py b/PLC/Peers.py index e4598dc..94d3204 100644 --- a/PLC/Peers.py +++ b/PLC/Peers.py @@ -110,7 +110,7 @@ class Peer (Row): # a host would have switched from one plc to the other local_foreign_nodes = ForeignNodes (self.api) # new to index it by hostname for searching later - local_foreign_nodes.hostname_index() + local_foreign_nodes_index = local_foreign_nodes.dict('hostname') ### mark entries for this peer outofdate old_count=0; @@ -120,7 +120,6 @@ class Peer (Row): old_count += 1 ### these fields get copied through - ### xxx need to figure how to revert unix timestamp to db timestamp format remote_fields = ['boot_state','model','version','date_created','last_updated'] ### scan the new entries, and mark them uptodate @@ -128,7 +127,7 @@ class Peer (Row): hostname = node['hostname'] foreign_id = node ['node_id'] try: - foreign_node = local_foreign_nodes.hostname_locate(hostname) + foreign_node = local_foreign_nodes_index[hostname] if foreign_node['peer_id'] != peer_id: ### the node has changed its plc, needs to update peer_node old_peer_id = foreign_node['peer_id'] @@ -153,7 +152,7 @@ class Peer (Row): new_foreign_node.sync() new_foreign_node.uptodate = True self.manage_node(new_foreign_node,foreign_id,True) - local_foreign_nodes.hostname_add_by(new_foreign_node) + local_foreign_nodes_index[hostname]=new_foreign_node ### delete entries that are not uptodate for foreign_node in local_foreign_nodes: