[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-12-08 23:02:50

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

Log message:
	more fixes for add node

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.177&r2=1.178
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.47&r2=1.48

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/12/08 20:47:37	1.177
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/12/08 23:02:49	1.178
@@ -13,6 +13,7 @@
 from Clusterfs import Clusterfs
 from Fs import Fs
 from RefObject import RefObject
+from ClusterNode import ClusterNode
 from NFSClient import NFSClient
 from NFSExport import NFSExport
 from Service import Service
@@ -329,10 +330,10 @@
 	except Exception, e:
 		luci_log.debug_verbose('vACN2: %s: %s' % (clusterName, str(e)))
 		try:
-			rc = getRicciAgent(self, clusterName)
-			if not rc:
+			cluster_ricci = getRicciAgent(self, clusterName)
+			if not cluster_ricci:
 				raise Exception, 'cannot find a ricci agent for %s' % clusterName
-			cluster_os = getClusterOS(self, rc)['os']
+			cluster_os = getClusterOS(self, cluster_ricci)['os']
 			if clusterObj is None:
 				try:
 					clusterObj = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
@@ -387,9 +388,64 @@
 	if not cluster_properties['isComplete']:
 		return (False, {'errors': errors, 'requestResults': cluster_properties})
 
+	try:
+		cluster_ricci = getRicciAgent(self, clusterName)
+		if not cluster_ricci:
+			raise Exception, 'Unable to get a ricci agent for %s' % clusterName
+	except Exception, e:
+		cluster_properties['isComplete'] = False
+		nodeUnauth(nodeList)
+		errors.append('Unable to contact a Ricci agent for %s.' % clusterName)
+		luci_log.debug_verbose('vACN6: ricci %s: %s' % (clusterName, str(e)))
+		return (False, {'errors': errors, 'requestResults': cluster_properties})
+
+	try:
+		model = getModelBuilder(None, cluster_ricci, cluster_ricci.dom0())
+		if not model:
+			raise Exception, 'unable to get model for %s' % clusterName
+		nodesptr = model.getClusterNodesPtr()
+		used_ids = {}
+		for i in model.getNodes():
+			try:
+				used_ids[int(i.getAttribute('nodeid'))] = 1
+			except Exception, e:
+				luci_log.debug_verbose('vACN7: %s' % str(e))
+				pass
+		next_node_id = 1;
+		for i in nodeList:
+			next_node_id += 1
+			new_node = ClusterNode()
+			new_node.attr_hash['name'] = i['host']
+			new_node.attr_hash['votes'] = str(1)
+			while next_node_id in used_ids:
+				next_node_id += 1
+			new_node.attr_hash['nodeid'] = str(next_node_id)
+			nodesptr.addChild(new_node)
+
+		model.isModified = True
+		conf_str = str(model.exportModelAsString())
+		if not conf_str:
+			raise Exception, 'unable to export model as a string'
+		batch_number, result = setClusterConf(cluster_ricci, conf_str)
+
+		while True:
+			batch_ret = checkBatch(cluster_ricci, batch_number)
+			code = batch_ret[0]
+			if code == True:
+				break
+			if code == -1:
+				errors.append(batch_ret[1])
+				raise Exception, batch_ret[1]
+			if code == False:
+				time.sleep(0.5)
+	except Exception, e:
+		luci_log.debug_verbose('vACN8: %s' % str(e))
+		errors.append('Unable to update the cluster node list for %s' % clusterName)
+		return (False, {'errors': errors, 'requestResults': cluster_properties})
+
 	error = createClusterSystems(self, clusterName, nodeList)
 	if error:
-		luci_log.debug_verbose('vACN5a: %s: %s' % (clusterName, str(e)))
+		luci_log.debug_verbose('vACN9: %s: %s' % (clusterName, str(e)))
 		nodeUnauth(nodeList)
 		cluster_properties['isComplete'] = False
 		errors.append(error)
@@ -405,7 +461,7 @@
 		except Exception, e:
 			nodeUnauth([clunode['host']])
 			success = False
-			luci_log.info('vACN6: Unable to connect to the ricci daemon on host %s: %s' % (clunode['host'], str(e)))
+			luci_log.info('vACN10: Unable to connect to the ricci daemon on host %s: %s' % (clunode['host'], str(e)))
 
 		if success:
 			try:
@@ -414,7 +470,7 @@
 			except Exception, e:
 				nodeUnauth([clunode['host']])
 				success = False
-				luci_log.info('vACN7: %s' % (clunode['host'], str(e)))
+				luci_log.info('vACN11: %s' % (clunode['host'], str(e)))
 
 		if not success:
 			cluster_properties['isComplete'] = False
@@ -4007,19 +4063,26 @@
         rc = RicciCommunicator(ricci[0])
       except Exception, e:
         rc = None
-        finished = False
+        finished = -1
+        err_msg = ''
         luci_log.debug_verbose('ICB15: ricci error: %s: %s' \
           % (ricci[0], str(e)))
 
       if rc is not None:
-        finished = checkBatch(rc, item[1].getProperty(BATCH_ID))
-
-      if finished == True:
+        batch_res = checkBatch(rc, item[1].getProperty(BATCH_ID))
+        finished = batch_res[0]
+        err_msg = batch_res[1]
+
+      if finished == True or finished == -1:
+        if finished == -1:
+          flag_msg = err_msg
+        else:
+          flag_msg = ''
         flag_desc = item[1].getProperty(FLAG_DESC)
         if flag_desc is None:
-          node_report['desc'] = REDIRECT_MSG
+          node_report['desc'] = flag_msg + REDIRECT_MSG
         else:
-          node_report['desc'] = flag_desc + REDIRECT_MSG
+          node_report['desc'] = flag_msg + flag_desc + REDIRECT_MSG
         nodereports.append(node_report)
         try:
             clusterfolder.manage_delObjects(item[0])
@@ -5097,8 +5160,11 @@
 				pass
 			luci_log.info('NNFP2: %s not authenticated' % item[0])
 
-		finished = checkBatch(rc, item[1].getProperty(BATCH_ID))
-		if finished == True:
+		batch_ret = checkBatch(rc, item[1].getProperty(BATCH_ID))
+		finished = batch_ret[0]
+		if finished == True or finished == -1:
+			if finished == -1:
+				luci_log.debug_verbose('NNFP2: batch error: %s' % batch_ret[1])
 			try:
 				nodefolder.manage_delObjects(item[0])
 			except Exception, e:
--- conga/luci/site/luci/Extensions/ricci_bridge.py	2006/11/27 21:05:51	1.47
+++ conga/luci/site/luci/Extensions/ricci_bridge.py	2006/12/08 23:02:49	1.48
@@ -1,7 +1,7 @@
 import xml
 from time import time, ctime
 from xml.dom import minidom
-from ricci_communicator import RicciCommunicator
+from ricci_communicator import RicciCommunicator, extract_module_status
 from LuciSyslog import LuciSyslog
 
 try:
@@ -10,23 +10,33 @@
 	pass
 
 def checkBatch(rc, batch_id):
+	err_msg = 'An unknown Ricci error occurred on %s' % rc.hostname()
+
 	try:
 		batch = rc.batch_report(batch_id)
 		if batch is None:
-			return True
+			return (True, 'batch id was not found')
 	except:
-		return False
+		return (-1, err_msg)
 
 	try:
-		dummy = batch.getAttribute('batch_id')
-		result = batch.getAttribute('status')
+		code, new_err_msg = extract_module_status(batch, 1)
+		if new_err_msg:
+			err_msg = 'A Ricci error occurred on %s: %s' \
+				% (rc.hostname(), str(new_err_msg))
 	except:
-		return False
+		return (-1, err_msg)
 
-	if result == '0':
-		return True
+	# In progress.
+	if code == -101 or code == -102:
+		return (False, 'in progress')
+
+	# Done successfully.
+	if code == '0':
+		return (True, 'completed sucessfully')
 
-	return False
+	# Error
+	return (-1, err_msg)
 
 def addClusterNodeBatch(os_str,
 						cluster_name,


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