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

[Cluster-devel] conga/luci cluster/form-macros site/luci/Exten ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-11-03 22:48:15

Modified files:
	luci/cluster   : form-macros 
	luci/site/luci/Extensions: cluster_adapters.py 
	                           conga_constants.py 

Log message:
	fix a couple of fence bugs and clean up the configuration validation in preparation for more fixes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.143&r2=1.144
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.21&r2=1.22

--- conga/luci/cluster/form-macros	2006/11/03 21:47:26	1.97
+++ conga/luci/cluster/form-macros	2006/11/03 22:48:14	1.98
@@ -394,6 +394,8 @@
 		</script>
 
 		<form name="basecluster" action="" method="post">
+			<input type="hidden" name="cluster_version"
+				tal:attributes="value os_version | nothing" />
 			<input type="hidden" name="pagetype"
 				tal:attributes="value request/pagetype | request/form/pagetype"
 			/>
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/03 21:13:25	1.143
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/03 22:48:15	1.144
@@ -21,6 +21,7 @@
 from Samba import Samba
 from FenceHandler import FenceHandler
 from clusterOS import resolveOSType
+from FenceHandler import FENCE_OPTS
 from GeneralError import GeneralError
 from UnknownClusterError import UnknownClusterError
 from homebase_adapters import nodeUnauth, nodeAuth, manageCluster, createClusterSystems, havePermCreateCluster, setNodeFlag, delNodeFlag, userAuthenticated, getStorageNode, getClusterNode
@@ -34,8 +35,6 @@
 #then only display chooser if the current user has
 #permissions on at least one. If the user is admin, show ALL clusters
 
-CLUSTER_FOLDER_PATH = '/luci/systems/cluster/'
-
 try:
 	luci_log = LuciSyslog()
 except LuciSyslogError, e:
@@ -481,17 +480,17 @@
 	
 ## Cluster properties form validation routines
 
-def validateMCastConfig(self, form):
+def validateMCastConfig(model, form):
 	try:
 		mcast_val = form['mcast'].strip().lower()
 		if mcast_val != 'true' and mcast_val != 'false':
-			raise KeyError(mcast_val)
+			raise KeyError, mcast_val
 		if mcast_val == 'true':
 			mcast_val = 1
 		else:
 			mcast_val = 0
 	except KeyError, e:
-		return (False, {'errors': ['An invalid multicast selection was made.']})
+		return (False, {'errors': ['An invalid multicast selection was made']})
 
 	if not mcast_val:
 		return (True, {'messages': ['Changes accepted. - FILL ME IN']})
@@ -504,12 +503,12 @@
 	except socket.error, e:
 		try:
 			socket.inet_pton(socket.AF_INET6, addr_str)
-		except socket.error, e6:
-			return (False, {'errors': ['An invalid multicast address was given: ' + e]})
+		except socket.error, e:
+			return (False, {'errors': ['An invalid multicast address was given: %s' % str(e)]})
 
 	return (True, {'messages': ['Changes accepted. - FILL ME IN']})
 
-def validateQDiskConfig(self, form):
+def validateQDiskConfig(model, form):
 	errors = list()
 
 	try:
@@ -521,7 +520,7 @@
 		else:
 			qdisk_val = 0
 	except KeyError, e:
-		return (False, {'errors': ['An invalid quorum partition selection was made.']})
+		return (False, {'errors': ['An invalid quorum partition selection was made']})
 
 	if not qdisk_val:
 		return (True, {'messages': ['Changes accepted. - FILL ME IN']})
@@ -529,64 +528,64 @@
 	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.')
+		errors.append('No Interval value was given')
 	except ValueError, e:
-		errors.append('An invalid Interval value was given: ' + e)
+		errors.append('An invalid Interval value was given: %s' % str(e))
 
 	try:
 		votes = int(form['votes'])
 		if votes < 1:
-			raise ValueError('Votes must be greater than 0')
+			raise ValueError, 'Votes must be greater than 0'
 	except KeyError, e:
-		errors.append('No Votes value was given.')
+		errors.append('No Votes value was given')
 	except ValueError, e:
-		errors.append('An invalid Votes value was given: ' + e)
+		errors.append('An invalid Votes value was given: %s' % str(e))
 
 	try:
 		tko = int(form['tko'])
 		if tko < 0:
-			raise ValueError('TKO must be 0 or greater')
+			raise ValueError, 'TKO must be 0 or greater'
 	except KeyError, e:
-		errors.append('No TKO value was given.')
+		errors.append('No TKO value was given')
 	except ValueError, e:
-		errors.append('An invalid TKO value was given: ' + e)
+		errors.append('An invalid TKO value was given: %s' % str(e))
 
 	try:
 		min_score = int(form['min_score'])
 		if min_score < 1:
 			raise ValueError('Minimum Score must be greater than 0')
 	except KeyError, e:
-		errors.append('No Minimum Score value was given.')
+		errors.append('No Minimum Score value was given')
 	except ValueError, e:
-		errors.append('An invalid Minimum Score value was given: ' + e)
+		errors.append('An invalid Minimum Score value was given: %s' % str(e))
 
 	try:
 		device = form['device'].strip()
 		if not device:
-			raise KeyError('device')
+			raise KeyError, 'device is none'
 	except KeyError, e:
-		errors.append('No Device value was given.')
+		errors.append('No Device value was given')
 
 	try:
 		label = form['label'].strip()
 		if not label:
-			raise KeyError('label')
+			raise KeyError, 'label is none'
 	except KeyError, e:
-		errors.append('No Label value was given.')
+		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'])
+			raise ValueError, 'invalid number of heuristics: %s' % 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)
+		errors.append('An invalid number of heuristics was given: %s' % str(e))
 
 	heuristics = list()
 	for i in xrange(num_heuristics):
@@ -601,37 +600,37 @@
 				(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))
+			errors.append('No heuristic name was given for heuristic #%d' % i + 1)
 
 		try:
 			hpath = form[prefix + 'hpath']
 		except KeyError, e:
-			errors.append('No heuristic path was given for heuristic #' + str(i + 1))
+			errors.append('No heuristic path was given for heuristic #%d' % i + 1)
 
 		try:
 			hint = int(form[prefix + 'hint'])
 			if hint < 1:
-				raise ValueError('Heuristic interval values must be greater than 0.')
+				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))
+			errors.append('No heuristic interval was given for heuristic #%d' % i + 1)
 		except ValueError, e:
-			errors.append('An invalid heuristic interval was given for heuristic #' + str(i + 1) + ': ' + e)
+			errors.append('An invalid heuristic interval was given for heuristic #%d: %s' % (i + 1, str(e)))
 
 		try:
 			hscore = int(form[prefix + 'score'])
 			if hscore < 1:
-				raise ValueError('Heuristic scores must be greater than 0.')
+				raise ValueError, 'Heuristic scores must be greater than 0'
 		except KeyError, e:
-			errors.append('No heuristic score was given for heuristic #' + str(i + 1))
+			errors.append('No heuristic score was given for heuristic #%d' % i + 1)
 		except ValueError, e:
-			errors.append('An invalid heuristic score was given for heuristic #' + str(i + 1) + ': ' + e)
+			errors.append('An invalid heuristic score was given for heuristic #%d: %s' % (i + 1, str(e)))
 		heuristics.append([ hname, hpath, hint, hscore ])
 
 	if len(errors) > 0:
 		return (False, {'errors': errors })
 	return (True, {'messages': ['Changes accepted. - FILL ME IN']})
 
-def validateGeneralConfig(self, form):
+def validateGeneralConfig(model, form):
 	errors = list()
 
 	try:
@@ -655,7 +654,7 @@
 
 	return (True, {'messages': ['Changes accepted. - FILL ME IN']})
 
-def validateFenceConfig(self, form):
+def validateFenceConfig(model, form):
 	errors = list()
 
 	try:
@@ -692,19 +691,33 @@
 	errors = list()
 	messages = list()
 
+	try:
+  		model = request.SESSION.get('model')
+		if not model:
+			raise Exception, 'model is none'
+	except Exception, e:
+		luci_log.debug_verbose('VCC0: unable to get model from session')
+		return (False, {'errors': ['No cluster model was found.']})
+
 	if not 'form' in request:
+		luci_log.debug_verbose('VCC1: no form passed in')
 		return (False, {'errors': ['No form was submitted.']})
+
 	if not 'configtype' in request.form:
+		luci_log.debug_verbose('VCC2: no configtype')
 		return (False, {'errors': ['No configuration type was submitted.']})
+
 	if not request.form['configtype'] in configFormValidators:
+		luci_log.debug_verbose('VCC3: invalid config type: %s' % request.form['configtype'])
 		return (False, {'errors': ['An invalid configuration type was submitted.']})
 
-	val = configFormValidators[request.form['configtype']]
-	ret = val(self, request.form)
+	config_validator = configFormValidators[request.form['configtype']]
+	ret = config_validator(model, request.form)
 
 	retcode = ret[0]
 	if 'errors' in ret[1]:
 		errors.extend(ret[1]['errors'])
+
 	if 'messages' in ret[1]:
 		messages.extend(ret[1]['messages'])
 
@@ -2673,7 +2686,7 @@
     if fencedev.getName().strip() == fencename:
       map = fencedev.getAttributes()
       try:
-        map['pretty_name'] = FenceHandler.FENCE_OPTS[fencedev.getAgentType()]
+        map['pretty_name'] = FENCE_OPTS[fencedev.getAgentType()]
       except Exception, e:
         map['pretty_name'] = fencedev.getAgentType()
 
@@ -2708,7 +2721,7 @@
         for kee in kees:
           fencedev[kee] = attr_hash[kee] #copy attrs over
         try:
-          fencedev['pretty_name'] = FenceHandler.FENCE_OPTS[fd.getAgentType()]
+          fencedev['pretty_name'] = FENCE_OPTS[fd.getAgentType()]
         except Exception, e:
           fencedev['pretty_name'] = fd.getAgentType()
 
--- conga/luci/site/luci/Extensions/conga_constants.py	2006/10/20 20:00:29	1.21
+++ conga/luci/site/luci/Extensions/conga_constants.py	2006/11/03 22:48:15	1.22
@@ -66,6 +66,9 @@
 PATH_TO_PRIVKEY="/var/lib/luci/var/certs/privkey.pem"
 PATH_TO_CACERT="/var/lib/luci/var/certs/cacert.pem"
 
+# Zope DB paths
+CLUSTER_FOLDER_PATH = '/luci/systems/cluster/'
+
 #Node states
 NODE_ACTIVE="0"
 NODE_INACTIVE="1"


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