All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
Date: 8 Feb 2007 03:43:00 -0000	[thread overview]
Message-ID: <20070208034300.9744.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-02-08 03:42:58

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

Log message:
	Support editing fdoms

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.181&r2=1.182
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_fdom.js.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.233&r2=1.234

--- conga/luci/cluster/form-macros	2007/02/08 02:34:35	1.181
+++ conga/luci/cluster/form-macros	2007/02/08 03:42:58	1.182
@@ -4353,14 +4353,14 @@
 				<td>
 					<input type="checkbox" name="prioritized" id="prioritized"
 						onchange="fdom_set_prioritized(this.form, this.checked)"
-						tal:attributes="checked fdom/prioritied | nothing" />
+						tal:attributes="checked python: (fdom and 'prioritized' in fdom and fdom['prioritized'] == '1') and 'checked' or ''" />
 				</td>
 			</tr>
 			<tr class="systemsTable">
 				<td>Restrict failover to this domain's members</td>
 				<td>
 					<input type="checkbox" name="restricted"
-						tal:attributes="checked fdom/restricted | nothing" />
+						tal:attributes="checked python: (fdom and 'restricted' in fdom and fdom['restricted'] == '1') and 'checked' or ''" />
 				</td>
 			</tr>
 			<tr class="systemsTable">
@@ -4393,15 +4393,17 @@
 					<td class="systemsTable" width="10%">
 						<input type="checkbox"
 							onchange="fdom_set_member(this.form, this.name, this.checked)"
-							tal:attributes="name n" />
+							tal:attributes="
+								checked python: ('members' in fdom and n in fdom['members']) and 'checked' or '';
+								name n" />
 					</td>
 					<td class="systemsTable" width="75%">
 						<input type="text" class="fdom_priority"
 							tal:attributes="
 								id n;
 								name python: '__PRIORITY__' + n;
-								value from/members/n/priority | string:1;
-								disabled not:fdom/prioritied | nothing" />
+								value python: ('members' in fdom and n in fdom['members'] and 'priority' in fdom['members'][n]) and fdom['members'][n]['priority'] or '1';
+								disabled python: (not fdom or not 'prioritized' in fdom or fdom['prioritized'] != '1' or not 'members' in fdom or not n in fdom['members']) and 'disabled' or ''" />
 					</td>
 				</tr>
 			</tal:block>
@@ -4424,11 +4426,13 @@
 	<script type="text/javascript">
 		set_page_title('Luci ??? cluster ??? failover domains ??? Configure a failover domain');
 	</script>
-	<h2>Failover Domain Configuration Form</h2>
 </div>
 
 <div metal:define-macro="fdom-form">
 	<h2>Failover Domain Form</h2>
+	<tal:block tal:define="fdom python:here.getFdomInfo(modelb, request)">
+		<tal:block metal:use-macro="here/form-macros/macros/fdom-macro" />
+	</tal:block>
 </div>
 
 <div metal:define-macro="fdomprocess-form">
--- conga/luci/cluster/validate_fdom.js	2007/02/08 02:34:35	1.2
+++ conga/luci/cluster/validate_fdom.js	2007/02/08 03:42:58	1.3
@@ -31,6 +31,10 @@
 	if (error_dialog(errors))
 		return (-1);
 
-	if (confirm('Add this failover domain?'))
+	var confirm_msg = 'Add this failover domain?';
+	if (form.oldname)
+		confirm_msg = 'Update this failover domain?';
+
+	if (confirm(confirm_msg))
 		form.submit();
 }
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/08 02:34:36	1.233
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/08 03:42:58	1.234
@@ -2013,19 +2013,26 @@
 
 def validateFdom(self, request):
 	errors = list()
-	model = request.SESSION.get('model')
+
+	try:
+		model = request.SESSION.get('model')
+		if not model:
+			raise Exception, 'no model'
+	except Exception, e:
+		luci_log.debug_verbose('validateFdom0: no model: %s' % str(e))
+		return (False, {'errors': [ 'Unable to retrieve cluster information.' ]})
 
 	prioritized = False
 	try:
 		prioritized = request.form.has_key('prioritized')
 	except:
-		pass
+		prioritized = False
 
 	restricted = False
 	try:
 		restricted = request.form.has_key('restricted')
 	except:
-		pass
+		restricted = False
 
 	clustername = None
 	try:
@@ -2069,12 +2076,14 @@
 		if fdom is None:
 			luci_log.debug_verbose('validateFdom1: No fdom named %s exists' % oldname)
 			errors.append('No failover domain named \"%s" exists.' % oldname)
-		fdom.children = list()
+		else:
+			fdom.addAttribute('name', name)
+			fdom.children = list()
 	else:
 		fdom = FailoverDomain()
 		fdom.addAttribute('name', name)
 
-	if fdom is None:
+	if fdom is None or len(errors) > 0:
 		return (False, {'errors': errors })
 
 	if prioritized:
@@ -2106,7 +2115,8 @@
 
 	try:
 		fdom_ptr = model.getFailoverDomainPtr()
-		fdom_ptr.addChild(fdom)
+		if not oldname:
+			fdom_ptr.addChild(fdom)
 		model.setModified(True)
 		conf = str(model.exportModelAsString())
 	except Exception, e:
@@ -2128,12 +2138,15 @@
 		return (False, {'errors': [ 'An error occurred while constructing the new cluster configuration.' ]})
 
 	try:
-		set_node_flag(self, clustername, ragent, str(batch_number), FDOM_ADD, 'Creating failover domain \"%s\"' % name)
+		if oldname:
+			set_node_flag(self, clustername, ragent, str(batch_number), FDOM, 'Updating failover domain \"%s\"' % oldname)
+		else:
+			set_node_flag(self, clustername, ragent, str(batch_number), FDOM_ADD, 'Creating failover domain \"%s\"' % name)
 	except Exception, e:
 		luci_log.debug_verbose('validateFdom5: failed to set flags: %s' % str(e))
 
 	response = request.RESPONSE
-	response.redirect(request['URL'] + "?pagetype=" + FDOM_CONFIG + "&clustername=" + clustername + '&fdomname=' + name + '&busyfirst=true')
+	response.redirect(request['URL'] + "?pagetype=" + FDOM + "&clustername=" + clustername + '&fdomname=' + name + '&busyfirst=true')
 
 def validateVM(self, request):
 	errors = list()
@@ -2249,6 +2262,7 @@
 	31: validateResourceAdd,
 	33: validateResourceAdd,
 	41: validateFdom,
+	44: validateFdom,
 	51: validateFenceAdd,
 	54: validateFenceEdit,
 	55: validateDaemonProperties,
@@ -3496,6 +3510,39 @@
 	response = req.RESPONSE
 	response.redirect(req['URL'] + "?pagetype=" + SERVICE_LIST + "&clustername=" + cluname + '&busyfirst=true')
 
+def getFdomInfo(self, model, request):
+	fhash = {}
+	fhash['members'] = {}
+
+	try:
+		fdom = model.getFailoverDomainByName(request['fdomname'])
+	except Exception, e:
+		luci_log.debug_verbose('getFdomInfo0: %s' % str(e))
+		return fhash
+
+	fhash['name'] = fdom.getName()
+
+	ordered_attr = fdom.getAttribute('ordered')
+	if ordered_attr is not None and (ordered_attr == "true" or ordered_attr == "1"):
+		fhash['prioritized'] = '1'
+	else:
+		fhash['prioritized'] = '0'
+
+	restricted_attr = fdom.getAttribute('restricted')
+	if restricted_attr is not None and (restricted_attr == "true" or restricted_attr == "1"):
+		fhash['restricted'] = '1'
+	else:
+		fhash['restricted'] = '0'
+
+	nodes = fdom.getChildren()
+	for node in nodes:
+		try:
+			priority = node.getAttribute('priority')
+		except:
+			priority = '1'
+		fhash['members'][node.getName()] = { 'priority': priority }
+	return fhash
+
 def getFdomsInfo(self, model, request, clustatus):
   slist = list()
   nlist = list()
@@ -3512,7 +3559,7 @@
   for fdom in fdoms:
     fdom_map = {}
     fdom_map['name'] = fdom.getName()
-    fdom_map['cfgurl'] = baseurl + "?pagetype=" + FDOM_LIST + "&clustername=" + clustername
+    fdom_map['cfgurl'] = baseurl + "?pagetype=" + FDOM + "&clustername=" + clustername + '&fdomname=' + fdom.getName()
     ordered_attr = fdom.getAttribute('ordered')
     restricted_attr = fdom.getAttribute('restricted')
     if ordered_attr is not None and (ordered_attr == "true" or ordered_attr == "1"):



             reply	other threads:[~2007-02-08  3:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08  3:43 rmccabe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-08-24 22:01 [Cluster-devel] conga/luci cluster/form-macros cluster/validat rmccabe
2007-08-24 21:55 rmccabe
2007-08-24 18:42 rmccabe
2007-08-24 18:40 rmccabe
2007-08-09  4:37 rmccabe
2007-08-09  4:34 rmccabe
2007-02-24  7:02 rmccabe
2007-02-16  5:29 rmccabe
2007-02-16  5:26 rmccabe
2007-02-12 23:28 rmccabe
2007-02-12 23:26 rmccabe
2007-02-09 18:32 rmccabe
2007-02-09 18:30 rmccabe
2007-02-08  2:34 rmccabe
2007-02-01 23:48 rmccabe
2007-01-25 19:55 rmccabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070208034300.9744.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.