[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
Branch: 	RHEL4
Changes by:	rmccabe sourceware org	2007-03-01 20:22:31

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

Log message:
	- Don't leave behind empty clusters when cluster creation fails
	- Pass manage_delObjects() a list in a few places it was getting a string
	Related: bz 230466

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

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/22 20:52:07	1.227.2.11
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/03/01 20:22:31	1.227.2.12
@@ -3293,17 +3293,26 @@
 			% (clustername, cluster_path, str(e)))
 		return results
 
-	for node in nodelist:
+	if len(nodelist) < 1:
+		luci_log.debug_verbose('GCSDB0a: removing cluster %s because it has no nodes' % clustername)
 		try:
-			node_val = {}
-			node_val['type'] = 'node'
-			node_val['name'] = node[0]
-			node_val['clustered'] = '[unknown]'
-			node_val['online'] = '[unknown]'
-			node_val['error'] = True
-			results.append(node_val)
+			clusters_dir = self.restrictedTraverse(CLUSTER_FOLDER_PATH)
+			clusters_dir.manage_delObjects([clustername])
 		except Exception, e:
-			luci_log.debug_verbose('GCSDB1: %s' % str(e))
+			luci_log.debug_verbose('GCSDB0b: %s: %s' % (clustername, str(e)))
+	else:
+		for node in nodelist:
+			try:
+				node_val = {}
+				node_val['type'] = 'node'
+				node_val['name'] = node[0]
+				node_val['clustered'] = '[unknown]'
+				node_val['online'] = '[unknown]'
+				node_val['error'] = True
+				results.append(node_val)
+			except Exception, e:
+				luci_log.debug_verbose('GCSDB1: %s' % str(e))
+
 	return results
 
 def getClusterStatus(self, request, rc, cluname=None):
@@ -4184,7 +4193,7 @@
 			errors += 1
 			continue
 		if nodeJoin(self, rc, clustername, nodename_resolved) is None:
-			luci_log.debug_verbose('CStart1: nodeLeave %s' % nodename_resolved)
+			luci_log.debug_verbose('CStart1: nodeJoin %s' % nodename_resolved)
 			errors += 1
 
 	return errors
@@ -5444,12 +5453,12 @@
           redirect_message = True
 
         luci_log.debug_verbose('ICB13: batch job is done -- deleting %s' % item[0])
-        clusterfolder.manage_delObjects(item[0])
+        clusterfolder.manage_delObjects([item[0]])
         continue
 
-
-
+      del_db_obj = False
       if creation_status < 0:  #an error was encountered
+        luci_log.debug_verbose('ICB13a: %s: CS %d for %s' % (cluname, creation_status, ricci[0]))
         if creation_status == RICCI_CONNECT_FAILURE:
           laststatus = item[1].getProperty(LAST_STATUS)
           if laststatus == INSTALL_TASK: #This means maybe node is rebooting
@@ -5479,14 +5488,17 @@
           node_report['iserror'] = True
           (err_code, err_msg) = extract_module_status(batch_xml, INSTALL_TASK)
           node_report['errormessage'] = CLUNODE_CREATE_ERRORS[INSTALL_TASK] + err_msg
+          del_db_obj = True
         elif creation_status == -(DISABLE_SVC_TASK):
           node_report['iserror'] = True
           (err_code, err_msg) = extract_module_status(batch_xml, DISABLE_SVC_TASK)
           node_report['errormessage'] = CLUNODE_CREATE_ERRORS[DISABLE_SVC_TASK] + err_msg
+          del_db_obj = True
         elif creation_status == -(REBOOT_TASK):
           node_report['iserror'] = True
           (err_code, err_msg) = extract_module_status(batch_xml, REBOOT_TASK)
           node_report['errormessage'] = CLUNODE_CREATE_ERRORS[REBOOT_TASK] + err_msg
+          del_db_obj = True
         elif creation_status == -(SEND_CONF):
           node_report['iserror'] = True
           (err_code, err_msg) = extract_module_status(batch_xml, SEND_CONF)
@@ -5500,11 +5512,15 @@
           (err_code, err_msg) = extract_module_status(batch_xml, START_NODE)
           node_report['errormessage'] = CLUNODE_CREATE_ERRORS[START_NODE]
         else:
+          del_db_obj = True
           node_report['iserror'] = True
           node_report['errormessage'] = CLUNODE_CREATE_ERRORS[0]
 
         try:
-          clusterfolder.manage_delObjects(item[0])
+          if del_db_obj is True:
+            luci_log.debug_verbose('ICB13a: %s node creation failed for %s: %d: deleting DB entry' % (cluname, ricci[0], creation_status))
+            clusterfolder.manage_delObjects([ricci[0]])
+          clusterfolder.manage_delObjects([item[0]])
         except Exception, e:
           luci_log.debug_verbose('ICB14: delObjects: %s: %s' \
             % (item[0], str(e)))
@@ -5518,7 +5534,7 @@
           node_report['statusindex'] = creation_status
           nodereports.append(node_report)
           try:
-              clusterfolder.manage_delObjects(item[0])
+              clusterfolder.manage_delObjects([item[0]])
           except Exception, e:
               luci_log.info('ICB15: Unable to delete %s: %s' % (item[0], str(e)))
           continue
@@ -5569,7 +5585,7 @@
           node_report['desc'] = flag_msg + flag_desc + REDIRECT_MSG
         nodereports.append(node_report)
         try:
-            clusterfolder.manage_delObjects(item[0])
+            clusterfolder.manage_delObjects([item[0]])
         except Exception, e:
             luci_log.info('ICB16: Unable to delete %s: %s' % (item[0], str(e)))
       else:
@@ -7352,7 +7368,7 @@
 			if finished == -1:
 				luci_log.debug_verbose('NNFP2: batch error: %s' % batch_ret[1])
 			try:
-				nodefolder.manage_delObjects(item[0])
+				nodefolder.manage_delObjects([item[0]])
 			except Exception, e:
 				luci_log.info('NNFP3: manage_delObjects for %s failed: %s' \
 					% (item[0], str(e)))


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