# 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;
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
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']
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: