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

[Cluster-devel] conga/luci homebase/form-macros site/luci/Exte ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-07-31 17:46:32

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

Log message:
	cluster add bits.. been sitting here unchecked in for too long

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/form-macros.diff?cvsroot=cluster&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.23&r2=1.24

--- conga/luci/homebase/form-macros	2006/07/25 17:47:36	1.31
+++ conga/luci/homebase/form-macros	2006/07/31 17:46:32	1.32
@@ -1,7 +1,7 @@
 <html>
 
 <tal:comment replace="nothing">
-	$Id: form-macros,v 1.31 2006/07/25 17:47:36 rmccabe Exp $
+	$Id: form-macros,v 1.32 2006/07/31 17:46:32 rmccabe Exp $
 </tal:comment>
 
 <head>
@@ -336,7 +336,7 @@
 		</tal:block>
 
 		<div tal:omit-tag="" tal:condition="python: systems[1] and len(systems[1]) > 0">
-			<h3 class="homebase">Unclustered Systems</h3>
+			<h3 class="homebase">Storage Systems</h3>
 
 			<tal:block tal:repeat="s python: systems[1]">
 				<div class="hbcheckdiv"
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/07/28 19:03:05	1.23
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/07/31 17:46:32	1.24
@@ -25,17 +25,15 @@
 
 CLUSTER_FOLDER_PATH = '/luci/systems/cluster/'
 
-def validateCreateCluster(self, request):
-	errors = list()
-	messages = list()
+def validateClusterNodes(request, sessionData, numStorage):
 	nodeList = list()
 	nodeHash = {}
 	rnodeHash = {}
 	oldNodeHash = {}
 	oldRnodeHash = {}
 	requestResults = {}
+	errors = list()
 
- 	sessionData = request.SESSION.get('checkRet')
 	if sessionData and 'requestResults' in sessionData:
 		requestResults = sessionData['requestResults']
 		if 'nodeHash' in requestResults:
@@ -43,18 +41,6 @@
 		if 'rnodeHash' in requestResults:
 			oldRnodeHash = requestResults['rnodeHash']
 
-	if not 'clusterName' in request.form or not request.form['clusterName']:
-		return (False, {'errors': [ 'No cluster name was specified.' ] })
-	clusterName = request.form['clusterName']
-
-	try:
-		numStorage = int(request.form['numStorage'])
-	except:
-		return (False, { 'errors': ['Unknown number of systems entered'], 'requestResults': requestResults })
-
-	if numStorage < 2:
-		return (False, { 'errors': ['A cluster must contain at least two nodes'], 'requestResults': requestResults })
-
 	i = 0
 	while i < numStorage:
 		try:
@@ -95,9 +81,6 @@
 				nodeList.append(node)
 		i += 1
 
-	if len(nodeList) < 2:
-		errors.append('A cluster must contain at least two nodes')
-
 	sfn = lambda x, y: \
 		x['cur_auth'] - y['cur_auth'] or (('errors' in y) - ('errors' in x))
 	nodeList.sort(sfn)
@@ -111,6 +94,41 @@
 		'isComplete': len(errors) < 1 and len(filter(dfn, nodeList)) == 0
 	}
 
+	return [errors, cluster_properties]
+
+def validateCreateCluster(self, request):
+	errors = list()
+	messages = list()
+	requestResults = {}
+
+	try:
+	 	sessionData = request.SESSION.get('checkRet')
+	except:
+		sessionData = None
+
+	if not 'clusterName' in request.form or not request.form['clusterName']:
+		return (False, {'errors': [ 'No cluster name was specified.' ] })
+	clusterName = request.form['clusterName']
+
+	try:
+		numStorage = int(request.form['numStorage'])
+	except:
+		return (False, { 'errors': ['Unknown number of systems entered'], 'requestResults': requestResults })
+
+	if numStorage < 2:
+		return (False, { 'errors': ['A cluster must contain at least two nodes'], 'requestResults': requestResults })
+
+	ret = validateClusterNodes(request, sessionData, numStorage)
+	errors.extend(ret[0])
+	cluster_properties = ret[1]
+
+	try:
+		nodeList = cluster_properties['nodeList']
+		if len(nodeList) < 2:
+			raise
+	except:
+		errors.append('A cluster must contain at least two nodes')
+
 	if cluster_properties['isComplete'] != True:
 		nodeUnauth(nodeList)
 		return (False, {'errors': errors, 'requestResults':cluster_properties })
@@ -168,12 +186,53 @@
   
 
 def validateAddClusterNode(self, request):
+	try:
+	 	sessionData = request.SESSION.get('checkRet')
+	except:
+		sessionData = None
+
 	if 'clusterName' in request.form:
 		clusterName = request.form['clusterName']
 	else:
 		return (False, {'errrors': [ 'Cluster name is missing'] })
 
-	return None
+	try:
+		numStorage = int(request.form['numStorage'])
+		if numStorage < 1:
+			raise
+	except:
+		errors.append('You must specify at least one node to add to the cluster')
+		return (False, {'errors': [ errors ] })
+
+	ret = validateClusterNodes(sessionData, request, numStorage)
+	errors.extend(ret[0])
+	cluster_properties = ret[1]
+
+	try:
+		nodeList = cluster_properties['nodeList']
+		if len(nodeList) < 1:
+			raise
+	except:
+		errors.append('You must specify at least one valid node to add to the cluster')
+		
+	if not cluster_properties['isComplete']:
+		return (False, {'errors': errors, 'requestResults': cluster_properties})
+
+	i = 0
+	while i < len(nodeList):
+		try:
+			x = 0 # ricci call succeeds
+			messages.append('Cluster join initiated for host \"' + i['ricci_host'] + '\"')
+			del nodeList[i]
+		except:
+			i['errors'] = True
+			errors.append('Unable to initiate node creation for host \"' + i['ricci_host'] + '\"')
+			cluster_properties['isComplete'] = 0
+
+	if not cluster_properties['isComplete']:
+		return (False, {'errors': errors, 'requestResults': cluster_properties})
+
+	return (True, {'errors': errors, 'messages': messages})
 
 formValidators = {
 	6: validateCreateCluster,


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