[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-10-27 01:11:16

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

Log message:
	more logging for debugging

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

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/26 22:59:13	1.130
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/27 01:11:16	1.131
@@ -1645,6 +1645,7 @@
 			nodename = req.form['nodename']
 		except:
 			return None
+
 	try:
 		cluname = req['clustername']
 	except KeyError, e:
@@ -1656,79 +1657,147 @@
 	ricci_agent = rc.hostname()
 
 	batch_number, result = startService(rc, svcname, nodename)
-	#Now we need to create a DB flag for this system.
+	if not batch_number or not result:
+		luci_log.debug_verbose('startService %s @ %s call failed' \
+			% (svcname, nodename))
+		return None
 
-	path = CLUSTER_FOLDER_PATH + cluname
-	clusterfolder = self.restrictedTraverse(path)
+	#Now we need to create a DB flag for this system.
+	path = str(CLUSTER_FOLDER_PATH + cluname)
 	batch_id = str(batch_number)
-	objname = ricci_agent + "____flag"
-	clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
-	#Now we need to annotate the new DB object
-	objpath = path + "/" + objname
-	flag = self.restrictedTraverse(objpath)
-	#flag[BATCH_ID] = batch_id
-	#flag[TASKTYPE] = SERVICE_START
-	#flag[FLAG_DESC] = "Starting service " + svcname
-	flag.manage_addProperty(BATCH_ID,batch_id, "string")
-	flag.manage_addProperty(TASKTYPE,SERVICE_START, "string")
-	flag.manage_addProperty(FLAG_DESC,"Starting service \'" + svcname + "\'", "string")
+	objname = str(ricci_agent + "____flag")
+
+	try:
+		clusterfolder = self.restrictedTraverse(path)
+		clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
+		#Now we need to annotate the new DB object
+		objpath = str(path + "/" + objname)
+		flag = self.restrictedTraverse(objpath)
+		flag.manage_addProperty(BATCH_ID, batch_id, "string")
+		flag.manage_addProperty(TASKTYPE, SERVICE_START, "string")
+		flag.manage_addProperty(FLAG_DESC, "Starting service \'" + svcname + "\'", "string")
+	except Exception, e:
+		luci_log.debug_verbose('Error creating flag at %s: %s' % (objpath, str(e)))
+
 	response = req.RESPONSE
 	response.redirect(req['HTTP_REFERER'] + "&busyfirst=true")
 
 def serviceRestart(self, rc, req):
-  svcname = req['servicename']
-  batch_number, result = restartService(rc, svcname)
+	try:
+		svcname = req['servicename']
+	except KeyError, e:
+		try:
+			svcname = req.form['servicename']
+		except:
+			luci_log.debug_verbose('no service name for serviceRestart')
+			return None
+	except:
+		luci_log.debug_verbose('no service name for serviceRestart')
+		return None
 
-  ricci_agent = rc.hostname()
-  #Now we need to create a DB flag for this system.
-  cluname = req['clustername']
+	#Now we need to create a DB flag for this system.
+	cluname = None
+	try:
+		cluname = req['clustername']
+	except:
+		try:
+			cluname = req.form['clustername']
+		except:
+			try:
+				cluname = rc.cluster_info()[0]
+			except:
+				pass
 
-  path = CLUSTER_FOLDER_PATH + cluname
-  clusterfolder = self.restrictedTraverse(path)
-  batch_id = str(batch_number)
-  objname = ricci_agent + "____flag"
-  clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
-  #Now we need to annotate the new DB object
-  objpath = path + "/" + objname
-  flag = self.restrictedTraverse(objpath)
-  #flag[BATCH_ID] = batch_id
-  #flag[TASKTYPE] = SERVICE_RESTART
-  #flag[FLAG_DESC] = "Restarting service " + svcname
-  flag.manage_addProperty(BATCH_ID,batch_id, "string")
-  flag.manage_addProperty(TASKTYPE,SERVICE_RESTART, "string")
-  flag.manage_addProperty(FLAG_DESC,"Restarting service " + svcname, "string")
+	if cluname is None:
+		luci_log.debug_verbose('unable to determine cluser name for serviceRestart %s' % svcname)
+		return None
+
+	batch_number, result = restartService(rc, svcname)
+	if not batch_number or not result:
+		luci_log.debug_verbose('restartService for %s failed' % svcname)
+		return None
+				
+	ricci_agent = rc.hostname()
+
+	path = str(CLUSTER_FOLDER_PATH + cluname)
+	batch_id = str(batch_number)
+	objname = str(ricci_agent + "____flag")
+
+	try:
+		clusterfolder = self.restrictedTraverse(path)
+		clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
 
-  response = req.RESPONSE
-  response.redirect(req['HTTP_REFERER'] + "&busyfirst=true")
+		#Now we need to annotate the new DB object
+		objpath = str(path + "/" + objname)
+		flag = self.restrictedTraverse(objpath)
+		flag.manage_addProperty(BATCH_ID, batch_id, "string")
+		flag.manage_addProperty(TASKTYPE, SERVICE_RESTART, "string")
+		flag.manage_addProperty(FLAG_DESC, "Restarting service " + svcname, "string")
+	except Exception, e:
+		luci_log.debug_verbose('Error creating flag in restartService %s: %s' \
+			% (svcname, str(e)))
+
+	response = req.RESPONSE
+	response.redirect(req['HTTP_REFERER'] + "&busyfirst=true")
 
 def serviceStop(self, rc, req):
-  svcname = req['servicename']
-  batch_number, result = stopService(rc, svcname)
+	try:
+		svcname = req['servicename']
+	except KeyError, e:
+		try:
+			svcname = req.form['servicename']
+		except:
+			luci_log.debug_verbose('no service name for serviceStop')
+			return None
+	except:
+		luci_log.debug_verbose('no service name for serviceStop')
+		return None
+
+	#Now we need to create a DB flag for this system.
+	cluname = None
+	try:
+		cluname = req['clustername']
+	except:
+		try:
+			cluname = req.form['clustername']
+		except:
+			try:
+				cluname = rc.cluster_info()[0]
+			except:
+				pass
 
-  #Now we need to create a DB flag for this system.
-  cluname = req['clustername']
+	if cluname is None:
+		luci_log.debug_verbose('unable to determine cluser name for serviceStop %s' % svcname)
+		return None
 
-  ricci_agent = rc.hostname()
+	batch_number, result = stopService(rc, svcname)
+	if not batch_number or not result:
+		luci_log.debug_verbose('stopService for %s failed' % svcname)
+		return None
 
-  path = CLUSTER_FOLDER_PATH + cluname
-  clusterfolder = self.restrictedTraverse(path)
-  batch_id = str(batch_number)
-  objname = ricci_agent + "____flag"
-  clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
-  #Now we need to annotate the new DB object
-  objpath = path + "/" + objname
-  flag = self.restrictedTraverse(objpath)
-  #flag[BATCH_ID] = batch_id
-  #flag[TASKTYPE] = SERVICE_STOP
-  #flag[FLAG_DESC] = "Stopping service " + svcname
-  flag.manage_addProperty(BATCH_ID,batch_id,"string")
-  flag.manage_addProperty(TASKTYPE,SERVICE_STOP, "string")
-  flag.manage_addProperty(FLAG_DESC,"Stopping service " + svcname,"string")
+	ricci_agent = rc.hostname()
 
-  time.sleep(2)
+	path = str(CLUSTER_FOLDER_PATH + cluname)
+	batch_id = str(batch_number)
+	objname = str(ricci_agent + "____flag")
 
-  response = req.RESPONSE
-  response.redirect(req['HTTP_REFERER'] + "&busyfirst=true")
+	try:
+		clusterfolder = self.restrictedTraverse(path)
+		clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
+		#Now we need to annotate the new DB object
+		objpath = str(path + "/" + objname)
+		flag = self.restrictedTraverse(objpath)
+
+		flag.manage_addProperty(BATCH_ID, batch_id, "string")
+		flag.manage_addProperty(TASKTYPE, SERVICE_STOP, "string")
+		flag.manage_addProperty(FLAG_DESC, "Stopping service " + svcname, "string")
+		time.sleep(2)
+	except Exception, e:
+		luci_log.debug_verbose('Error creating flags for stopService %s: %s' \
+			% (svcname, str(e)))
+
+	response = req.RESPONSE
+	response.redirect(req['HTTP_REFERER'] + "&busyfirst=true")
 
 def getFdomsInfo(self, modelb, request, clustatus):
   slist = list()


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