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

[Cluster-devel] conga/luci cluster/form-macros cluster/resourc ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-12-05 06:44:10

Modified files:
	luci/cluster   : form-macros resource-form-macros 
	                 resource_form_handlers.js 
	luci/site/luci/Extensions: cluster_adapters.py 

Log message:
	fixes for adding and editing services

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.119&r2=1.120
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.170&r2=1.171

--- conga/luci/cluster/form-macros	2006/12/04 22:59:56	1.119
+++ conga/luci/cluster/form-macros	2006/12/05 06:44:09	1.120
@@ -2879,7 +2879,9 @@
 		<input type="hidden" name="uuid" value="toplevel" />
 		<input type="hidden" name="parent_uuid" value="_toplevel" />
 		<input type="hidden" name="tree_level" value="-1" />
+		<input type="hidden" name="svc_name" value="" />
 		<input type="hidden" name="form_xml" />
+		<input type="hidden" name="action" value="add" />
 		</form>
 	</div>
 
@@ -2939,30 +2941,46 @@
 </div>
 
 <div metal:define-macro="serviceconfig-type-macro" tal:omit-tag="">
-	<span tal:omit-tag="" tal:condition="python: type == 'ip'">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/ip_macro" />
-	</span>
-	<span tal:omit-tag="" tal:condition="python: type == 'fs'">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/fs_macro" />
-	</span>
-	<span tal:omit-tag="" tal:condition="python: type == 'gfs'">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/gfs_macro" />
-	</span>
-	<span tal:omit-tag="" tal:condition="python: type == 'nfsm'">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/nfsm_macro" />
-	</span>
-	<span tal:omit-tag="" tal:condition="python: type == 'nfsx'">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/nfsx_macro" />
-	</span>
-	<span tal:omit-tag="" tal:condition="python: type == 'nfsc'">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/nfsc_macro" />
-	</span>
-	<span tal:omit-tag="" tal:condition="python: type == 'smb'">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/smb_macro" />
-	</span>
-	<span tal:omit-tag="" tal:condition="python: type == 'script'">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/scr_macro" />
-	</span>
+	<tal:block tal:condition="python: type == 'ip' or type == 'IP Address: '">
+		<tal:block
+			metal:use-macro="here/resource-form-macros/macros/ip_macro" />
+	</tal:block>
+
+	<tal:block tal:condition="python: type == 'fs' or type == 'File System: '">
+		<tal:block
+			metal:use-macro="here/resource-form-macros/macros/fs_macro" />
+	</tal:block>
+
+	<tal:block tal:condition="python: type == 'gfs' or type == 'GFS: '">
+		<tal:block
+			metal:use-macro="here/resource-form-macros/macros/gfs_macro" />
+	</tal:block>
+
+	<tal:block tal:condition="python: type == 'nfsm' or type == 'NFS Mount: '">
+		<tal:block
+			metal:use-macro="here/resource-form-macros/macros/nfsm_macro" />
+	</tal:block>
+
+	<tal:block tal:condition="python: type == 'nfsx' or type == 'NFS Export: '">
+		<tal:block
+			metal:use-macro="here/resource-form-macros/macros/nfsx_macro" />
+	</tal:block>
+
+	<tal:block tal:condition="python: type == 'nfsc' or type == 'NFS Client: '">
+		<tal:block
+			metal:use-macro="here/resource-form-macros/macros/nfsc_macro" />
+	</tal:block>
+
+	<tal:block
+		tal:condition="python: type == 'smb' or type == 'Samba Service: '">
+		<tal:block
+			metal:use-macro="here/resource-form-macros/macros/smb_macro" />
+	</tal:block>
+
+	<tal:block tal:condition="python: type == 'script' or type == 'Script: '">
+		<tal:block
+			metal:use-macro="here/resource-form-macros/macros/scr_macro" />
+	</tal:block>
 </div>
 
 <div metal:define-macro="service-config-head-macro" tal:omit-tag="">
@@ -3071,6 +3089,10 @@
 		</div>
 	</div>
 	<div class="service_comp_list">
+		<form name="service_name_form">
+			<input type="hidden" name="service_name"
+				tal:attributes="value sinfo/name | nothing" />
+		</form>
 		<form name="master" method="post">
 		<tal:block
 			tal:define="global clusterinfo python: here.getClusterInfo(modelb, request)" />
@@ -3086,7 +3108,9 @@
 		<input type="hidden" name="uuid" value="toplevel" />
 		<input type="hidden" name="parent_uuid" value="_toplevel" />
 		<input type="hidden" name="tree_level" value="-1" />
+		<input type="hidden" name="svc_name" value="" />
 		<input type="hidden" name="form_xml" />
+		<input type="hidden" name="action" value="edit" />
 		</form>
 	</div>
 
--- conga/luci/cluster/resource-form-macros	2006/11/10 19:44:57	1.24
+++ conga/luci/cluster/resource-form-macros	2006/12/05 06:44:09	1.25
@@ -271,7 +271,7 @@
 			<div metal:use-macro="here/resource-form-macros/macros/fs_macro" />
 		</tal:block>
 
-		<tal:block tal:condition="python: type == 'gfs'">
+		<tal:block tal:condition="python: type == 'gfs' or type == 'clusterfs'">
 			<div metal:use-macro="here/resource-form-macros/macros/gfs_macro" />
 		</tal:block>
 
@@ -307,7 +307,10 @@
 		tal:attributes="name res/parent_uuid | nothing"
 		tal:define="editDisabled resourceIsRef | nothing">
 
-	<input name="edit" type="hidden"
+	<input name="immutable" type="hidden" value="true"
+		tal:condition="editDisabled" />
+
+	<input name="edit" type="hidden" value="true"
 		tal:condition="python: ptype == '33' and True or False" />
 
 	<input name="pagetype" type="hidden"
@@ -368,7 +371,10 @@
 		tal:attributes="name res/parent_uuid | nothing"
 		tal:define="editDisabled resourceIsRef | nothing">
 
-	<input name="edit" type="hidden"
+	<input name="immutable" type="hidden" value="true"
+		tal:condition="editDisabled" />
+
+	<input name="edit" type="hidden" value="true"
 		tal:condition="python: ptype == '33' and True or False" />
 
 	<input name="pagetype" type="hidden"
@@ -507,7 +513,10 @@
 		tal:attributes="name res/parent_uuid | nothing"
 		tal:define="editDisabled resourceIsRef | nothing">
 
-	<input name="edit" type="hidden"
+	<input name="immutable" type="hidden" value="true"
+		tal:condition="editDisabled" />
+
+	<input name="edit" type="hidden" value="true"
 		tal:condition="python: ptype == '33' and True or False" />
 
 	<input name="pagetype" type="hidden"
@@ -609,7 +618,10 @@
 		tal:attributes="name res/parent_uuid | nothing"
 		tal:define="editDisabled resourceIsRef | nothing">
 
-	<input name="edit" type="hidden"
+	<input name="immutable" type="hidden" value="true"
+		tal:condition="editDisabled" />
+
+	<input name="edit" type="hidden" value="true"
 		tal:condition="python: ptype == '33' and True or False" />
 
 	<input name="pagetype" type="hidden"
@@ -727,7 +739,10 @@
 		tal:attributes="name res/parent_uuid | nothing"
 		tal:define="editDisabled resourceIsRef | nothing">
 
-	<input name="edit" type="hidden"
+	<input name="immutable" type="hidden" value="true"
+		tal:condition="editDisabled" />
+
+	<input name="edit" type="hidden" value="true"
 		tal:condition="python: ptype == '33' and True or False" />
 
 	<input name="pagetype" type="hidden"
@@ -799,7 +814,10 @@
 		tal:attributes="name res/parent_uuid | nothing"
 		tal:define="editDisabled resourceIsRef | nothing">
 
-	<input name="edit" type="hidden"
+	<input name="immutable" type="hidden" value="true"
+		tal:condition="editDisabled" />
+
+	<input name="edit" type="hidden" value="true"
 		tal:condition="python: ptype == '33' and True or False" />
 
 	<input name="pagetype" type="hidden"
@@ -851,7 +869,10 @@
 		tal:attributes="name res/parent_uuid | nothing"
 		tal:define="editDisabled resourceIsRef | nothing">
 
-	<input name="edit" type="hidden"
+	<input name="immutable" type="hidden" value="true"
+		tal:condition="editDisabled" />
+
+	<input name="edit" type="hidden" value="true"
 		tal:condition="python: ptype == '33' and True or False" />
 
 	<input name="pagetype" type="hidden"
@@ -913,7 +934,10 @@
 		tal:attributes="name res/parent_uuid | nothing"
 		tal:define="editDisabled resourceIsRef | nothing">
 
-	<input name="edit" type="hidden"
+	<input name="immutable" type="hidden" value="true"
+		tal:condition="editDisabled" />
+
+	<input name="edit" type="hidden" value="true"
 		tal:condition="python: ptype == '33' and True or False" />
 
 	<input name="pagetype" type="hidden"
--- conga/luci/cluster/resource_form_handlers.js	2006/11/10 19:44:57	1.22
+++ conga/luci/cluster/resource_form_handlers.js	2006/12/05 06:44:09	1.23
@@ -380,14 +380,27 @@
 function forms_to_xml(master_form) {
 	var errors = new Array();
 	var form_xml = '';
+	var svc_name = null;
 
 	var form = document.getElementsByTagName('form');
 	for (var i = 0 ; i < form.length ; i++) {
+		if (form[i].name == 'service_name_form') {
+			if (!form[i].service_name ||
+				str_is_blank(form[i].service_name.value))
+			{
+				set_form_err(form[i].service_name);
+			} else {
+				clr_form_err(form[i].service_name);
+				svc_name = form[i].service_name.value;
+			}
+			continue;
+		}
+
 		if (form[i].name == 'master' || !form[i].uuid || !form[i].uuid.value)
 			continue;
 		var err = check_form(form[i]);
 		if (err)
-			errors.concat(err);
+			errors = errors.concat(err);
 		var temp = form[i].innerHTML.match(/<input [^>]+>/ig).toString().replace(/>(,|$)/g, '/>');
 		if (!temp)
 			continue;
@@ -395,6 +408,9 @@
 					form[i].parent_uuid.value + '">' + temp + '</form>';
 	}
 
+	if (!svc_name)
+		errors.push('No name was given for this service.');
+
 	if (!form_xml)
 		errors.push('No resource information was submitted.');
 
@@ -403,7 +419,14 @@
 
 	/* sort this out in the backend */
 	master_form.form_xml.value = '<formlist>' + form_xml + '</formlist>';
-	if (confirm('Save changes to this service?'))
+	master_form.svc_name.value = svc_name;
+
+	var confirm_msg = null;
+	if (master_form.action.value == 'add')
+		confirm_msg = 'Create this service?';
+	else
+		confirm_msg = 'Save changes to this service?';
+	if (confirm(confirm_msg))
 		master_form.submit();
 	return (0);
 }
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/29 18:15:20	1.170
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/12/05 06:44:10	1.171
@@ -399,8 +399,9 @@
 	try:
 		form_xml = request['form_xml']
 		if not form_xml:
-			raise KeyError('form_xml must not be blank')
-	except KeyError, e:
+			raise KeyError, 'form_xml must not be blank'
+	except Exception, e:
+		luci_log.debug_verbose('vSA0: no form_xml: %s' % str(e))
 		return (False, {'errors': ['No resource data was supplied for this service.']})
 
 	try:
@@ -408,7 +409,8 @@
 		forms = doc.getElementsByTagName('form')
 		if len(forms) < 1:
 			raise
-	except:
+	except Exception, e:
+		luci_log.debug_verbose('vSA1: error: %s' % str(e))
 		return (False, {'errors': ['The resource data submitted for this service is not properly formed.']})
 
 	form_hash = {}
@@ -440,24 +442,31 @@
 			try:
 				dummy_form[str(i.getAttribute('name'))] = str(i.getAttribute('value'))
 			except Exception, e:
-				luci_log.debug_verbose('Error parsing service XML: %s' % str(e))
+				luci_log.debug_verbose('vSA2: parsing XML: %s' % str(e))
 				pass
 
 		try:
 			res_type = dummy_form['type'].strip()
 			if not res_type or not res_type in resourceAddHandler:
-				raise
-		except:
+				raise Exception, 'invalid resource type: %s' % res_type
+		except Exception, e:
+			luci_log.debug_verbose('vSA3: %s' % str(e))
 			return (False, {'errors': ['An invalid resource type was specified: ' + res_type]})
 
 		try:
-			resObj = resourceAddHandler[res_type](request, dummy_form)
-		except:
-			luci_log('res type %d is invalid' % res_type)
+			if dummy_form.has_key('immutable'):
+				model = request.SESSION.get('model')
+				if not model:
+					raise Exception, 'model is None'
+				resObj = getResource(model, dummy_form['resourceName'])
+			else:
+				resObj = resourceAddHandler[res_type](request, dummy_form)
+		except Exception, e:
 			resObj = None
+			luci_log.debug_verbose('vSA4: type %s: %s' % (res_type, str(e)))
 
 		if resObj is None:
-			return (False, {'errors': ['An error occurred while adding ' + res_type]})
+			return (False, {'errors': [ 'An error occurred while adding %s' % res_type ]})
 		form_hash[form_id]['obj'] = resObj
 			
 	return (True, {'messages': ['This service has been updated.']})
@@ -3798,6 +3807,7 @@
 	for item in modelb.getResources():
 		itemmap = {}
 		itemmap['name'] = item.getName()
+		itemmap['attrs'] = item.attr_hash
 		itemmap['type'] = item.resource_type
 		itemmap['cfgurl'] = baseurl + "?" + "clustername=" + cluname + "&resourcename=" + item.getName() + "&pagetype=" + RESOURCE_CONFIG
 		itemmap['url'] = baseurl + "?" + "clustername=" + cluname + "&resourcename=" + item.getName() + "&pagetype=" + RESOURCE
@@ -4651,6 +4661,17 @@
 	response = request.RESPONSE
 	response.redirect(request['URL'] + "?pagetype=" + RESOURCES + "&clustername=" + clustername + '&busyfirst=true')
 
+def getResource(modelb, name):
+	resPtr = modelb.getResourcesPtr()
+	resources = resPtr.getChildren()
+
+	for res in resources:
+		if res.getName() == name:
+			return res
+
+	luci_log.debug_verbose('getResource: unable to find resource \"%s\"' % name)
+	raise KeyError, name
+
 def getResourceForEdit(modelb, name):
 	resPtr = modelb.getResourcesPtr()
 	resources = resPtr.getChildren()
@@ -4660,7 +4681,7 @@
 			resPtr.removeChild(res)
 			return res
 
-	luci_log.debug_verbose('unable to find resource \"%s\"' % name)
+	luci_log.debug_verbose('GRFE0: unable to find resource \"%s\"' % name)
 	raise KeyError, name
 
 def appendModel(request, model):


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