[Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ...
rmccabe at sourceware.org
rmccabe at sourceware.org
Mon Nov 27 21:05:52 UTC 2006
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 += '</function_call>'
batch += '</request>'
batch += '</module>'
-
+
need_reboot = install_base or install_services or install_shared_storage or install_LVS
if need_reboot:
batch += '<module name="service">'
@@ -96,7 +96,7 @@
batch += '<function_call name="install"/>'
batch += '</request>'
batch += '</module>'
-
+
batch += '<module name="cluster">'
batch += '<request API_version="1.0">'
batch += '<function_call name="set_cluster.conf">'
@@ -236,7 +236,7 @@
batch += '<cman expected_votes="1" two_node="1"/>'
else:
batch += '<cman/>'
-
+
batch += '<fencedevices/>'
batch += '<rm/>'
batch += '</cluster>'
@@ -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 = '<module name="cluster"><request API_version="1.0"><function_call name="status"/></request></module>'
+ 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 = '<module name="cluster"><request API_version="1.0"><function_call name="status"/></request></module>'
- 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 = '<module name="cluster"><request API_version="1.0"><function_call name="restart_service"><var mutable="false" name="servicename" type="string" value=\"' + servicename + '\"/></function_call></request></module>'
More information about the Cluster-devel
mailing list