[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci cluster/form-macros homebase/homeba ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2007-07-12 22:35:40

Modified files:
	luci/cluster   : form-macros 
	luci/homebase  : homebase_common.js 
	luci/plone-custom: conga.js 
	luci/site/luci/Extensions: LuciClusterInfo.py LuciDB.py 
	                           PropsObject.py RicciQueries.py 
	                           cluster_adapters.py 
	                           ricci_communicator.py 

Log message:
	Most of the fix for 247521: Luci returns mis-leading errors if cluster.conf has a syntax error

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.203&r2=1.204
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/plone-custom/conga.js.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciDB.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/RicciQueries.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.260&r2=1.261
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.28&r2=1.29

--- conga/luci/cluster/form-macros	2007/07/12 15:44:43	1.203
+++ conga/luci/cluster/form-macros	2007/07/12 22:35:39	1.204
@@ -122,14 +122,20 @@
 		</td>
 	</tr>
 
-	<tr class="cluster">
-		<td tal:condition="exists: cstatus/error" class="cluster">
+	<tr class="cluster" tal:condition="exists:cstatus/error">
+		<td class="cluster">
 			<span class="errmsgs">
 				An error occurred while attempting to get status information for this cluster. The information shown may be stale or inaccurate.
 			</span>
 		</td>
 	</tr>
 
+	<tr class="cluster" tal:condition="exists:cstatus/errmsg">
+		<td class="cluster">
+			<span class="errmsgs" tal:content="cstatus/errmsg" />
+		</td>
+	</tr>
+
 	<tr class="cluster info_middle">
 		<td colspan="2" class="cluster cluster_quorum">
 			<ul class="cluster_quorum"
--- conga/luci/homebase/homebase_common.js	2007/07/12 15:44:43	1.19
+++ conga/luci/homebase/homebase_common.js	2007/07/12 22:35:39	1.20
@@ -108,14 +108,6 @@
 	}
 }
 
-function hide_element(id) {
-	var elem = document.getElementById(id);
-	if (elem) {
-		elem.style.visibility = 'hidden';
-		elem.style.display = 'none';
-	}
-}
-
 function isValidHost(str) {
 	var i = str.split('.');
 
--- conga/luci/plone-custom/conga.js	2007/06/25 16:11:30	1.5
+++ conga/luci/plone-custom/conga.js	2007/07/12 22:35:39	1.6
@@ -11,6 +11,14 @@
 	return str.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace('\'', '&apos;');
 }
 
+function hide_element(id) {
+	var elem = document.getElementById(id);
+	if (elem) {
+		elem.style.visibility = 'hidden';
+		elem.style.display = 'none';
+	}
+}
+
 function popup_window(url, width_percent, height_percent) {
 	var width = window.innerWidth * (width_percent / 100);
 	var height = window.innerHeight * (height_percent / 100);
--- conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/07/12 15:44:43	1.6
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/07/12 22:35:40	1.7
@@ -123,36 +123,38 @@
 	return results
 
 def getClusterStatus(self, request, rc, cluname=None):
-
 	try:
-		doc = rq.getClusterStatusBatch(rc)
-		if not doc:
-			raise Exception, 'doc is None'
+		doc = rq.getClusterStatusBatch(rc) or None
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('GCS0: error: %r %s' % (e, str(e)))
+			luci_log.debug_verbose('GCS0: error: %r: %r %s' \
+				% (cluname, e, str(e)))
 		doc = None
 
-	if doc is None and not cluname:
-		try:
-			model = request.SESSION.get('model')
-			cinfo = getClusterStatusModel(model)
-			if not cinfo or len(cinfo) < 1:
-				raise Exception, 'cinfo is None'
-			return cinfo
-		except Exception, e:
-			if LUCI_DEBUG_MODE is True:
-				luci_log.debug_verbose('GCS1: %r %s' % (e, str(e)))
-			doc = None
+	if doc is None:
+		model = LuciExtractCluModel(self, request, cluname)
+		if model is not None:
+			try:
+				cinfo = getClusterStatusModel(model)
+				if not cinfo or len(cinfo) < 1:
+					raise Exception, 'cinfo is None'
+				return cinfo
+			except Exception, e:
+				if LUCI_DEBUG_MODE is True:
+					luci_log.debug_verbose('GCS1: %r: %r %s' \
+						% (cluname, e, str(e)))
 
-	if not doc:
+	if doc is None:
 		try:
 			from LuciDB import getClusterStatusDB
-			fvars = GetReqVars(request, [ 'clustername' ])
+			if cluname:
+				clustername = cluname
+			else:
+				fvars = GetReqVars(request, [ 'clustername' ])
 
-			clustername = fvars['clustername']
-			if clustername is None:
-				raise Exception, 'unable to determine cluster name'
+				clustername = fvars['clustername']
+				if clustername is None:
+					raise Exception, 'unable to determine cluster name'
 
 			cinfo = getClusterStatusDB(self, clustername)
 			if not cinfo or len(cinfo) < 1:
@@ -160,7 +162,8 @@
 			return cinfo
 		except Exception, e:
 			if LUCI_DEBUG_MODE is True:
-				luci_log.debug_verbose('GCS1a: unable to get cluster info from DB: %r %s' % (e, str(e)))
+				luci_log.debug_verbose('GCS2: cluster %r info from DB: %r %s' \
+					% (cluname, e, str(e)))
 		return []
 
 	results = list()
@@ -699,11 +702,13 @@
 
 def getClustersInfo(self, status, req):
 	clu_map = {}
+
+	fvars = GetReqVars(req, [ 'URL' ])
+	baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+
 	nodelist = list()
 	svclist = list()
 	clulist = list()
-	baseurl = req['URL']
-
 	for item in status:
 		if item['type'] == 'node':
 			nodelist.append(item)
@@ -713,11 +718,14 @@
 			clulist.append(item)
 		else:
 			continue
+
 	if len(clulist) < 1:
 		return {}
 	clu = clulist[0]
-	if 'error' in clu:
-		clu_map['error'] = True
+	if clu.has_key('error'):
+		clu_map['error'] = clu['error']
+	if clu.has_key('errmsg'):
+		clu_map['errmsg'] = clu['errmsg']
 	clustername = clu['name']
 	if not clu['alias']:
 		clu_map['clusteralias'] = clu['alias']
@@ -788,7 +796,8 @@
 def getNodeInfo(self, model, status, request):
 	infohash = {}
 	item = None
-	baseurl = request['URL']
+	fvars = GetReqVars(request, [ 'URL', 'clustername', 'nodename' ])
+	baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
 
 	nodestate = NODE_ACTIVE
 	svclist = list()
@@ -796,13 +805,12 @@
 		if thing['type'] == 'service':
 			svclist.append(thing)
 
-	# Get cluster name and node name from request
-	try:
-		clustername = request['clustername']
-		nodename = request['nodename']
-	except Exception, e:
+	clustername = fvars['clustername']
+	nodename = fvars['nodename']
+	if clustername is None or nodename is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('getNodeInfo0: %r %s' % (e, str(e)))
+			luci_log.debug_verbose('getNodeInfo0: %r %r' \
+				% (clustername, nodename))
 		return {}
 
 	# extract correct node line from cluster status
@@ -900,7 +908,7 @@
 		try:
 			rc = RicciCommunicator(nodename_resolved)
 			if not rc:
-				raise Exception, 'rc is none'
+				raise Exception, 'connection failed'
 		except Exception, e:
 			rc = None
 			infohash['ricci_error'] = True
@@ -930,6 +938,10 @@
 	nodelist = list()
 	svclist = list()
 
+	fvars = GetReqVars(req, [ 'URL', 'clustername' ])
+	baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+	clustername = fvars['clustername']
+
 	#Sort into lists...
 	for item in status:
 		if item['type'] == 'node':
@@ -939,24 +951,14 @@
 		else:
 			continue
 
-	try:
-		clustername = req['clustername']
-		if not clustername:
-			raise KeyError, 'clustername is blank'
-	except:
+	if clustername is None:
 		try:
-			clustername = req.form['clustername']
-			raise KeyError, 'clustername is blank'
-		except:
-			try:
-				clustername = req.form['clustername']
-			except:
-				try:
-					clustername = model.getClusterName()
-				except:
-					if LUCI_DEBUG_MODE is True:
-						luci_log.debug_verbose('GNI0: unable to determine cluster name')
-					return {}
+			clustername = model.getClusterName().strip()
+		except Exception, e:
+			if LUCI_DEBUG_MODE is True:
+				luci_log.debug_verbose('GNI0: no cluster name: %r %s' \
+					% (e, str(e)))
+			return {}
 
 	for item in nodelist:
 		nl_map = {}
@@ -968,11 +970,6 @@
 		except:
 			nl_map['gulm_lockserver'] = False
 
-		try:
-			baseurl = req['URL']
-		except:
-			baseurl = '/luci/cluster/index_html'
-
 		cfgurl = '%s?pagetype=%s&clustername=%s&nodename=%s' \
 			% (baseurl, NODE, clustername, name)
 		nl_map['configurl'] = cfgurl
@@ -1058,9 +1055,11 @@
 			luci_log.debug_verbose('getFence0: model is None')
 		return {}
 
-	fence_map = {}
-	fencename = request['fencename']
+	fvars = GetReqVars(request, [ 'URL', 'fencename' ])
+	baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+	fencename = fvars['fencename']
 
+	fence_map = {}
 	nodes = model.getNodes()
 	fencedevs = model.getFenceDevices()
 	clustername = model.getClusterName()
@@ -1090,7 +1089,6 @@
 									found_duplicate = True
 							if found_duplicate is True:
 								continue
-							baseurl = request['URL']
 							node_hash = {}
 							cur_nodename = node.getName().strip()
 							node_hash['nodename'] = cur_nodename
@@ -1398,8 +1396,10 @@
 		fences_map['fencedevs'] = list()
 		return fences_map
 
-	clustername = request['clustername']
-	baseurl = request['URL']
+	fvars = GetReqVars(request, [ 'clustername', 'URL' ])
+	baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+	clustername = fvars['clustername'] or model.getClusterName()
+
 	fencedevs = list() #This is for the fencedev list page
 
 	#Get list of fence devices
@@ -1556,6 +1556,37 @@
 			luci_log.debug_verbose('GMFC1: unable to get model builder for %s: %r %s' % (clustername, e, str(e)))
 	return None
 
+def LuciExtractCluModel(self, request, cluster_name=None):
+	model = None
+	try:
+		model = request.SESSION.get('model')
+		model.getClusterName()
+		return model
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('LECM0: %r: %r %s' \
+				% (cluster_name, e, str(e)))
+		model = None
+
+	if not cluster_name:
+		fvar = GetReqVars(request, [ 'clustername' ])
+		cluster_name = fvar['clustername']
+
+	if cluster_name is None:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('LECM1: no cluster name')
+		return None
+
+	try:
+		model = getModelForCluster(self, cluster_name)
+		model.getClusterName()
+		return model
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('LECM2: no model for %s: %r %s' \
+				% (cluster_name, e, str(e)))
+	return None
+
 def getClusterOS(self, rc):
 	from HelperFunctions import resolveOSType
 
--- conga/luci/site/luci/Extensions/LuciDB.py	2007/06/28 16:02:50	1.4
+++ conga/luci/site/luci/Extensions/LuciDB.py	2007/07/12 22:35:40	1.5
@@ -931,7 +931,7 @@
 			luci_log.debug_verbose('GCF0: cluster %s [%s] folder missing: %r %s -- returning empty map' % (cluname, path, e, str(e)))
 	return None
 
-def getClusterStatusDB(self, clustername):
+def getClusterStatusDB(self, clustername, errmsg=None):
 	results = list()
 	vals = {}
 
@@ -942,12 +942,14 @@
 	vals['quorate'] = '[unknown]'
 	vals['votes'] = '[unknown]'
 	vals['minQuorum'] = '[unknown]'
+	if errmsg:
+		vals['errmsg'] = errmsg
 	results.append(vals)
 
 	nodelist = getClusterDBNodes(self, clustername)
 	if len(nodelist) < 1:
-		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('GCSDB0a: removing cluster %s because it has no nodes' % clustername)
+		luci_log.info('Removing cluster %s because it has no nodes' \
+			% clustername)
 		try:
 			clusters_dir = self.restrictedTraverse(CLUSTER_FOLDER_PATH)
 			clusters_dir.manage_delObjects([clustername])
@@ -960,7 +962,7 @@
 	for node in nodelist:
 		node_val = {}
 		node_val['type'] = 'node'
-		node_val['name'] = node
+		node_val['name'] = node[0]
 		node_val['clustered'] = '[unknown]'
 		node_val['online'] = '[unknown]'
 		node_val['error'] = True
--- conga/luci/site/luci/Extensions/PropsObject.py	2007/07/12 15:44:43	1.5
+++ conga/luci/site/luci/Extensions/PropsObject.py	2007/07/12 22:35:40	1.6
@@ -7,7 +7,7 @@
 
 from Variable import parse_variable
 from ricci_defines import PROPS_TAG
-from xml.dom.Node import ELEMENT_NODE
+import xml.dom
 
 class PropsObject:
 
@@ -35,7 +35,7 @@
     def import_xml(self, parent_node):
         props = None
         for node in parent_node.childNodes:
-            if node.nodeType == ELEMENT_NODE:
+            if node.nodeType == xml.dom.Node.ELEMENT_NODE:
                 if node.nodeName == PROPS_TAG:
                     props = node
         if props is None:
--- conga/luci/site/luci/Extensions/RicciQueries.py	2007/06/27 08:14:13	1.3
+++ conga/luci/site/luci/Extensions/RicciQueries.py	2007/07/12 22:35:40	1.4
@@ -289,6 +289,9 @@
 	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:
+		return None
+
 	try:
 		cluster_tags = ricci_xml.getElementsByTagName('cluster')
 	except Exception, e:
@@ -300,10 +303,12 @@
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('GCSB1: %d entries - expecting 1' \
 				% len(cluster_tags))
+			return None
 	elif len(cluster_tags) > 1:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('GCSB2: %d entries, expecting 1 use first' \
 				% len(cluster_tags))
+
 	try:
 		cluster_node = cluster_tags[0]
 		if not cluster_node:
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/07/03 17:05:59	1.260
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/07/12 22:35:40	1.261
@@ -25,9 +25,11 @@
 from LuciSyslog import get_logger
 from ResourceHandler import create_resource
 from homebase_adapters import parseHostForm
-from LuciClusterInfo import getClusterInfo, getModelBuilder, getModelForCluster
 from LuciClusterActions import propagateClusterConfAsync
 
+from LuciClusterInfo import getClusterInfo, \
+	getModelBuilder, LuciExtractCluModel
+
 from conga_constants import BATCH_ID, CLUNODE_CREATE_ERRORS, \
 	CLUSTER_ADD, CLUSTER_CONFIG, CLUSTER_DAEMON, CLUSTER_DELETE, \
 	CLUSTER_FOLDER_PATH, CLUSTER_RESTART, CLUSTER_START, CLUSTER_STOP, \
@@ -545,8 +547,7 @@
 	try:
 		model = getModelBuilder(None, cluster_ricci, cluster_ricci.dom0())
 		if not model:
-			errors.append('Unable to build the cluster model for %s' \
-				% clustername)
+			errors.append('Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername)
 			raise Exception, 'unable to get model for %s' % clustername
 
 		nodesptr = model.getClusterNodesPtr()
@@ -560,8 +561,7 @@
 					% (node_name, clustername))
 	except Exception, e:
 		incomplete = True
-		errors.append('Unable to build the cluster model for %s' \
-			% clustername)
+		errors.append('Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername)
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('VACN11: %r %s' % (e, str(e)))
 
@@ -629,7 +629,7 @@
 			raise Exception, 'batch or result is None'
 	except Exception, e:
 		incomplete = True
-		errors.append('Unable to save the new cluster model')
+		errors.append('Unable to generate the new cluster configuration')
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('VACN14: %s' % e)
 
@@ -728,7 +728,7 @@
 	if model is None:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('vSA1: no model')
-		return (False, {'errors': ['No cluster model was found']})
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
 
 	try:
 		doc = minidom.parseString(form_xml)
@@ -921,12 +921,11 @@
 			luci_log.debug_verbose('VRA0: type is blank')
 		return (False, {'errors': ['No resource type was given']})
 
-	try:
-		model = request.SESSION.get('model')
-	except Exception, e:
+	model = LuciExtractCluModel(self, request)
+	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VRA1: no model: %r %s' % (e, str(e)))
-		return None
+			luci_log.debug_verbose('VRA1: no model')
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration. The configuration XML may contain errors' ]})
 
 	errors = list()
 	try:
@@ -1397,8 +1396,8 @@
 	model = LuciExtractCluModel(self, request, clustername)
 	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VCC0: no model, no cluster name')
-		return (False, {'errors': ['No cluster model was found']})
+			luci_log.debug_verbose('VCC0: no model')
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
 
 	if clustername is None:
 		clustername = model.getClusterName()
@@ -1437,37 +1436,6 @@
 	request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \
 		% (baseurl, CLUSTER_CONFIG, clustername))
 
-def LuciExtractCluModel(self, request, cluster_name=None):
-	model = None
-	try:
-		model = request.SESSION.get('model')
-		model.getClusterName()
-		return model
-	except Exception, e:
-		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('LECM0: %s: %r %s' \
-				% (cluster_name, e, str(e)))
-		model = None
-
-	if not cluster_name:
-		fvar = GetReqVars(request, [ 'clustername' ])
-		cluster_name = fvar['clustername']
-		if cluster_name is None:
-			if LUCI_DEBUG_MODE is True:
-				luci_log.debug_verbose('LECM1: no cluster name')
-
-	if cluster_name is None:
-		return None
-
-	try:
-		model = getModelForCluster(self, cluster_name)
-		model.getClusterName()
-		return model
-	except Exception, e:
-		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('LECM2: no model: %r %s' % (e, str(e)))
-	return None
-
 def validateFenceAdd(self, request):
 	errors = list()
 	fvar = GetReqVars(request, [ 'clustername', 'URL' ])
@@ -1476,10 +1444,10 @@
 	clustername = fvar['clustername']
 
 	model = LuciExtractCluModel(self, request, clustername)
-	if not model:
+	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFE0: no model')
-		return (False, { 'errors': [ 'No cluster model was found' ] })
+			luci_log.debug_verbose('VFA0: no model')
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ] })
 
 	ret_code, ret_obj = validateNewFenceDevice(request.form, model)
 	if ret_code != FD_VAL_SUCCESS:
@@ -1502,14 +1470,14 @@
 	clustername = fvar['clustername']
 	if clustername is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFE: No cluster name')
+			luci_log.debug_verbose('VFE0: No cluster name')
 		return (False, {'errors': ['No cluster name was given']})
 
 	model = LuciExtractCluModel(self, request, clustername)
 	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFE: unable to get model from session')
-		return (False, {'errors': ['No cluster model was found']})
+			luci_log.debug_verbose('VFE1: no model')
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ] })
 
 	# This is a fence edit situation, so the model should already have an
 	# entry for this fence device.
@@ -1569,9 +1537,8 @@
 	model = LuciExtractCluModel(self, request, clustername)
 	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('vNFC6: unable to get model for cluster %s' \
-				% clustername)
-		return (False, {'errors': ['No cluster model was found']})
+			luci_log.debug_verbose('vNFC6: no model for %s' % clustername)
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ] })
 
 	try:
 		doc = minidom.parseString(fvar['fence_xml'])
@@ -1798,20 +1765,20 @@
 	nodename = fvar['nodename']
 	if nodename is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFE: no node name')
+			luci_log.debug_verbose('DFD0: no node name')
 		return (False, {'errors': ['No node name was given']})
 
 	clustername = fvar['clustername']
 	if clustername is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFE: no cluster name')
+			luci_log.debug_verbose('DFD1: no cluster name')
 		return (False, {'errors': ['No cluster name was given']})
 
 	model = LuciExtractCluModel(self, request, clustername)
 	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFE: model, no cluster name')
-		return (False, {'errors': ['No cluster model was found']})
+			luci_log.debug_verbose('DFD2: no model')
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ] })
 
 	fencedev_name = fvar['orig_name']
 	if fencedev_name is None:
@@ -1826,7 +1793,7 @@
 
 	if fdev_to_delete is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFD: Could not find fence device "%s" in model' % fencedev_name)
+			luci_log.debug_verbose('DFD3: Could not find fence device "%s" in model' % fencedev_name)
 		return (False, {'errors': ['Could not find fence device "%s" in model' % fencedev_name ]})
 
 	fdev_ptr = model.getFenceDevicePtr()
@@ -1840,7 +1807,7 @@
 		model.removeFenceInstancesForFenceDevice(fencedev_name)
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFD: error removing %s: %r %s' \
+			luci_log.debug_verbose('DFD4: error removing %s: %r %s' \
 				% (fencedev_name, e, str(e)))
 
 	ret = propagateClusterConfAsync(self, model, None, CLUSTER_CONFIG,
@@ -1940,15 +1907,15 @@
 	if clustername is None:
 		errors.append('Unable to determine this cluster\'s name')
 
-	name = fvar['name']
-	if name is None:
-		errors.append('No name was given for this failover domain')
-
 	model = LuciExtractCluModel(self, request, clustername)
 	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('validateFdom0: no model: %r %s')
-		return (False, {'errors': [ 'Unable to retrieve cluster information' ]})
+			luci_log.debug_verbose('validateFdom0: no model')
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
+
+	name = fvar['name']
+	if name is None:
+		errors.append('No name was given for this failover domain')
 
 	prioritized = False
 	try:
@@ -2051,19 +2018,19 @@
 	model = LuciExtractCluModel(self, request, clustername)
 	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('validateVM0: no model')
-		return (False, {'errors': [ 'Unable to retrieve cluster information' ]})
+			luci_log.debug_verbose('validateVM1: no model')
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
 
 	vm_name = fvar['vmname']
 	if vm_name is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('validateVM0: no vm name')
+			luci_log.debug_verbose('validateVM2: no vm name')
 		errors.append('No virtual machine name was given')
 
 	vm_path = fvar['vmpath']
 	if vm_path is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('validateVM1: no vm path')
+			luci_log.debug_verbose('validateVM3: no vm path')
 		errors.append('No path to the virtual machine configuration directory was given')
 
 	autostart = 1
@@ -2205,7 +2172,7 @@
 		if getClusterInfo(self, None, req) == {}:
 			msg_list.append('invalid cluster')
 		else:
-			model = req.SESSION.get('model')
+			model = LuciExtractCluModel(self, req, clustername)
 			cc = model.exportModelAsString()
 
 	return { 'msg': ''.join(msg_list), 'cluster_conf': cc }
@@ -2283,20 +2250,12 @@
 
 	if not model:
 		cluname = fvar['clustername']
-		if cluname is None:
+		model = LuciExtractCluModel(self, request, cluname)
+		if model is None:
 			if LUCI_DEBUG_MODE is True:
-				luci_log.debug('CTP1: no cluster name')
-			return 'No cluster name was given'
-
-		try:
-			model = getModelForCluster(self, cluname)
-			if not model:
-				raise Exception, 'No cluster model'
-		except Exception, e:
-			if LUCI_DEBUG_MODE is True:
-				luci_log.debug_verbose('CTP2: GMFC failed for %s: %r %s' \
-					% (e, str(e), cluname))
-			return 'Unable to get the model object for %s' % cluname
+				luci_log.debug_verbose('CTP2: No cluster model for %s' \
+					% cluname)
+			return 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors.' % cluname
 
 	redirect_page = NODES
 	if task == CLUSTER_STOP:
@@ -2312,7 +2271,7 @@
 		from LuciClusterActions import ClusterDelete
 		ret = ClusterDelete(self, model)
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('CTP3: ret is %s' % str(e))
+			luci_log.debug_verbose('CTP3: ret is %r' % ret)
 		if ret is not None:
 			redirect_page = ret
 	else:
@@ -2869,20 +2828,19 @@
 	fvars = GetReqVars(req,
 				[ 'clustername', 'servicename', 'nodename', 'URL' ])
 	baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+	clustername = fvars['clustername']
 
-	try:
-		model = LuciExtractCluModel(self, req,
-					cluster_name=fvars['clustername'])
-	except Exception, e:
+	model = LuciExtractCluModel(self, req, clustername)
+	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('serviceDelete0: %r %s' % (e, str(e)))
-		return (False, { 'errors': [ 'No resource name was given' ]})
+			luci_log.debug_verbose('serviceDelete0: no model')
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
 
 	ret = DeleteCluSvc(self, rc, fvars, model)
 	if ret is None:
 		response = req.RESPONSE
 		response.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \
-			% (baseurl, SERVICES, fvars['clustername']))
+			% (baseurl, SERVICES, clustername))
 	else:
 		return ret
 
@@ -2907,21 +2865,19 @@
 	fvars = GetReqVars(req,
 		[ 'clustername', 'resourcename', 'nodename', 'URL' ])
 	baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+	clustername = fvars['clustername']
 
-	try:
-		model = LuciExtractCluModel(self, req, fvars['clustername'])
-		if not model:
-			raise Exception, 'no model'
-	except Exception, e:
+	model = LuciExtractCluModel(self, req, clustername)
+	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('resourceDelete0: %r %s' % (e, str(e)))
-		return (False, { 'errors': [ 'No resource name was given' ] })
+			luci_log.debug_verbose('resourceDelete0: no model')
+		return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
 
 	ret = DeleteResource(self, rc, model, fvars['resourcename'])
 	if ret is None:
 		response = req.RESPONSE
 		response.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \
-			% (baseurl, RESOURCES, fvars['clustername']))
+			% (baseurl, RESOURCES, clustername))
 	else:
 		return ret
 
--- conga/luci/site/luci/Extensions/ricci_communicator.py	2007/07/03 16:56:39	1.28
+++ conga/luci/site/luci/Extensions/ricci_communicator.py	2007/07/12 22:35:40	1.29
@@ -5,8 +5,7 @@
 # GNU General Public License as published by the
 # Free Software Foundation.
 
-from xml.dom import minidom
-from xml.dom.Node import ELEMENT_NODE
+from xml.dom import minidom, Node
 from conga_ssl import SSLSocket
 from LuciSyslog import get_logger
 from conga_constants import LUCI_DEBUG_MODE, LUCI_DEBUG_NET
@@ -242,7 +241,7 @@
 
 		batch_node = None
 		for node in doc.firstChild.childNodes:
-			if node.nodeType == ELEMENT_NODE:
+			if node.nodeType == Node.ELEMENT_NODE:
 				if node.nodeName == 'batch':
 					batch_node = node#.cloneNode(True)
 		if batch_node is None:
@@ -361,7 +360,7 @@
 
 		batch_node = None
 		for node in doc.firstChild.childNodes:
-			if node.nodeType == ELEMENT_NODE:
+			if node.nodeType == Node.ELEMENT_NODE:
 				if node.nodeName == 'batch':
 					batch_node = node#.cloneNode(True)
 		if batch_node is None:
@@ -500,7 +499,7 @@
 	total = 0
 	last  = 0
 	for node in batch_xml.childNodes:
-		if node.nodeType == ELEMENT_NODE:
+		if node.nodeType == Node.ELEMENT_NODE:
 			if node.nodeName == 'module':
 				total = total + 1
 				status = node.getAttribute('status')
@@ -549,7 +548,7 @@
 
 	c = 0
 	for node in batch_xml.childNodes:
-		if node.nodeType == ELEMENT_NODE:
+		if node.nodeType == Node.ELEMENT_NODE:
 			if node.nodeName == 'module':
 				module_xml = node
 				c = c + 1
@@ -558,17 +557,17 @@
 					if status == '0' or status == '4':
 						# module executed, dig deeper into request
 						for node_i in module_xml.childNodes:
-							if node_i.nodeType == ELEMENT_NODE:
+							if node_i.nodeType == Node.ELEMENT_NODE:
 								if node_i.nodeName == 'API_error':
 									return -2, 'API error'
 								elif node_i.nodeName == 'response':
 									for node_j in node_i.childNodes:
-										if node_j.nodeType == ELEMENT_NODE:
+										if node_j.nodeType == Node.ELEMENT_NODE:
 											if node_j.nodeName == 'function_response':
 												code = -11111111
 												msg = 'BUG'
 												for var in node_j.childNodes:
-													if var.nodeType == ELEMENT_NODE:
+													if var.nodeType == Node.ELEMENT_NODE:
 														if var.nodeName == 'var':
 															if var.getAttribute('name') == 'success' and var.getAttribute('value') == 'true':
 																return 0, ''


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]