Skip to contentSkip to conversation

conga/luci/site/luci/Extensions cluster_adapte ...

Cluster-devel [email protected] 1 participant 1 message Sep 25, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-09-25 22:59:15

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

Log message:
add node stuff

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.69&r2=1.70
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.18&r2=1.19

luci/site/luci/Extensions/cluster_adapters.py +36 -9
@@ -23,7 +23,7 @@
 #then only display chooser if the current user has 
 #permissions on at least one. If the user is admin, show ALL clusters
 
-from homebase_adapters import nodeAuth, nodeUnauth, manageCluster
+from homebase_adapters import nodeAuth, nodeUnauth, manageCluster, createClusterSystems
 
 CLUSTER_FOLDER_PATH = '/luci/systems/cluster/'
 
@@ -151,6 +151,7 @@
 			cluster_properties['isComplete'] = False
 			errors.append(error)
 			return (False, {'errors': errors, 'requestResults':cluster_properties })
+
 		batch_id_map = {}
 		for i in nodeList:
 			try:
@@ -189,7 +190,8 @@
 
 def validateAddClusterNode(self, request):
 	errors = list()
-	messages = list()
+	messages = list() 
+	requestResults = {}
 
 	try:
 	 	sessionData = request.SESSION.get('checkRet')
@@ -199,7 +201,7 @@
 	if 'clusterName' in request.form:
 		clusterName = request.form['clusterName']
 	else:
-		return (False, {'errors': [ 'Cluster name is missing'] })
+		return (False, {'errors': [ 'Cluster name is missing'], 'requestResults': requestResults })
 
 	try:
 		numStorage = int(request.form['numStorage'])
@@ -207,7 +209,7 @@
 			raise
 	except:
 		errors.append('You must specify at least one node to add to the cluster')
-		return (False, {'errors': [ errors ] })
+		return (False, {'errors': [ errors ], 'requestResults': requestResults })
 
 	ret = validateClusterNodes(request, sessionData, clusterName, numStorage)
 	errors.extend(ret[0])
@@ -225,18 +227,43 @@
 
 	i = 0
 	while i < len(nodeList):
+		clunode = nodeList[i]
 		try:
-			x = 0 # ricci call succeeds
-			messages.append('Cluster join initiated for host \"' + i['ricci_host'] + '\"')
+			batchNode = addClusterNodeBatch(clusterName, True, False, False)
+			if not batchNode:
+				raise
 			del nodeList[i]
 		except:
-			i['errors'] = True
-			errors.append('Unable to initiate node creation for host \"' + i['ricci_host'] + '\"')
-			cluster_properties['isComplete'] = 0
+			clunode['errors'] = True
+			nodeUnauth(nodeList)
+			cluster_properties['isComplete'] = False
+			errors.append('Unable to initiate node creation for host \"' + clunode['ricci_host'] + '\"')
 
 	if not cluster_properties['isComplete']:
 		return (False, {'errors': errors, 'requestResults': cluster_properties})
 
+	error = createClusterSystems(self, clusterName, nodeList)
+	if error:
+		nodeUnauth(nodeList)
+		cluster_properties['isComplete'] = False
+		errors.append(error)
+		return (False, {'errors': errors, 'requestResults': cluster_properties})
+
+	batch_id_map = {}
+	for i in nodeList:
+		clunode = nodeList[i]
+		try:
+			rc = RicciCommunicator(clunode['ricci_host'])
+			resultNode = rc.process_batch(batchNode, async=True)
+			batch_id_map[clunode['ricci_host']] = resultNode.getAttribute('batch_id')
+			messages.append('Cluster join initiated for host \"' + clunode['ricci_host'] + '\"')
+		except:
+			nodeUnauth(nodeList)
+			cluster_properties['isComplete'] = False
+			errors.append('An error occurred while attempting to add cluster node \"' + clunode['ricci_host'] + '\"')
+			return (False, {'errors': errors, 'requestResults': cluster_properties})
+
+	buildClusterCreateFlags(self, batch_id_map, clusterName)
 	return (True, {'errors': errors, 'messages': messages})
 
 formValidators = {
luci/site/luci/Extensions/homebase_adapters.py +86 -0

92 lines not on this page · raw message

luci/site/luci/Extensions/ricci_bridge.py +51 -0

57 lines not on this page · raw message