From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 13 Oct 2006 22:56:29 -0000 Subject: [Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ... Message-ID: <20061013225629.10058.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2006-10-13 22:56:28 Modified files: luci/site/luci/Extensions: cluster_adapters.py Log message: detect changes in cluster membership and deal with them accordingly, part 1 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.109&r2=1.110 --- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/10/13 21:25:14 1.109 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/10/13 22:56:28 1.110 @@ -2926,12 +2926,9 @@ def resolveClusterChanges(self, clusterName, modelb): try: - mb_nodes = dict.fromkeys(modelb.getNodes()) + mb_nodes = modelb.getNodes() if not mb_nodes or not len(mb_nodes): raise - mb_map = {} - for i in iter(mb_nodes): - mb_map[i] = i except: return 'Unable to find cluster nodes for ' + clusterName @@ -2943,16 +2940,48 @@ return 'Unable to find an entry for ' + clusterName + ' in the Luci database.' try: - db_nodes = cluster_node.objectItems('Folder') + db_nodes = map(lambda x: x[0], cluster_node.objectItems('Folder')) if not db_nodes or not len(db_nodes): raise - db_map = {} - for i in iter(db_nodes): - db_map[i[0]] = i[0] except: # Should we just create them all? Can this even happen? return 'Unable to find database entries for any nodes in ' + clusterName + same_host = lambda x, y: x == y or x[:len(y) + 1] == y + '.' or y[:len(x) + 1] == x + '.' + + # this is a really great algorithm. + missing_list = list() + new_list = list() + for i in mb_nodes: + for j in db_nodes: + f = 0 + if same_host(i, j): + f = 1 + break + if not f: + new_list.append(i) + + for i in db_nodes: + for j in mb_nodes: + f = 0 + if same_host(i, j): + f = 1 + break + if not f: + missing_list.append(i) + + messages = list() + for i in missing_list: + cluster_node.delObjects([i]) + messages.append('Node \"' + i + '\" is no longer in a member of cluster \"' + clusterName + '.\". It has been deleted from the management interface for this cluster.') + + for i in new_list: + cluster_node.manage_addFolder(i, '__luci__:csystem:' + clusterName) + cluster_node.manage_addProperty('exceptions', 'auth', 'string') + messages.append('A new node, \"' + i + ',\" is now a member of cluster \"' + clusterName + '.\". It has added to the management interface for this cluster, but you must authenticate to it in order for it to be fully functional.') + + return messages + def addResource(self, request, ragent): if not request.form: return (False, {'errors': ['No form was submitted.']})