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

[Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-09-28 22:04:27

Modified files:
	luci/site/luci/Extensions: cluster_adapters.py 

Log message:
	flesh out more stubs

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.75&r2=1.76

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/09/28 20:10:29	1.75
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/09/28 22:04:27	1.76
@@ -330,7 +330,7 @@
 	try:
 		interval = int(form['interval'])
 		if interval < 0:
-			raise ValueError('Interval must be 0 or greater')
+			raise ValueError('Interval must be 0 or greater.')
 	except KeyError, e:
 		errors.append('No Interval value was given.')
 	except ValueError, e:
@@ -365,18 +365,71 @@
 
 	try:
 		device = form['device'].strip()
+		if not device:
+			raise KeyError('device')
 	except KeyError, e:
 		errors.append('No Device value was given.')
 
 	try:
 		label = form['label'].strip()
+		if not label:
+			raise KeyError('label')
 	except KeyError, e:
 		errors.append('No Label value was given.')
 
+	num_heuristics = 0
+	try:
+		num_heuristics = int(form['num_heuristics'])
+		if num_heuristics < 0:
+			raise ValueError(form['num_heuristics'])
+		if num_heuristics == 0:
+			num_heuristics = 1
+	except KeyError, e:
+		errors.append('No number of heuristics was given.')
+	except ValueError, e:
+		errors.append('An invalid number of heuristics was given: ' + e)
+
+	heuristics = list()
+	for i in xrange(num_heuristics):
+		prefix = 'heuristic' + str(i) + ':'
+		try:
+			hname = form[prefix + 'hname'].strip()
+			if not hname:
+				raise KeyError(prefix + 'hname')
+		except KeyError, e:
+			if ((not prefix + 'hpath' in form or not form['hpath'].strip()) and
+				(not prefix + 'hint' in form or not form['hint'].strip()) and
+				(not prefix + 'hscore' in form or not form['hscore'].strip())):
+				# The row is blank; ignore it.
+				continue
+			errors.append('No heuristic name was given for heuristic #' + str(i + 1))
+
+		try:
+			hpath = form[prefix + 'hpath']
+		except KeyError, e:
+			errors.append('No heuristic path was given for heuristic #' + str(i + 1))
+
+		try:
+			hint = int(form[prefix + 'hint'])
+			if hint < 1:
+				raise ValueError('Heuristic interval values must be greater than 0.')
+		except KeyError, e:
+			errors.append('No heuristic interval was given for heuristic #' + str(i + 1))
+		except ValueError, e:
+			errors.append('An invalid heuristic interval was given for heuristic #' + str(i + 1) + ': ' + e)
+
+		try:
+			hscore = int(form[prefix + 'score'])
+			if hscore < 1:
+				raise ValueError('Heuristic scores must be greater than 0.')
+		except KeyError, e:
+			errors.append('No heuristic score was given for heuristic #' + str(i + 1))
+		except ValueError, e:
+			errors.append('An invalid heuristic score was given for heuristic #' + str(i + 1) + ': ' + e)
+		heuristics.append([ hname, hpath, hint, hscore ])
+
 	if len(errors) > 0:
 		return (False, {'errors': errors })
-
-	# heur: heuristicN:hname heuristicN:hprog heuristicN:hint heuristicN:score
 	return (True, {'messages': 'Changes accepted. - FILL ME IN'})
 
 def validateGeneralConfig(self, form):
@@ -384,6 +437,8 @@
 
 	try:
 		cluster_name = form['cluname'].strip()
+		if not cluster_name:
+			raise KeyError('cluname')
 	except KeyError, e:
 		errors.append('No cluster name was given.')
 


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