From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 27 Nov 2006 21:05:52 -0000 Subject: [Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ... Message-ID: <20061127210552.19065.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-11-27 21:05:51 Modified files: luci/site/luci/Extensions: cluster_adapters.py ricci_bridge.py Removed files: luci/site/luci/Extensions: RicciReceiveError.py UnknownClusterError.py Log message: cleanups Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.167&r2=1.168 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/RicciReceiveError.py.diff?cvsroot=cluster&r1=1.1&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/UnknownClusterError.py.diff?cvsroot=cluster&r1=1.1&r2=NONE --- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/11/27 19:11:41 1.167 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/11/27 21:05:51 1.168 @@ -1026,7 +1026,7 @@ try: pagetype = request[PAGETYPE] - except KeyError, e: + except: pagetype = '3' @@ -1121,7 +1121,7 @@ try: url = request['URL'] - except KeyError, e: + except: url = "/luci/cluster/index_html" #The only way this method can run is if there exists @@ -2819,8 +2819,13 @@ svclist.append(thing) #Get cluster name and node name from request - clustername = request['clustername'] - nodename = request['nodename'] + try: + clustername = request['clustername'] + nodename = request['nodename'] + except Exception, e: + luci_log.debug_verbose('getNodeInfo0: %s' % str(e)) + return {} + #extract correct node line from cluster status found = False for item in status: @@ -2828,7 +2833,9 @@ found = True break if found == False: - raise UnknownClusterError("Fatal", "Unable to resolve node name in cluster status") + luci_log.debug_verbose('getNodeInfo1: Unable to resolve node name in cluster status') + return {} + #Now determine state of node... if item['online'] == "false": nodestate = NODE_UNKNOWN --- conga/luci/site/luci/Extensions/ricci_bridge.py 2006/11/20 23:30:17 1.46 +++ conga/luci/site/luci/Extensions/ricci_bridge.py 2006/11/27 21:05:51 1.47 @@ -63,7 +63,7 @@ batch += '' batch += '' batch += '' - + need_reboot = install_base or install_services or install_shared_storage or install_LVS if need_reboot: batch += '' @@ -96,7 +96,7 @@ batch += '' batch += '' batch += '' - + batch += '' batch += '' batch += '' @@ -236,7 +236,7 @@ batch += '' else: batch += '' - + batch += '' batch += '' batch += '' @@ -298,66 +298,39 @@ pass return (None, None) - -def getPayload(bt_node): - if not bt_node: - return None - - mod_node = None - for node in bt_node.childNodes: - if node.nodeType == xml.dom.Node.ELEMENT_NODE and node.nodeName == 'module': - mod_node = node - if not mod_node: - return None - - resp_node = None - for node in mod_node.childNodes: - if node.nodeType == xml.dom.Node.ELEMENT_NODE: - resp_node = node - if not resp_node: - return None +def getClusterStatusBatch(rc): + batch_str = '' + ricci_xml = rc.batch_run(batch_str, async=False) - fr_node = None - for node in resp_node.childNodes: - if node.nodeType == xml.dom.Node.ELEMENT_NODE: - fr_node = node - if not fr_node: + try: + cluster_tags = ricci_xml.getElementsByTagName('cluster') + except Exception, e: + luci_log.debug_verbose('getClusterStatusBatch0: %s' % str(e)) return None - varnode = None - for node in fr_node.childNodes: - if node.nodeName == 'var': - varnode = node - break - if not varnode: - return None + if len(cluster_tags) < 1: + luci_log.debug_verbose('getClusterStatusBatch1: %d entries - expecting 1' \ + % len(cluster_tags)) + elif len(cluster_tags) > 1: + luci_log.debug_verbose('getClusterStatusBatch2: %d entries - expecting 1, using the first' % len(cluster_tags)) - cl_node = None - for node in varnode.childNodes: - if node.nodeName == 'cluster': - cl_node = node - break - if not cl_node: + try: + cluster_node = cluster_tags[0] + if not cluster_node: + raise Exception, 'element 0 is None' + except Exception, e: + luci_log.debug_verbose('getClusterStatusBatch3: %s' % str(e)) return None - doc = minidom.Document() - doc.appendChild(cl_node) - return doc - -def getClusterStatusBatch(rc): - batch_str = '' - ricci_xml = rc.batch_run(batch_str, async=False) - - if not ricci_xml or not ricci_xml.firstChild: - luci_log.debug_verbose('ricci_xml is None from batch_run') - - doc = getPayload(ricci_xml.firstChild) - if not doc or not doc.firstChild: - luci_log.debug_verbose('doc is None from getPayload: %s' % ricci_xml.toxml()) - return None + try: + doc = minidom.Document() + doc.appendChild(cluster_node) + return doc + except Exception, e: + luci_log.debug_verbose('getClusterStatusBatch4: %s' % str(e)) - return doc + return None def setClusterConf(rc, clusterconf, propagate=True): if propagate == True: @@ -490,7 +463,7 @@ return None, None ricci_xml = rc.batch_run(batch) return batchAttemptResult(ricci_xml) - + def restartService(rc, servicename): batch_str = ''