From 83fe6b6b3571d190b525e46d30b0df05e552d76e Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 12 Apr 2011 17:26:47 +0200 Subject: [PATCH] Tony has reported that in some rare occurences, RefreshPeer creates nodes that should be remote but remain local protect the fragment that sets host's hrn in the case reported by Tony, this fails with, apparently, the peer's 'hrn_root' being None this change does not fix the first cause for that, but at least should let RefreshPeer finish its job cleanly (but with a missing hrn though) --- PLC/Peers.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/PLC/Peers.py b/PLC/Peers.py index fb47b6e..6489199 100644 --- a/PLC/Peers.py +++ b/PLC/Peers.py @@ -1,5 +1,3 @@ -# $Id$ -# $URL$ # # Thierry Parmentelat - INRIA # @@ -9,6 +7,7 @@ from types import StringTypes from urlparse import urlparse import PLC.Auth +from PLC.Debug import log from PLC.Faults import * from PLC.Namespace import hostname_to_hrn from PLC.Parameter import Parameter, Mixed @@ -165,14 +164,17 @@ class Peer(Row): 'peer_node_id': peer_node_id}, commit = commit) - # attempt to manually update the 'hrn' tag - root_auth = self['hrn_root'] sites = Sites(self.api, node['site_id'], ['login_base']) site = sites[0] login_base = site['login_base'] - hrn = hostname_to_hrn(root_auth, login_base, node['hostname']) - tags = {'hrn': hrn} - Node(self.api, node).update_tags(tags) + try: + # attempt to manually update the 'hrn' tag with the remote prefix + hrn_root = self['hrn_root'] + hrn = hostname_to_hrn(hrn_root, login_base, node['hostname']) + tags = {'hrn': hrn} + Node(self.api, node).update_tags(tags) + except: + print >>log, "WARNING: could not find out hrn on hostname=%s"%node['hostname'] def remove_node(self, node, commit = True): """ @@ -181,7 +183,7 @@ class Peer(Row): remove = Row.remove_object(Node, 'peer_node') remove(self, node, commit) - # attempt to manually update the 'hrn' tag + # attempt to manually update the 'hrn' tag now that the node is local root_auth = self.api.config.PLC_HRN_ROOT sites = Sites(self.api, node['site_id'], ['login_base']) site = sites[0] -- 2.43.0