[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-16 05:27:59

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

Log message:
	more service stuff i had on my local machine

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

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/16 04:54:33	1.113
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/16 05:27:59	1.114
@@ -355,7 +355,7 @@
 	buildClusterCreateFlags(self, batch_id_map, clusterName)
 	return (True, {'errors': errors, 'messages': messages})
 
-def validateServiceEdit(self, request):
+def validateServiceAdd(self, request):
 	try:
 		form_xml = request['form_xml']
 		if not form_xml:
@@ -388,11 +388,36 @@
 		if not form_parent in form_hash:
 			form_hash[form_parent] = {'form': None, 'kids': []}
 		form_hash[form_parent]['kids'].append(form_id)
-		
-	return (True, {'messages': ['OK']})
+		dummy_form = {}
+		for i in ielems:
+			try:
+				type = str(i.getAttribute('type'))
+			except:
+				continue
+			if not type or type == 'button':
+				continue
+			try:
+				dummy_form[str(i.getAttribute('name'))] = str(i.getAttribute('value'))
+			except:
+				pass
 
-def validateServiceAdd(self, request):
-	return (True, {})
+		try:
+			res_type = dummy_form['type'].strip()
+			if not res_type or not res_type in resourceAddHandler:
+				raise
+		except:
+			return (False, {'errors': ['An invalid resource type was specified: ' + res_type]})
+
+		try:
+			resObj = resourceAddHandler[res_type](self, dummy_form)
+		except:
+			resObj = None
+
+		if resObj is None:
+			return (False, {'errors': ['An error occurred while adding ' + res_type]})
+		form_hash[form_id]['obj'] = resObj
+			
+	return (True, {'messages': ['This service has been updated.']})
 
 def validateResourceAdd(self, request):
 	return (True, {})
@@ -400,7 +425,6 @@
 def validateResourceEdit(self, request):
 	return (True, {})
 
-
 ## Cluster properties form validation routines
 
 def validateMCastConfig(self, form):
@@ -646,7 +670,7 @@
 	7: validateConfigCluster,
 	15: validateAddClusterNode,
 	21: validateServiceAdd,
-	24: validateServiceEdit,
+	24: validateServiceAdd,
 	31: validateResourceAdd,
 	33: validateResourceEdit,
 	51: validateFenceAdd,
@@ -2747,9 +2771,10 @@
 	response = request.RESPONSE
 	response.redirect(request['HTTP_REFERER'] + "&busyfirst=true")
 
-def addIp(request):
+def addIp(request, form=None):
+	if form is None:
+		form = request.form
 	modelb = request.SESSION.get('model')
-	form = request.form
 
 	if not modelb or not form:
 		return None
@@ -2785,9 +2810,10 @@
 	modelb.getResourcesPtr().addChild(res)
 	return res
 
-def addFs(request):
+def addFs(request, form=None):
+	if form is None:
+		form = request.form
 	modelb = request.SESSION.get('model')
-	form = request.form
 
 	if not modelb or not form:
 		return None
@@ -2861,9 +2887,9 @@
 	modelb.getResourcesPtr().addChild(res)
 	return res
 
-def addGfs(request):
-	form = request.form
-
+def addGfs(request, form=None):
+	if form is None:
+		form = request.form
 	modelb = request.SESSION.get('model')
 	if not modelb:
 		return None
@@ -2923,8 +2949,9 @@
 	modelb.getResourcesPtr().addChild(res)
 	return res
 
-def addNfsm(request):
-	form = request.form
+def addNfsm(request, form=None):
+	if form is None:
+		form = request.form
 	modelb = request.SESSION.get('model')
 
 	if not form or not modelb:
@@ -2993,8 +3020,9 @@
 	modelb.getResourcesPtr().addChild(res)
 	return res
 
-def addNfsc(request):
-	form = request.form
+def addNfsc(request, form=None):
+	if form is None:
+		form = request.form
 	modelb = request.SESSION.get('model')
 
 	if not form or not modelb:
@@ -3037,9 +3065,10 @@
 	modelb.getResourcesPtr().addChild(res)
 	return res
 
-def addNfsx(request):
+def addNfsx(request, form=None):
+	if form is None:
+		form = request.form
 	modelb = request.SESSION.get('model')
-	form = request.form
 
 	if not modelb or not form:
 		return None
@@ -3069,7 +3098,9 @@
 	modelb.getResourcesPtr().addChild(res)
 	return res
 
-def addScr(request):
+def addScr(request, form=None):
+	if form is None:
+		form = request.form
 	modelb = request.SESSION.get('model')
 	form = request.form
 
@@ -3109,9 +3140,10 @@
 	modelb.getResourcesPtr().addChild(res)
 	return res
 
-def addSmb(request):
+def addSmb(request, form=None):
+	if form is None:
+		form = request.form
 	modelb = request.SESSION.get('model')
-	form = request.form
 
 	if not modelb or not form:
 		return None


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