All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-09 18:32 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-09 18:32 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL4
Changes by:	rmccabe at sourceware.org	2007-02-09 18:32:04

Modified files:
	luci/cluster   : form-macros validate_fence.js 
	luci/homebase  : form-macros homebase_common.js 
	                 validate_cluster_add.js 
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	don't let passwords get into the server's html output

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.176.2.6&r2=1.176.2.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_fence.js.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3&r2=1.3.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/form-macros.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.55&r2=1.55.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.16&r2=1.16.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_cluster_add.js.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.7&r2=1.7.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.48&r2=1.48.2.1

--- conga/luci/cluster/form-macros	2007/02/08 15:59:20	1.176.2.6
+++ conga/luci/cluster/form-macros	2007/02/09 18:32:03	1.176.2.7
@@ -275,7 +275,8 @@
 					<ul class="vanilla">
 						<li class="vanilla">
 							<input name="check_certs" type="checkbox"
-								tal:attributes="checked python: (add_cluster and add_cluster['check_certs']) and 'checked'" />
+								id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)" />
 							View system certificates before sending any passwords.
 						</li>
 						<li class="vanilla">
@@ -404,7 +405,7 @@
 								onChange="pwd0Change(this.form)"
 								autocomplete="off"
 								tal:attributes="
-									value sys/passwd | nothing;
+									value nothing;
 									class python: 'hbInputPass' + ('errors' in sys and ' error' or '');
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum" />
@@ -1485,7 +1486,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1543,7 +1544,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1592,7 +1593,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1642,7 +1643,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1691,7 +1692,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 		</table>
 
@@ -1739,7 +1740,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1796,7 +1797,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1854,7 +1855,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1903,7 +1904,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -2042,7 +2043,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -2100,7 +2101,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -2254,7 +2255,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 			</tr>
 			<tr>
@@ -3567,7 +3568,8 @@
 					<ul class="vanilla">
 						<li class="vanilla">
 							<input name="check_certs" type="checkbox"
-								tal:attributes="checked python: (add_cluster and add_cluster['check_certs']) and 'checked'" />
+								id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)" />
 							View system certificates before sending any passwords.
 						</li>
 						<li class="vanilla"
@@ -3608,7 +3610,7 @@
 								autocomplete="off"
 								onChange="pwd0Change(this.form)"
 								tal:attributes="
-									value sys/passwd | nothing;
+									value nothing;
 									class python: 'hbInputPass' + ('errors' in sys and ' error' or '');
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum" />
--- conga/luci/cluster/validate_fence.js	2007/01/25 21:03:47	1.3
+++ conga/luci/cluster/validate_fence.js	2007/02/09 18:32:03	1.3.2.1
@@ -50,6 +50,14 @@
 	return (null);
 }
 
+function validate_field_passwd(form_elem) {
+	if (form_elem.disabled) {
+		clr_form_err(form_elem);
+		return (null);
+	}
+	return validate_field_str(form_elem);
+}
+
 /* Very loose checking for now -- just make sure it's not blank */
 function validate_field_host(form_elem) {
 	return (validate_field_str(form_elem));
@@ -82,7 +90,7 @@
 field_validator['ipaddr'] = validate_field_host;
 field_validator['hostname'] = validate_field_host;
 field_validator['login'] = validate_field_str;
-field_validator['passwd'] = validate_field_str;
+field_validator['passwd'] = validate_field_passwd;
 field_validator['servers'] = validate_field_str;
 field_validator['cserver'] = validate_field_str;
 field_validator['device'] = validate_field_str;
--- conga/luci/homebase/form-macros	2007/01/29 20:43:29	1.55
+++ conga/luci/homebase/form-macros	2007/02/09 18:32:03	1.55.2.1
@@ -373,7 +373,7 @@
 								tal:attributes="
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum;
-									value sys/passwd | nothing" />
+									value nothing" />
 						</td>
 						<td class="systemsTable">
 							<img 
@@ -413,7 +413,10 @@
 			<tfoot class="systemsTable">
 				<tr class="systemsTable"><td colspan="2" class="systemsTable">
 					<ul class="vanilla">
-						<li class="vanilla"><input name="check_certs" type="checkbox">View system certificates before sending any passwords.</li>
+						<li class="vanilla">
+							<input name="check_certs" id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)"
+								type="checkbox">View system certificates before sending any passwords.</li>
 						<li class="vanilla"
 							tal:attributes="id python: cur_sysnum < 2 and 'allSameDiv' or ''">
 							<input type="checkbox" name="allSameCheckBox"
@@ -666,7 +669,7 @@
 								tal:attributes="
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum;
-									value sys/passwd | nothing" />
+									value nothing" />
 									
 						</td>
 						<td class="systemsTable">
@@ -707,7 +710,10 @@
 			<tfoot class="systemsTable">
 				<tr class="systemsTable"><td colspan="2" class="systemsTable">
 					<ul class="vanilla">
-						<li class="vanilla"><input name="check_certs" type="checkbox">View system certificates before sending any passwords.</li>
+						<li class="vanilla">
+							<input name="check_certs" id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)"
+								type="checkbox">View system certificates before sending any passwords.</li>
 						<li class="vanilla"
 							tal:attributes="id python: cur_sysnum < 2 and 'allSameDiv' or ''"><input type="checkbox" name="allSameCheckBox" id="allSameCheckBox" onClick="allPasswdsSame(this.form);"/>Check if storage system passwords are identical.</li>
 					</ul>
@@ -804,7 +810,8 @@
 					<ul class="vanilla">
 						<li class="vanilla">
 							<input name="check_certs" type="checkbox"
-								tal:attributes="checked python: add_cluster['check_certs'] and 'checked'" />
+								id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)" />
 							View system certificates before sending any passwords.
 						</li>
 						<li class="vanilla" id="allSameDiv">
@@ -848,7 +855,7 @@
 								autocomplete="off"
 								onChange="pwd0Change(this.form)"
 								tal:attributes="
-									value sys/passwd | nothing;
+									value nothing;
 									class python: 'hbInputPass' + ('errors' in sys and ' error' or '');
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum" />
@@ -956,8 +963,11 @@
 						tal:condition="cur_sys" />
 
 					<ul class="vanilla">
-						<li class="vanilla"><input name="check_certs" type="checkbox">View system certificates before sending any passwords.</li>
-						<li class="vanilla"><input type="checkbox" name="allSameCheckBox" id="allSameCheckBox" onClick="allPasswdsSame(this.form);"/>Authenticate to all cluster nodes using the password provided above.</li>
+						<li class="vanilla">
+							<input name="check_certs" id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)"
+								type="checkbox">View system certificates before sending any passwords.
+						</li>
 					</ul>
 				</td></tr>
 			</tfoot>
@@ -976,7 +986,7 @@
 							autocomplete="off"
 							id="__SYSTEM0:Passwd" name="__SYSTEM0:Passwd"
 							tal:attributes="
-								value cur_sys/passwd | nothing" />
+								value nothing" />
 					</td>
 					<tal:block tal:condition="cur_sys">
 						<td class="systemsTable">
--- conga/luci/homebase/homebase_common.js	2007/01/25 21:03:47	1.16
+++ conga/luci/homebase/homebase_common.js	2007/02/09 18:32:03	1.16.2.1
@@ -132,6 +132,26 @@
 	return (null);
 }
 
+function view_certs_only(form, state) {
+	var num_systems = form.numStorage.value;
+	if (!form.numStorage)
+		return (-1);
+
+	if (state) {
+		var cb = document.getElementById('allSameCheckBox');
+		if (cb && cb.checked)
+			cb.checked = false;
+	}
+
+	for (var i = 0 ; i < num_systems ; i++) {
+		var passwd = document.getElementById('__SYSTEM' + i + ':Passwd');
+		if (passwd) {
+			passwd.value = "";
+			passwd.disabled = state;
+		}
+	}
+}
+
 function allPasswdsSame(form) {
 	var cb = document.getElementById('allSameCheckBox');
 	if (!cb)
@@ -252,6 +272,12 @@
 	var added_storage = new Array();
 	var num_systems = form.numStorage.value;
 
+	var view_certs = document.getElementById('view_certs');
+	if (view_certs)
+		view_certs = view_certs.checked;
+	else
+		view_certs = false;
+
 	for (var i = 0 ; i < num_systems ; i++) {
 		var element = document.getElementById('__SYSTEM' + i + ':Addr');
 
@@ -260,18 +286,31 @@
 		element.disabled = false;
 
 		var pwdElem = document.getElementById('__SYSTEM' + i + ':Passwd');
-		if (!element.value) {
-			if (pwdElem.value) {
+		if (!element.value || str_is_blank(element.value)) {
+			if (pwdElem && pwdElem.value && !str_is_blank(pwdElem.value)) {
 				set_form_err(element);
-				if (!allSameCB.checked) {
+				if (!allSameCB || !allSameCB.checked) {
 					errors.push('You entered a password, but no hostname for system ' + (i + 1));
 					clr_form_err(pwdElem);
 				} else
 					pwdElem.value = '';
 			}
-			clr_form_err(pwdElem);
+			if (pwdElem)
+				clr_form_err(pwdElem);
+			continue;
+		}
+
+		if (view_certs) {
+			if (pwdElem) {
+				pwdElem.value = ' ';
+				pwdElem.disabled = false;
+			}
+			added_storage.push(element.value);
+			clr_form_err(element);
 			continue;
-		} else if (!pwdElem || !pwdElem.value) {
+		}
+
+		if (!pwdElem || !pwdElem.value) {
 			errors.push('No password was given for \"' + element.value + '\"');
 			set_form_err(pwdElem);
 		} else if (str_is_blank(pwdElem.value)) {
--- conga/luci/homebase/validate_cluster_add.js	2007/01/29 16:56:50	1.7
+++ conga/luci/homebase/validate_cluster_add.js	2007/02/09 18:32:03	1.7.2.1
@@ -34,13 +34,17 @@
 	if (error_dialog(errors))
 		return (-1);
 
-	var confirm_str = '';
-	if (form.addnode)
-		confirm_str = 'Add ' + (added_storage.length > 1 ? 'these nodes' : 'this node') + ' to the \"' + clusterName + '\" cluster?';
-	else
-		confirm_str = 'Add the cluster \"' + clusterName + '\" to the Luci management interface?';
+	var view_certs = document.getElementById('view_certs');
+	if (!view_certs || !view_certs.checked) {
+		var confirm_str = '';
+		if (form.addnode)
+			confirm_str = 'Add ' + (added_storage.length > 1 ? 'these nodes' : 'this node') + ' to the \"' + clusterName + '\" cluster?';
+		else
+			confirm_str = 'Add the cluster \"' + clusterName + '\" to the Luci management interface?';
 
-	if (confirm(confirm_str))
+		if (confirm(confirm_str))
+			form.submit();
+	} else
 		form.submit();
 
 	return (0);
--- conga/luci/site/luci/Extensions/homebase_adapters.py	2007/01/29 23:30:00	1.48
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2007/02/09 18:32:04	1.48.2.1
@@ -156,7 +156,7 @@
 		if len(sysData) < 2 or not sysData[1]:
 			raise Exception, 'no password'
 		cur_pass = sysData[1]
-		cur_entry['passwd'] = cur_pass
+		cur_entry['passwd'] = ''
 	except:
 		luci_log.debug_verbose('vACI1: %s no password given')
 		request.SESSION.set('add_cluster_initial', cur_entry)
@@ -338,7 +338,7 @@
 	for i in node_list:
 		cur_node = { 'host': i }
 		if same_node_passwds:
-			cur_node['passwd'] = cur_pass
+			cur_node['passwd'] = ''
 		add_cluster['nodes'][i] = cur_node
 	request.SESSION.set('add_cluster', add_cluster)
 	request.response.redirect('/luci/homebase/index_html?pagetype=%s' % HOMEBASE_ADD_CLUSTER)
@@ -382,7 +382,7 @@
 			cur_passwd = None
 		else:
 			cur_passwd = sysData[1]
-			cur_system['passwd'] = cur_passwd
+			cur_system['passwd'] = ''
 
 		try:
 			cur_fp = request.form['__SYSTEM%dFingerprint' % i].strip()



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-08-24 22:01 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-08-24 22:01 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-08-24 22:01:45

Modified files:
	luci/cluster   : form-macros validate_config_multicast.js 
	                 validate_config_qdisk.js 
	luci/site/luci/Extensions: LuciClusterInfo.py 
	                           cluster_adapters.py 
	luci/site/luci/Extensions/ClusterModel: ModelBuilder.py 

Log message:
	qdisk and multicast configuration fixes from the RHEL4 branch

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.209&r2=1.210
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_multicast.js.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_qdisk.js.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.268&r2=1.269
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&r1=1.6&r2=1.7

--- conga/luci/cluster/form-macros	2007/08/24 18:42:06	1.209
+++ conga/luci/cluster/form-macros	2007/08/24 22:01:41	1.210
@@ -1082,7 +1082,7 @@
 				<tr class="systemsTable">
 					<td class="systemsTable">
 						<input type="radio" name="mcast" value="False"
-							onClick="disable_mcast('mcast_address');"
+							onClick="disable_mcast('mcast_address', 'mcast_interface');"
 							tal:attributes="checked python: clusterinfo['is_mcast'] != 'True'"
 						/>
 						<tal:block tal:condition="python:os_version == 'rhel4'">
@@ -1097,7 +1097,7 @@
 				<tr class="systemsTable">
 					<td class="systemsTable">
 						<input type="radio" name="mcast" value="True"
-							onClick="enable_mcast('mcast_address');"
+							onClick="enable_mcast('mcast_address', 'mcast_interface');"
 							tal:attributes="checked python: clusterinfo['is_mcast'] == 'True'"
 
 						/>
@@ -1122,6 +1122,18 @@
 								value clusterinfo/mcast_addr |nothing" />
 					</td>
 				</tr>
+				<tr class="systemsTable">
+					<td class="systemsTable">
+						Multicast network interface <span tal:condition="python:os_version != 'rhel4'">(optional)</span>
+					</td>
+					<td class="systemsTable">
+						<input type="text"
+							name="mcast_interface" id="mcast_interface"
+							tal:attributes="
+								disabled not:clusterinfo/mcast_addr;
+								value clusterinfo/mcast_interface |nothing" />
+					</td>
+				</tr>
 			</tbody>
 
 			<tfoot class="systemsTable">
--- conga/luci/cluster/validate_config_multicast.js	2007/08/24 18:42:06	1.5
+++ conga/luci/cluster/validate_config_multicast.js	2007/08/24 22:01:41	1.6
@@ -8,24 +8,36 @@
 */
 
 var prev_mcast_str = '';
+var prev_mcast_if = '';
 
-function disable_mcast(addrId) {
-	addrObj = document.getElementById(addrId);
-	if (!addrObj) {
-		return;
-	}
-	addrObj.disabled = true;
-	prev_mcast_str = addrObj.value;
-	addrObj.value = '';
+function disable_mcast(addrId, ifId) {
+	var addrObj = document.getElementById(addrId);
+	if (addrObj) {
+		prev_mcast_str = addrObj.value;
+		addrObj.disabled = true;
+		addrObj.value = '';
+	}
+
+	var ifObj = document.getElementById(ifId);
+	if (ifObj) {
+		prev_mcast_if = ifObj.value;
+		ifObj.disabled = true;
+		ifObj.value = '';
+	}
 }
 
-function enable_mcast(addrId) {
-	addrObj = document.getElementById(addrId);
-	if (!addrObj) {
-		return;
+function enable_mcast(addrId, ifId) {
+	var addrObj = document.getElementById(addrId);
+	if (addrObj) {
+		addrObj.disabled = false;
+		addrObj.value = prev_mcast_str;
+	}
+
+	var ifObj = document.getElementById(ifId);
+	if (ifObj) {
+		ifObj.disabled = false;
+		ifObj.value = prev_mcast_if; 
 	}
-	addrObj.disabled = false;
-	addrObj.value = prev_mcast_str;
 }
 
 function validate_form(form) {
@@ -54,6 +66,7 @@
 		clr_form_err(form.mcast[0]);
 		clr_form_err(form.mcast[1]);
 		clr_form_err(form.mcast_address);
+		clr_form_err(form.mcast_interface);
 	}
 
 	if (mcast == 1) {
@@ -68,6 +81,15 @@
 			}
 			clr_form_err(form.mcast_address);
 		}
+
+		if (form.cluster_version && form.cluster_version.value == 'rhel4') {
+			if (!form.mcast_interface || str_is_blank(form.mcast_interface.value)) {
+				set_form_err(form.mcast_interface);
+				errors.push('No multicast interface was given.');
+			} else {
+				clr_form_err(form.mcast_interface);
+			}
+		}
 	}
 
 	if (error_dialog(errors))
--- conga/luci/cluster/validate_config_qdisk.js	2007/08/08 21:00:06	1.8
+++ conga/luci/cluster/validate_config_qdisk.js	2007/08/24 22:01:41	1.9
@@ -180,17 +180,6 @@
 				clr_form_err(form.interval);
 		}
 
-		if (!form.votes || str_is_blank(form.votes.value)) {
-			errors.push('No votes setting was given.');
-			set_form_err(form.votes);
-		} else {
-			if (!is_valid_int(form.votes.value, 1, null)) {
-				errors.push('Votes values must be greater than 0.');
-				set_form_err(form.votes);
-			} else
-				clr_form_err(form.votes);
-		}
-
 		if (!form.tko || str_is_blank(form.tko.value)) {
 			errors.push('No TKO setting was given.');
 			set_form_err(form.tko);
@@ -202,15 +191,15 @@
 				clr_form_err(form.tko);
 		}
 
-		if (!form.min_score || str_is_blank(form.min_score.value)) {
-			errors.push('No minimum score setting was given.');
-			set_form_err(form.min_score);
+		if (!form.votes || str_is_blank(form.votes.value)) {
+			errors.push('No votes setting was given.');
+			set_form_err(form.votes);
 		} else {
-			if (!is_valid_int(form.min_score.value, 1, null)) {
-				errors.push('Minimum score values must be greater than 0.');
-				set_form_err(form.min_score);
+			if (!is_valid_int(form.votes.value, 1, null)) {
+				errors.push('Votes values must be greater than 0.');
+				set_form_err(form.votes);
 			} else
-				clr_form_err(form.min_score);
+				clr_form_err(form.votes);
 		}
 
 		var no_dev = !form.device || str_is_blank(form.device.value);
@@ -226,6 +215,23 @@
 				if (err)
 					errors = errors.concat(err);
 			}
+
+			if (hnum > 1) {
+				if (!form.min_score || str_is_blank(form.min_score.value)) {
+					errors.push('No minimum score setting was given.');
+					set_form_err(form.min_score);
+				} else {
+					if (!is_valid_int(form.min_score.value, 1, null)) {
+						errors.push('Minimum score values must be greater than 0.');
+						set_form_err(form.min_score);
+					} else
+						clr_form_err(form.min_score);
+				}
+			} else {
+				clr_form_err(form.min_score);
+			}
+		} else {
+			clr_form_err(form.min_score);
 		}
 	}
 
--- conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/08/24 18:42:06	1.11
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/08/24 22:01:42	1.12
@@ -618,9 +618,11 @@
 		is_mcast = model.isMulticast()
 		if is_mcast:
 			clumap['mcast_addr'] = model.getMcastAddr()
+			clumap['mcast_interface'] = model.getMcastInterface()
 			clumap['is_mcast'] = 'True'
 		else:
 			clumap['mcast_addr'] = None
+			clumap['mcast_interface'] = None
 			clumap['is_mcast'] = 'False'
 		clumap['gulm'] = False
 	else:
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/24 18:42:06	1.268
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/24 22:01:42	1.269
@@ -974,6 +974,14 @@
 		errors.append('An invalid multicast selection was made')
 		return (False, {'errors': errors})
 
+	mcast_interface = None
+	if form.has_key('mcast_interface'):
+		mcast_interface = form['mcast_interface'].strip()
+
+	if mcast_manual is True and form.has_key('cluster_version') and form['cluster_version'].strip() == 'rhel4' and not mcast_interface:
+		errors.append('No multicast interface was specified')
+		return (False, {'errors': errors})
+
 	if mcast_manual is True:
 		import socket
 		try:
@@ -992,20 +1000,13 @@
 		addr_str = None
 
 	try:
-		old_mcast_addr = model.getMcastAddr()
-	except Exception, e:
-		luci_log.debug_verbose('VMCC0: %r %s' % (e, str(e)))
-		old_mcast_addr = None
-
-	if (addr_str is None and mcast_manual is not True and not old_mcast_addr) or (mcast_manual is True and addr_str == old_mcast_addr):
-		errors.append('No multicast configuration changes were made')
-		return (False, {'errors': errors})
-
-	try:
-		if model.getMcastAddr() is not None and not addr_str:
+		if not addr_str:
+			if mcast_interface:
+				errors.append('A multicast interface was specified, but no multicast address was given')
+				return (False, {'errors': errors})
 			model.del_cluster_multicast()
 		else:
-			model.set_cluster_multicast(addr_str)
+			model.set_cluster_multicast(addr_str, mcast_if=mcast_interface)
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug('Error updating mcast properties: %r %s' \
@@ -1108,7 +1109,7 @@
 	for i in xrange(num_heuristics):
 		try:
 			h = form['heuristic%d' % i]
-			if not h or len(h) != 3:
+			if not h or len(h) != 3 or not (h[0].strip() and h[1].strip() and h[2].strip()):
 				continue
 		except:
 			continue
@@ -1118,26 +1119,26 @@
 			if not hprog:
 				raise Exception, 'no hprog'
 		except Exception, e:
-			errors.append('No program was given for heuristic %d' % i + 1)
+			errors.append('No program was given for heuristic %d' % (i + 1))
 		try:
 			hint = int(h[1])
 			if hint < 1:
 				raise ValueError, 'Heuristic interval values must be greater than 0'
 		except KeyError, e:
-			errors.append('No interval was given for heuristic %d' % i + 1)
+			errors.append('No interval was given for heuristic %d' % (i + 1))
 		except ValueError, e:
 			errors.append('An invalid interval was given for heuristic %d: %s' \
-				% (i + 1, str(e)))
+				% ((i + 1), str(e)))
 
 		try:
 			hscore = int(h[2])
 			if hscore < 1:
 				raise ValueError, 'Heuristic scores must be greater than 0'
 		except KeyError, e:
-			errors.append('No score was given for heuristic %d' % i + 1)
+			errors.append('No score was given for heuristic %d' % (i + 1))
 		except ValueError, e:
 			errors.append('An invalid score was given for heuristic %d: %s' \
-				% (i + 1, str(e)))
+				% ((i + 1), str(e)))
 
 		heuristics.append([ hprog, hint, hscore ])
 
--- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/08/24 18:42:06	1.6
+++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/08/24 22:01:42	1.7
@@ -682,17 +682,23 @@
       children = self.CMAN_ptr.getChildren()
       for child in children:
         if child.getTagName() == MCAST_STR:
+          self.mcast_ptr = child
           addr = child.getAttribute("addr")
           if addr is not None:
             self.mcast_address = addr
-            return
           else:  #What a mess! a multicast tag, but no addr attribute
             self.mcast_address = ""
-            return
+          mcastif = child.getAttribute("interface")
+          if mcastif is not None:
+            self.mcast_interface = mcastif
+          return
 
   def getMcastAddr(self):
     return self.mcast_address
 
+  def getMcastInterface(self):
+    return self.mcast_interface
+
   def isQuorumd(self):
     return self.usesQuorumd
 
@@ -877,6 +883,8 @@
 
       self.usesMulticast = None
       self.mcast_address = None
+      self.mcast_interface = None
+      self.mcast_ptr = None
 
       #reset self.lock_type
       self.lock_type = GULM_TYPE
@@ -985,7 +993,7 @@
     for child in iter(self.CMAN_ptr.getChildren()):
       if child.getTagName() == MCAST_STR:
         self.CMAN_ptr.removeChild(child)
-        break
+
     self.mcast_ptr = None
     self.usesMulticast = False
     self.mcast_address = None



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-08-24 21:55 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-08-24 21:55 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL4
Changes by:	rmccabe at sourceware.org	2007-08-24 21:55:44

Modified files:
	luci/cluster   : form-macros validate_config_multicast.js 
	luci/site/luci/Extensions: LuciClusterInfo.py 
	                           cluster_adapters.py 
	luci/site/luci/Extensions/ClusterModel: ModelBuilder.py 

Log message:
	When using multicast on a rhel4 cluster, a network interface must be specified.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.176.2.20&r2=1.176.2.21
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_multicast.js.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.4.2&r2=1.3.4.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.10.2.2&r2=1.10.2.3
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.23&r2=1.227.2.24
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.5.2.2&r2=1.5.2.3

--- conga/luci/cluster/form-macros	2007/08/24 18:40:28	1.176.2.20
+++ conga/luci/cluster/form-macros	2007/08/24 21:55:42	1.176.2.21
@@ -1082,7 +1082,7 @@
 				<tr class="systemsTable">
 					<td class="systemsTable">
 						<input type="radio" name="mcast" value="False"
-							onClick="disable_mcast('mcast_address');"
+							onClick="disable_mcast('mcast_address', 'mcast_interface');"
 							tal:attributes="checked python: clusterinfo['is_mcast'] != 'True'"
 						/>
 						<tal:block tal:condition="python:os_version == 'rhel4'">
@@ -1097,7 +1097,7 @@
 				<tr class="systemsTable">
 					<td class="systemsTable">
 						<input type="radio" name="mcast" value="True"
-							onClick="enable_mcast('mcast_address');"
+							onClick="enable_mcast('mcast_address', 'mcast_interface');"
 							tal:attributes="checked python: clusterinfo['is_mcast'] == 'True'"
 
 						/>
@@ -1122,6 +1122,18 @@
 								value clusterinfo/mcast_addr |nothing" />
 					</td>
 				</tr>
+				<tr class="systemsTable">
+					<td class="systemsTable">
+						Multicast network interface <span tal:condition="python:os_version != 'rhel4'">(optional)</span>
+					</td>
+					<td class="systemsTable">
+						<input type="text"
+							name="mcast_interface" id="mcast_interface"
+							tal:attributes="
+								disabled not:clusterinfo/mcast_addr;
+								value clusterinfo/mcast_interface |nothing" />
+					</td>
+				</tr>
 			</tbody>
 
 			<tfoot class="systemsTable">
@@ -1194,18 +1206,18 @@
 			</tr>
 
 			<tr class="systemsTable">
-				<td class="systemsTable">TKO</td>
+				<td class="systemsTable">Votes</td>
 				<td class="systemsTable">
-					<input type="text" name="tko"
-						tal:attributes="value clusterinfo/tko | nothing" />
+					<input type="text" name="votes"
+						tal:attributes="value clusterinfo/votes | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
-				<td class="systemsTable">Votes</td>
+				<td class="systemsTable">TKO</td>
 				<td class="systemsTable">
-					<input type="text" name="votes"
-						tal:attributes="value clusterinfo/votes | nothing" />
+					<input type="text" name="tko"
+						tal:attributes="value clusterinfo/tko | nothing" />
 				</td>
 			</tr>
 
--- conga/luci/cluster/validate_config_multicast.js	2007/08/24 18:40:28	1.3.4.2
+++ conga/luci/cluster/validate_config_multicast.js	2007/08/24 21:55:42	1.3.4.3
@@ -8,24 +8,36 @@
 */
 
 var prev_mcast_str = '';
+var prev_mcast_if = '';
 
-function disable_mcast(addrId) {
-	addrObj = document.getElementById(addrId);
-	if (!addrObj) {
-		return;
-	}
-	addrObj.disabled = true;
-	prev_mcast_str = addrObj.value;
-	addrObj.value = '';
+function disable_mcast(addrId, ifId) {
+	var addrObj = document.getElementById(addrId);
+	if (addrObj) {
+		prev_mcast_str = addrObj.value;
+		addrObj.disabled = true;
+		addrObj.value = '';
+	}
+
+	var ifObj = document.getElementById(ifId);
+	if (ifObj) {
+		prev_mcast_if = ifObj.value;
+		ifObj.disabled = true;
+		ifObj.value = '';
+	}
 }
 
-function enable_mcast(addrId) {
-	addrObj = document.getElementById(addrId);
-	if (!addrObj) {
-		return;
+function enable_mcast(addrId, ifId) {
+	var addrObj = document.getElementById(addrId);
+	if (addrObj) {
+		addrObj.disabled = false;
+		addrObj.value = prev_mcast_str;
+	}
+
+	var ifObj = document.getElementById(ifId);
+	if (ifObj) {
+		ifObj.disabled = false;
+		ifObj.value = prev_mcast_if; 
 	}
-	addrObj.disabled = false;
-	addrObj.value = prev_mcast_str;
 }
 
 function validate_form(form) {
@@ -54,6 +66,7 @@
 		clr_form_err(form.mcast[0]);
 		clr_form_err(form.mcast[1]);
 		clr_form_err(form.mcast_address);
+		clr_form_err(form.mcast_interface);
 	}
 
 	if (mcast == 1) {
@@ -68,6 +81,15 @@
 			}
 			clr_form_err(form.mcast_address);
 		}
+
+		if (form.cluster_version && form.cluster_version.value == 'rhel4') {
+			if (!form.mcast_interface || str_is_blank(form.mcast_interface.value)) {
+				set_form_err(form.mcast_interface);
+				errors.push('No multicast interface was given.');
+			} else {
+				clr_form_err(form.mcast_interface);
+			}
+		}
 	}
 
 	if (error_dialog(errors))
--- conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/08/24 18:40:29	1.10.2.2
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/08/24 21:55:42	1.10.2.3
@@ -618,9 +618,11 @@
 		is_mcast = model.isMulticast()
 		if is_mcast:
 			clumap['mcast_addr'] = model.getMcastAddr()
+			clumap['mcast_interface'] = model.getMcastInterface()
 			clumap['is_mcast'] = 'True'
 		else:
 			clumap['mcast_addr'] = None
+			clumap['mcast_interface'] = None
 			clumap['is_mcast'] = 'False'
 		clumap['gulm'] = False
 	else:
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/24 18:40:29	1.227.2.23
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/24 21:55:42	1.227.2.24
@@ -983,6 +983,14 @@
 		errors.append('An invalid multicast selection was made')
 		return (False, {'errors': errors})
 
+	mcast_interface = None
+	if form.has_key('mcast_interface'):
+		mcast_interface = form['mcast_interface'].strip()
+
+	if mcast_manual is True and form.has_key('cluster_version') and form['cluster_version'].strip() == 'rhel4' and not mcast_interface:
+		errors.append('No multicast interface was specified')
+		return (False, {'errors': errors})
+
 	if mcast_manual is True:
 		import socket
 		try:
@@ -1001,20 +1009,13 @@
 		addr_str = None
 
 	try:
-		old_mcast_addr = model.getMcastAddr()
-	except Exception, e:
-		luci_log.debug_verbose('VMCC0: %r %s' % (e, str(e)))
-		old_mcast_addr = None
-
-	if (addr_str is None and mcast_manual is not True and not old_mcast_addr) or (mcast_manual is True and addr_str == old_mcast_addr):
-		errors.append('No multicast configuration changes were made')
-		return (False, {'errors': errors})
-
-	try:
-		if model.getMcastAddr() is not None and not addr_str:
+		if not addr_str:
+			if mcast_interface:
+				errors.append('A multicast interface was specified, but no multicast address was given')
+				return (False, {'errors': errors})
 			model.del_cluster_multicast()
 		else:
-			model.set_cluster_multicast(addr_str)
+			model.set_cluster_multicast(addr_str, mcast_if=mcast_interface)
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug('Error updating mcast properties: %r %s' \
--- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/08/24 18:40:29	1.5.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/08/24 21:55:43	1.5.2.3
@@ -682,17 +682,23 @@
       children = self.CMAN_ptr.getChildren()
       for child in children:
         if child.getTagName() == MCAST_STR:
+          self.mcast_ptr = child
           addr = child.getAttribute("addr")
           if addr is not None:
             self.mcast_address = addr
-            return
           else:  #What a mess! a multicast tag, but no addr attribute
             self.mcast_address = ""
-            return
+          mcastif = child.getAttribute("interface")
+          if mcastif is not None:
+            self.mcast_interface = mcastif
+          return
 
   def getMcastAddr(self):
     return self.mcast_address
 
+  def getMcastInterface(self):
+    return self.mcast_interface
+
   def isQuorumd(self):
     return self.usesQuorumd
 
@@ -877,6 +883,8 @@
 
       self.usesMulticast = None
       self.mcast_address = None
+      self.mcast_interface = None
+      self.mcast_ptr = None
 
       #reset self.lock_type
       self.lock_type = GULM_TYPE
@@ -985,7 +993,7 @@
     for child in iter(self.CMAN_ptr.getChildren()):
       if child.getTagName() == MCAST_STR:
         self.CMAN_ptr.removeChild(child)
-        break
+
     self.mcast_ptr = None
     self.usesMulticast = False
     self.mcast_address = None



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-08-24 18:42 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-08-24 18:42 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-08-24 18:42:07

Modified files:
	luci/cluster   : form-macros validate_config_multicast.js 
	luci/site/luci/Extensions: LuciClusterInfo.py 
	                           cluster_adapters.py 
	luci/site/luci/Extensions/ClusterModel: ModelBuilder.py 

Log message:
	Fix the issue described in bz253994: Cannot specify multicast address for a cluster

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.208&r2=1.209
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_multicast.js.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.267&r2=1.268
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&r1=1.5&r2=1.6

--- conga/luci/cluster/form-macros	2007/08/09 21:05:28	1.208
+++ conga/luci/cluster/form-macros	2007/08/24 18:42:06	1.209
@@ -1115,11 +1115,11 @@
 						Multicast address
 					</td>
 					<td class="systemsTable">
-						<input type="text" name="mcast_address" id="mcast_address"
+						<input type="text"
+							name="mcast_address" id="mcast_address"
 							tal:attributes="
-								disabled python: clusterinfo['is_mcast'] != 'True' and '1' or '0';
-								value python: clusterinfo['is_mcast'] == 'True' and clusterinfo['mcast_addr'] or '';"
-						/>
+								disabled not:clusterinfo/mcast_addr;
+								value clusterinfo/mcast_addr |nothing" />
 					</td>
 				</tr>
 			</tbody>
--- conga/luci/cluster/validate_config_multicast.js	2007/08/08 21:00:06	1.4
+++ conga/luci/cluster/validate_config_multicast.js	2007/08/24 18:42:06	1.5
@@ -11,8 +11,9 @@
 
 function disable_mcast(addrId) {
 	addrObj = document.getElementById(addrId);
-	if (!addrObj || addrObj.disabled)
+	if (!addrObj) {
 		return;
+	}
 	addrObj.disabled = true;
 	prev_mcast_str = addrObj.value;
 	addrObj.value = '';
@@ -20,8 +21,9 @@
 
 function enable_mcast(addrId) {
 	addrObj = document.getElementById(addrId);
-	if (!addrObj || !addrObj.disabled)
+	if (!addrObj) {
 		return;
+	}
 	addrObj.disabled = false;
 	addrObj.value = prev_mcast_str;
 }
--- conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/08/08 21:00:07	1.10
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/08/24 18:42:06	1.11
@@ -620,8 +620,8 @@
 			clumap['mcast_addr'] = model.getMcastAddr()
 			clumap['is_mcast'] = 'True'
 		else:
+			clumap['mcast_addr'] = None
 			clumap['is_mcast'] = 'False'
-			clumap['mcast_addr'] = '1.2.3.4'
 		clumap['gulm'] = False
 	else:
 		#-------------
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/09 04:37:20	1.267
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/24 18:42:06	1.268
@@ -991,13 +991,21 @@
 	else:
 		addr_str = None
 
-	if (addr_str is None and mcast_manual is not True) or (mcast_manual is True and addr_str == model.getMcastAddr()):
+	try:
+		old_mcast_addr = model.getMcastAddr()
+	except Exception, e:
+		luci_log.debug_verbose('VMCC0: %r %s' % (e, str(e)))
+		old_mcast_addr = None
+
+	if (addr_str is None and mcast_manual is not True and not old_mcast_addr) or (mcast_manual is True and addr_str == old_mcast_addr):
 		errors.append('No multicast configuration changes were made')
 		return (False, {'errors': errors})
 
 	try:
-		model.usesMulticast = True
-		model.mcast_address = addr_str
+		if model.getMcastAddr() is not None and not addr_str:
+			model.del_cluster_multicast()
+		else:
+			model.set_cluster_multicast(addr_str)
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug('Error updating mcast properties: %r %s' \
--- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/07/27 17:02:35	1.5
+++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/08/24 18:42:06	1.6
@@ -121,6 +121,8 @@
     self.filename = filename
     self.lock_type = DLM_TYPE
     self.mcast_address = mcast_addr
+    self.mcast_interface = None
+    self.mcast_ptr = None
     self.cluster_ptr = None
     self.GULM_ptr = None
     self.CMAN_ptr = None
@@ -269,7 +271,10 @@
     if self.usesMulticast is True:
       mcast = Multicast()
       mcast.addAttribute("addr", self.mcast_address)
+      if self.mcast_interface is not None:
+        mcast.addAttribute("interface", self.mcast_interface)
       cman.addChild(mcast)
+      self.mcast_ptr = mcast
 
     fds = FenceDevices()
     obj_tree.addChild(fds)
@@ -513,8 +518,9 @@
     self.clusternodes_ptr.addChild(clusternode)
     if self.usesMulticast is True:
       mcast = Multicast()
-      mcast.addAttribute("addr", self.mcast_address)
-      mcast.addAttribute("interface", "eth0")  #eth0 is the default
+      mcast.addAttribute('addr', self.mcast_address)
+      if self.mcast_interface is not None:
+        mcast.addAttribute('interface', self.mcast_interface)
       clusternode.addChild(mcast)
     self.isModified = True
 
@@ -914,61 +920,84 @@
       #set modified
       self.isModified = True
 
-  def swap_multicast_state(self, address=None):
-    if self.usesMulticast is True:
-      #First, eliminate <multicast> tag
-      if self.CMAN_ptr is not None:
-        children = self.CMAN_ptr.getChildren()
-        if len(children) > 0:
-          for child in children:
-            if child.getTagName() == MCAST_STR:
-              self.CMAN_ptr.removeChild(child)
-              break
-      found_one = True
-      while found_one is True:
-        found_one = False
-        nodes = self.clusternodes_ptr.getChildren()
-        for node in nodes:
-          node_children = node.getChildren()
-          for node_child in node_children:
-            if node_child.getTagName() == MCAST_STR:
-              node.removeChild(node_child)
-              found_one = True
-              break
-          if found_one is True:
-            break
+  def set_nodes_multicast(self, mcast_addr, mcast_if=None):
+    for node in iter(self.getNodes()):
+      new_mcast_tag = True
+      mcast = None
+
+      for node_child in iter(node.getChildren()):
+        if node_child.getTagName() == MCAST_STR:
+          mcast = node_child
+          new_mcast_tag = False
+          break
 
-      self.usesMulticast = False
-      self.mcast_address = None
-      self.isModified = True
+      if mcast is None:
+        mcast = Multicast()
 
+      mcast.addAttribute('addr', mcast_addr)
+      if mcast_if:
+        mcast.addAttribute('interface', mcast_if)
+      else:
+        try:
+          mcast.removeAttribute('interface')
+        except:
+          pass
+
+      if new_mcast_tag is True:
+        node.addChild(mcast)
 
+  def set_cluster_multicast(self, mcast_addr, mcast_if=None):
+    if not self.CMAN_ptr:
+      return False
+
+    if self.mcast_ptr is None:
+      mcast = Multicast()
+      self.CMAN_ptr.addChild(mcast)
+      self.mcast_ptr = mcast
     else:
-      if self.CMAN_ptr is not None:
-        mcast = Multicast()
-        mcast.addAttribute("addr", address)
-        self.CMAN_ptr.addChild(mcast)
+      mcast = self.mcast_ptr
 
-      has_one = False
-      nodes = self.getNodes()
-      for node in nodes:
-        has_one = False
-        node_children = node.getChildren()
-        for node_child in node_children:
-          if node_child.getTagName() == MCAST_STR:
-            has_one = True
-            break
-        if has_one is False:
-          mcast = Multicast()
-          mcast.addAttribute("addr", address)
-          mcast.addAttribute("interface", "eth0")
-          node.addChild(mcast)
+    mcast.addAttribute('addr', mcast_addr)
+    if mcast_if is not None:
+      mcast.addAttribute('interface', mcast_if)
+    else:
+      try:
+        mcast.removeAttribute('interface')
+      except:
+        pass
+    self.mcast_address = mcast_addr 
+    self.mcast_interface = mcast_if
+    self.usesMulticast = True
+    self.set_nodes_multicast(mcast_addr, mcast_if=mcast_if)
+    self.isModified = True
 
-      self.mcast_address = address
-      self.usesMulticast = True
-      self.isModified = True
+  def del_nodes_multicast(self):
+    for node in iter(self.getNodes()):
+      for node_child in iter(node.getChildren()):
+        if node_child.getTagName() == MCAST_STR:
+          node.removeChild(node_child)
+          break
 
+  def del_cluster_multicast(self):
+    if self.CMAN_ptr is None:
+      return False
 
+    for child in iter(self.CMAN_ptr.getChildren()):
+      if child.getTagName() == MCAST_STR:
+        self.CMAN_ptr.removeChild(child)
+        break
+    self.mcast_ptr = None
+    self.usesMulticast = False
+    self.mcast_address = None
+    self.mcast_interface = None
+    self.del_nodes_multicast()
+    self.isModified = True
+
+  def swap_multicast_state(self, address=None, mcast_if=None):
+    if self.usesMulticast is True:
+      self.del_cluster_multicast()
+    else:
+      self.set_cluster_multicast(address, mcast_if)
 
   def check_fence_daemon(self):
     if self.GULM_ptr is None and self.fence_daemon_ptr is None:



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-08-24 18:40 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-08-24 18:40 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL4
Changes by:	rmccabe at sourceware.org	2007-08-24 18:40:29

Modified files:
	luci/cluster   : form-macros validate_config_multicast.js 
	luci/site/luci/Extensions: LuciClusterInfo.py 
	                           cluster_adapters.py 
	luci/site/luci/Extensions/ClusterModel: ModelBuilder.py 

Log message:
	Fix the issue described in bz253994: Cannot specify multicast address for a cluster

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.176.2.19&r2=1.176.2.20
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_multicast.js.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.4.1&r2=1.3.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.10.2.1&r2=1.10.2.2
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.22&r2=1.227.2.23
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.5.2.1&r2=1.5.2.2

--- conga/luci/cluster/form-macros	2007/08/23 18:47:34	1.176.2.19
+++ conga/luci/cluster/form-macros	2007/08/24 18:40:28	1.176.2.20
@@ -1115,11 +1115,11 @@
 						Multicast address
 					</td>
 					<td class="systemsTable">
-						<input type="text" name="mcast_address" id="mcast_address"
+						<input type="text"
+							name="mcast_address" id="mcast_address"
 							tal:attributes="
-								disabled python: clusterinfo['is_mcast'] != 'True' and '1' or '0';
-								value python: clusterinfo['is_mcast'] == 'True' and clusterinfo['mcast_addr'] or '';"
-						/>
+								disabled not:clusterinfo/mcast_addr;
+								value clusterinfo/mcast_addr |nothing" />
 					</td>
 				</tr>
 			</tbody>
--- conga/luci/cluster/validate_config_multicast.js	2007/08/09 21:28:50	1.3.4.1
+++ conga/luci/cluster/validate_config_multicast.js	2007/08/24 18:40:28	1.3.4.2
@@ -11,8 +11,9 @@
 
 function disable_mcast(addrId) {
 	addrObj = document.getElementById(addrId);
-	if (!addrObj || addrObj.disabled)
+	if (!addrObj) {
 		return;
+	}
 	addrObj.disabled = true;
 	prev_mcast_str = addrObj.value;
 	addrObj.value = '';
@@ -20,8 +21,9 @@
 
 function enable_mcast(addrId) {
 	addrObj = document.getElementById(addrId);
-	if (!addrObj || !addrObj.disabled)
+	if (!addrObj) {
 		return;
+	}
 	addrObj.disabled = false;
 	addrObj.value = prev_mcast_str;
 }
--- conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/08/09 21:35:20	1.10.2.1
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/08/24 18:40:29	1.10.2.2
@@ -620,8 +620,8 @@
 			clumap['mcast_addr'] = model.getMcastAddr()
 			clumap['is_mcast'] = 'True'
 		else:
+			clumap['mcast_addr'] = None
 			clumap['is_mcast'] = 'False'
-			clumap['mcast_addr'] = '1.2.3.4'
 		clumap['gulm'] = False
 	else:
 		#-------------
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/23 19:00:30	1.227.2.22
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/24 18:40:29	1.227.2.23
@@ -1000,13 +1000,21 @@
 	else:
 		addr_str = None
 
-	if (addr_str is None and mcast_manual is not True) or (mcast_manual is True and addr_str == model.getMcastAddr()):
+	try:
+		old_mcast_addr = model.getMcastAddr()
+	except Exception, e:
+		luci_log.debug_verbose('VMCC0: %r %s' % (e, str(e)))
+		old_mcast_addr = None
+
+	if (addr_str is None and mcast_manual is not True and not old_mcast_addr) or (mcast_manual is True and addr_str == old_mcast_addr):
 		errors.append('No multicast configuration changes were made')
 		return (False, {'errors': errors})
 
 	try:
-		model.usesMulticast = True
-		model.mcast_address = addr_str
+		if model.getMcastAddr() is not None and not addr_str:
+			model.del_cluster_multicast()
+		else:
+			model.set_cluster_multicast(addr_str)
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug('Error updating mcast properties: %r %s' \
--- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/08/09 21:32:34	1.5.2.1
+++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/08/24 18:40:29	1.5.2.2
@@ -121,6 +121,8 @@
     self.filename = filename
     self.lock_type = DLM_TYPE
     self.mcast_address = mcast_addr
+    self.mcast_interface = None
+    self.mcast_ptr = None
     self.cluster_ptr = None
     self.GULM_ptr = None
     self.CMAN_ptr = None
@@ -269,7 +271,10 @@
     if self.usesMulticast is True:
       mcast = Multicast()
       mcast.addAttribute("addr", self.mcast_address)
+      if self.mcast_interface is not None:
+        mcast.addAttribute("interface", self.mcast_interface)
       cman.addChild(mcast)
+      self.mcast_ptr = mcast
 
     fds = FenceDevices()
     obj_tree.addChild(fds)
@@ -513,8 +518,9 @@
     self.clusternodes_ptr.addChild(clusternode)
     if self.usesMulticast is True:
       mcast = Multicast()
-      mcast.addAttribute("addr", self.mcast_address)
-      mcast.addAttribute("interface", "eth0")  #eth0 is the default
+      mcast.addAttribute('addr', self.mcast_address)
+      if self.mcast_interface is not None:
+        mcast.addAttribute('interface', self.mcast_interface)
       clusternode.addChild(mcast)
     self.isModified = True
 
@@ -914,61 +920,84 @@
       #set modified
       self.isModified = True
 
-  def swap_multicast_state(self, address=None):
-    if self.usesMulticast is True:
-      #First, eliminate <multicast> tag
-      if self.CMAN_ptr is not None:
-        children = self.CMAN_ptr.getChildren()
-        if len(children) > 0:
-          for child in children:
-            if child.getTagName() == MCAST_STR:
-              self.CMAN_ptr.removeChild(child)
-              break
-      found_one = True
-      while found_one is True:
-        found_one = False
-        nodes = self.clusternodes_ptr.getChildren()
-        for node in nodes:
-          node_children = node.getChildren()
-          for node_child in node_children:
-            if node_child.getTagName() == MCAST_STR:
-              node.removeChild(node_child)
-              found_one = True
-              break
-          if found_one is True:
-            break
+  def set_nodes_multicast(self, mcast_addr, mcast_if=None):
+    for node in iter(self.getNodes()):
+      new_mcast_tag = True
+      mcast = None
+
+      for node_child in iter(node.getChildren()):
+        if node_child.getTagName() == MCAST_STR:
+          mcast = node_child
+          new_mcast_tag = False
+          break
 
-      self.usesMulticast = False
-      self.mcast_address = None
-      self.isModified = True
+      if mcast is None:
+        mcast = Multicast()
 
+      mcast.addAttribute('addr', mcast_addr)
+      if mcast_if:
+        mcast.addAttribute('interface', mcast_if)
+      else:
+        try:
+          mcast.removeAttribute('interface')
+        except:
+          pass
+
+      if new_mcast_tag is True:
+        node.addChild(mcast)
 
+  def set_cluster_multicast(self, mcast_addr, mcast_if=None):
+    if not self.CMAN_ptr:
+      return False
+
+    if self.mcast_ptr is None:
+      mcast = Multicast()
+      self.CMAN_ptr.addChild(mcast)
+      self.mcast_ptr = mcast
     else:
-      if self.CMAN_ptr is not None:
-        mcast = Multicast()
-        mcast.addAttribute("addr", address)
-        self.CMAN_ptr.addChild(mcast)
+      mcast = self.mcast_ptr
 
-      has_one = False
-      nodes = self.getNodes()
-      for node in nodes:
-        has_one = False
-        node_children = node.getChildren()
-        for node_child in node_children:
-          if node_child.getTagName() == MCAST_STR:
-            has_one = True
-            break
-        if has_one is False:
-          mcast = Multicast()
-          mcast.addAttribute("addr", address)
-          mcast.addAttribute("interface", "eth0")
-          node.addChild(mcast)
+    mcast.addAttribute('addr', mcast_addr)
+    if mcast_if is not None:
+      mcast.addAttribute('interface', mcast_if)
+    else:
+      try:
+        mcast.removeAttribute('interface')
+      except:
+        pass
+    self.mcast_address = mcast_addr 
+    self.mcast_interface = mcast_if
+    self.usesMulticast = True
+    self.set_nodes_multicast(mcast_addr, mcast_if=mcast_if)
+    self.isModified = True
 
-      self.mcast_address = address
-      self.usesMulticast = True
-      self.isModified = True
+  def del_nodes_multicast(self):
+    for node in iter(self.getNodes()):
+      for node_child in iter(node.getChildren()):
+        if node_child.getTagName() == MCAST_STR:
+          node.removeChild(node_child)
+          break
 
+  def del_cluster_multicast(self):
+    if self.CMAN_ptr is None:
+      return False
 
+    for child in iter(self.CMAN_ptr.getChildren()):
+      if child.getTagName() == MCAST_STR:
+        self.CMAN_ptr.removeChild(child)
+        break
+    self.mcast_ptr = None
+    self.usesMulticast = False
+    self.mcast_address = None
+    self.mcast_interface = None
+    self.del_nodes_multicast()
+    self.isModified = True
+
+  def swap_multicast_state(self, address=None, mcast_if=None):
+    if self.usesMulticast is True:
+      self.del_cluster_multicast()
+    else:
+      self.set_cluster_multicast(address, mcast_if)
 
   def check_fence_daemon(self):
     if self.GULM_ptr is None and self.fence_daemon_ptr is None:



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-08-09  4:37 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-08-09  4:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-08-09 04:37:21

Modified files:
	luci/cluster   : form-macros validate_xvm_key.js 
	luci/site/luci/Extensions: StorageReport.py cluster_adapters.py 
	luci/storage   : form-macros 

Log message:
	pull in fixes from the RHEL5 branch

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.206&r2=1.207
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_xvm_key.js.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.266&r2=1.267
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&r1=1.22&r2=1.23

--- conga/luci/cluster/form-macros	2007/08/08 21:00:06	1.206
+++ conga/luci/cluster/form-macros	2007/08/09 04:37:20	1.207
@@ -982,7 +982,7 @@
 
 				<tr id="fence_xvm_config" class="invisible">
 					<td class="systemsTable" colspan="2" id="fence_xvm_config">
-						<table class="systemsTable">
+						<table class="systemsTable" width="100%">
 							<tr class="systemsTable">
 								<td class="systemsTable">
 									<div id="fence_xvm_hosts" />
--- conga/luci/cluster/validate_xvm_key.js	2007/08/08 21:00:06	1.1
+++ conga/luci/cluster/validate_xvm_key.js	2007/08/09 04:37:20	1.2
@@ -12,16 +12,21 @@
 	var node_num = 0;
 
 	var hclu_elem = document.getElementById('host_cluster_name');
-	if (hclu_elem) {
+	if (hclu_elem && hclu_elem.value) {
 		++node_num;
 		url += '&node' + node_num + '=' + hclu_elem.value;
 	}
 	var vclu_elem = document.getElementById('virt_cluster_name');
-	if (vclu_elem) {
+	if (vclu_elem && vclu_elem.value) {
 		++node_num;
 		url += '&node' + node_num + '=' + vclu_elem.value;
 	}
-    initiate_async_get(url, cluster_member_callback);
+
+	if (!node_num) {
+		alert('No node names were entered');
+	} else {
+	    initiate_async_get(url, cluster_member_callback);
+	}
 }
 
 function cluster_member_callback() {
@@ -50,9 +55,15 @@
 		return;
 	}
 
-	obj = obj.responseXML;
+	try {
+		obj = obj.responseXML.getElementsByTagName('dict')[0];
+	} catch (e) {
+		alert('Received a malformed response from the luci server.');
+		return;
+	}
+
 	var clusters = [];
-	var dict_tags = obj.firstChild.getElementsByTagName('dict');
+	var dict_tags = obj.getElementsByTagName('dict');
 	for (var i = 0 ; i < dict_tags.length ; i++) {
 		try {
 			var cnode_names = [];
@@ -81,31 +92,33 @@
 	for (var i = 0 ; i < clusters.length ; i++) {
 		var cnode_list = clusters[i][1];
 
-		var div = document.createElement('div');
-		var p = document.createElement('p');
 		var span = document.createElement('strong');
-		var ul = document.createElement('ul');
-
-		p.className = 'cluster';
 		span.className = 'cluster';
-		span.textContent = 'Cluster: ' + clusters[i][0];
 
-		p.appendChild(span);
-		div.appendChild(p);
+		var txtnode = document.createTextNode('Cluster: ' + clusters[i][0]);
+		span.appendChild(txtnode);
+
+		var ul = document.createElement('ul');
+		ul.className = 'vanilla';
 
 		for (var j = 0 ; j < cnode_list.length ; j++) {
 			var li = document.createElement('li');
 			var input = document.createElement('input');
-			var lispan = document.createElement('span');
+			var litxt = document.createTextNode(cnode_list[j]);
+
 			input.type = 'checkbox';
 			input.name = '__NODE_HOSTNAME__';
 			input.value = cnode_list[j];
 			input.checked = 'checked';
-			lispan.textContent = cnode_list[j];
+
 			li.appendChild(input);
-			li.appendChild(lispan);
+			li.appendChild(litxt);
 			ul.appendChild(li);
 		}
+
+		var div = document.createElement('div');
+		div.className = 'fence';
+		div.appendChild(span);
 		div.appendChild(ul);
 		xvm_div_elem.appendChild(div);
 	}
@@ -115,5 +128,9 @@
 		form_elem.pagetype.value = '60';
 		fc_elem.className = 'invisible';
 		xvm_hidden_elem.className = 'systemsTable';
+		var applyelem = document.getElementById('fence_config_submit');
+		if (applyelem) {
+			applyelem.disabled = true;
+		}
 	}
 }
--- conga/luci/site/luci/Extensions/StorageReport.py	2007/07/27 16:43:47	1.25
+++ conga/luci/site/luci/Extensions/StorageReport.py	2007/08/09 04:37:20	1.26
@@ -2060,7 +2060,7 @@
     length_in_bytes = 0
     for t in mapper_data['sources']:
         length_in_bytes += int(t['props']['size']['value'])
-    ppb = (length * 1.0) / length_in_bytes  # pixels per byte
+    ppb = (length * 1.0) / max(0.00001, length_in_bytes)  # pixels per byte
     lower_cyl['offset'] = int(lower_cyl['offset'] * ppb)
     for d in lower_cyl['cyls']:
         d['beg'] = int(d['beg'] * ppb)
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/08 21:26:37	1.266
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/09 04:37:20	1.267
@@ -27,8 +27,6 @@
 from homebase_adapters import parseHostForm
 from LuciClusterActions import propagateClusterConfAsync
 
-from LuciZopeAsync import get_cluster_nodes_async
-
 from LuciClusterInfo import getClusterInfo, \
 	getModelBuilder, LuciExtractCluModel
 
@@ -2171,8 +2169,8 @@
 				luci_log.info('Setting fence_xvm key for node "%s" failed' % i)
 			continue
 
-		set_node_flag(self, clustername, i, batch_num,
-			FENCE_XVM_KEY_CREATE, 'Creating a fence_xvm key file')
+		set_node_flag(self, clustername, i, batch_num, FENCE_XVM_KEY_CREATE,
+			'Creating fence_xvm key file for host "%s"' % i)
 
 	request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&tab=2&busyfirst=true' \
 		% (baseurl, CLUSTER_CONFIG, clustername))
--- conga/luci/storage/form-macros	2007/06/27 08:14:22	1.22
+++ conga/luci/storage/form-macros	2007/08/09 04:37:21	1.23
@@ -896,7 +896,7 @@
    <div metal:use-macro="here/form-macros/macros/form-scripts"/>
    <span tal:omit-tag="" 
          tal:condition="not: mapper/new_sources">
-    There is no available <span tal:replace="mapper/pretty_sources_name"/> to be added to <span tal:replace="mapper/pretty_type"/> '<span tal:replace="mapper/pretty_name"/>'. 
+    There are no available <span tal:replace="mapper/pretty_sources_name"/> to be added to <span tal:replace="mapper/pretty_type"/> '<span tal:replace="mapper/pretty_name"/>'. 
      <br/>
      <br/>
     <a tal:define="go_to_mapper_url  python:'./?pagetype=52&mapper_type=' + mapper['mapper_type'] + '&mapper_id=' + mapper['mapper_id'] + '&storagename=' + storagename" 



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-08-09  4:34 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-08-09  4:34 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe at sourceware.org	2007-08-09 04:34:53

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

Log message:
	minor cleanups for 230451 fix

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.90.2.28&r2=1.90.2.29
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_xvm_key.js.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.120.2.36&r2=1.120.2.37

--- conga/luci/cluster/form-macros	2007/08/08 21:18:46	1.90.2.28
+++ conga/luci/cluster/form-macros	2007/08/09 04:34:49	1.90.2.29
@@ -982,7 +982,7 @@
 
 				<tr id="fence_xvm_config" class="invisible">
 					<td class="systemsTable" colspan="2" id="fence_xvm_config">
-						<table class="systemsTable">
+						<table class="systemsTable" width="100%">
 							<tr class="systemsTable">
 								<td class="systemsTable">
 									<div id="fence_xvm_hosts" />
--- conga/luci/cluster/validate_xvm_key.js	2007/08/08 21:20:37	1.1.2.2
+++ conga/luci/cluster/validate_xvm_key.js	2007/08/09 04:34:51	1.1.2.3
@@ -12,16 +12,21 @@
 	var node_num = 0;
 
 	var hclu_elem = document.getElementById('host_cluster_name');
-	if (hclu_elem) {
+	if (hclu_elem && hclu_elem.value) {
 		++node_num;
 		url += '&node' + node_num + '=' + hclu_elem.value;
 	}
 	var vclu_elem = document.getElementById('virt_cluster_name');
-	if (vclu_elem) {
+	if (vclu_elem && vclu_elem.value) {
 		++node_num;
 		url += '&node' + node_num + '=' + vclu_elem.value;
 	}
-    initiate_async_get(url, cluster_member_callback);
+
+	if (!node_num) {
+		alert('No node names were entered');
+	} else {
+	    initiate_async_get(url, cluster_member_callback);
+	}
 }
 
 function cluster_member_callback() {
@@ -50,9 +55,15 @@
 		return;
 	}
 
-	obj = obj.responseXML;
+	try {
+		obj = obj.responseXML.getElementsByTagName('dict')[0];
+	} catch (e) {
+		alert('Received a malformed response from the luci server.');
+		return;
+	}
+
 	var clusters = [];
-	var dict_tags = obj.firstChild.getElementsByTagName('dict');
+	var dict_tags = obj.getElementsByTagName('dict');
 	for (var i = 0 ; i < dict_tags.length ; i++) {
 		try {
 			var cnode_names = [];
@@ -81,31 +92,33 @@
 	for (var i = 0 ; i < clusters.length ; i++) {
 		var cnode_list = clusters[i][1];
 
-		var div = document.createElement('div');
-		var p = document.createElement('p');
 		var span = document.createElement('strong');
-		var ul = document.createElement('ul');
-
-		p.className = 'cluster';
 		span.className = 'cluster';
-		span.textContent = 'Cluster: ' + clusters[i][0];
 
-		p.appendChild(span);
-		div.appendChild(p);
+		var txtnode = document.createTextNode('Cluster: ' + clusters[i][0]);
+		span.appendChild(txtnode);
+
+		var ul = document.createElement('ul');
+		ul.className = 'vanilla';
 
 		for (var j = 0 ; j < cnode_list.length ; j++) {
 			var li = document.createElement('li');
 			var input = document.createElement('input');
-			var lispan = document.createElement('span');
+			var litxt = document.createTextNode(cnode_list[j]);
+
 			input.type = 'checkbox';
 			input.name = '__NODE_HOSTNAME__';
 			input.value = cnode_list[j];
 			input.checked = 'checked';
-			lispan.textContent = cnode_list[j];
+
 			li.appendChild(input);
-			li.appendChild(lispan);
+			li.appendChild(litxt);
 			ul.appendChild(li);
 		}
+
+		var div = document.createElement('div');
+		div.className = 'fence';
+		div.appendChild(span);
 		div.appendChild(ul);
 		xvm_div_elem.appendChild(div);
 	}
@@ -115,5 +128,9 @@
 		form_elem.pagetype.value = '60';
 		fc_elem.className = 'invisible';
 		xvm_hidden_elem.className = 'systemsTable';
+		var applyelem = document.getElementById('fence_config_submit');
+		if (applyelem) {
+			applyelem.disabled = true;
+		}
 	}
 }
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/08 21:14:38	1.120.2.36
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/09 04:34:52	1.120.2.37
@@ -27,8 +27,6 @@
 from homebase_adapters import parseHostForm
 from LuciClusterActions import propagateClusterConfAsync
 
-from LuciZopeAsync import get_cluster_nodes_async
-
 from LuciClusterInfo import getClusterInfo, \
 	getModelBuilder, LuciExtractCluModel
 
@@ -2171,8 +2169,8 @@
 				luci_log.info('Setting fence_xvm key for node "%s" failed' % i)
 			continue
 
-		set_node_flag(self, clustername, i, batch_num,
-			FENCE_XVM_KEY_CREATE, 'Creating a fence_xvm key file')
+		set_node_flag(self, clustername, i, batch_num, FENCE_XVM_KEY_CREATE,
+			'Creating fence_xvm key file for host "%s"' % i)
 
 	request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&tab=2&busyfirst=true' \
 		% (baseurl, CLUSTER_CONFIG, clustername))



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-24  7:02 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-24  7:02 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-02-24 07:02:42

Modified files:
	luci/cluster   : form-macros validate_sys_svc.js 
	luci/site/luci/Extensions: ricci_bridge.py system_adapters.py 

Log message:
	Cleanups to the system services management interface

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.193&r2=1.194
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_sys_svc.js.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/system_adapters.py.diff?cvsroot=cluster&r1=1.1&r2=1.2

--- conga/luci/cluster/form-macros	2007/02/23 22:07:45	1.193
+++ conga/luci/cluster/form-macros	2007/02/24 07:02:42	1.194
@@ -5062,7 +5062,7 @@
 			<td class="systemsTable">
 				<span
 					tal:content="s/state |string:[unknown]"
-					tal:attributes="id python: '__STATUS__:' + s['name']" />
+					tal:attributes="id python: '__STATUS__' + s['name']" />
 			</td>
 
 			<td class="systemsTable">
--- conga/luci/cluster/validate_sys_svc.js	2007/02/23 22:07:45	1.1
+++ conga/luci/cluster/validate_sys_svc.js	2007/02/24 07:02:42	1.2
@@ -3,16 +3,45 @@
 		if (xmlHttp_object.status == 200) {
 			var response = xmlHttp_object.responseXML;
 			if (response) {
-				req_status = response.getAttribute('success');
-				req_op = response.getAttribute('operation');
-				req_svc = response.getAttribute('service');
-				req_msg = response.getAttribute('message');
-				//alert(req_msg + ' / ' + req_status + ' / ' + req_op + ' / ' + req_svc);
+				var result = response.getElementsByTagName('result')[0];
+				var req_status = result.getAttribute('success');
+				var req_op = result.getAttribute('operation');
+				var req_svc = result.getAttribute('service');
+				var req_msg = result.getAttribute('message');
+
+				if (req_status != '0') {
+					var op_str = null;
+					if (req_op == 'stop')
+						op_str = 'stopped';
+					else
+						op_str = req_op + 'ed';
+
+					alert('Service ' + req_svc + ' was successfully ' + op_str);
+
+					var status_elem = document.getElementById('__STATUS__' + req_svc);
+					var start_elem = document.getElementById('__START__' + req_svc);
+					var restart_elem = document.getElementById('__RESTART__' + req_svc);
+					var stop_elem = document.getElementById('__STOP__' + req_svc);
+
+					if (req_op == 'stop') {
+						stop_elem.disabled = 'disabled';
+						restart_elem.disabled = 'disabled';
+						start_elem.disabled = '';
+						status_elem.innerHTML = 'Stopped';
+					} else {
+						stop_elem.disabled = '';
+						restart_elem.disabled = '';
+						start_elem.disabled = 'disabled';
+						status_elem.innerHTML = 'Running';
+					}
+				} else {
+					alert('An error occurred while attempting to ' + req_op + ' service ' + req_svc + ': ' + req_msg);
+				}
 			} else {
-				alert(xmlHttp_object.responseText);
+				alert('Error retrieving data from server');
 			}
 		} else {
-			//alert('Error retrieving data from server: ' + xmlHttp_object.status);
+			alert('Error retrieving data from server: ' + xmlHttp_object.status);
 		}
 	}
 }
--- conga/luci/site/luci/Extensions/ricci_bridge.py	2007/02/23 22:07:45	1.59
+++ conga/luci/site/luci/Extensions/ricci_bridge.py	2007/02/24 07:02:42	1.60
@@ -491,16 +491,15 @@
 
 	doc = minidom.Document()
 	elem = doc.createElement('result')
+	elem.setAttribute('success', '0')
 
 	if not servicename:
 		elem.setAttribute('service', 'No service name was specified.')
 		elem.setAttribute('message', 'No service name was specified.')
-		elem.setAttribute('success', '0')
 
 	if not op:
 		elem.setAttribute('operation', 'No operation was specified.')
 		elem.setAttribute('message', 'No operation was specified.')
-		elem.setAttribute('success', '0')
 
 	if not servicename or not op:
 		doc.appendChild(elem)
@@ -517,8 +516,7 @@
 		else:
 			raise Exception, op
 	except Exception, e:
-		elem.setAttribute('success', '0');
-		elem.setAttribute('message', 'Unknown operation')
+		elem.setAttribute('message', 'Unknown operation: %s' % str(e))
 		doc.appendChild(elem)
 		return doc
 
@@ -526,14 +524,31 @@
 		
 	ricci_xml = rc.batch_run(batch_str, async=False)
 	if not ricci_xml or not ricci_xml.firstChild:
-		luci_log.debug_verbose('SVCM0: None returned')
-		elem.setAttribute('success', '0')
 		elem.setAttribute('message', 'operation failed')
 		doc.appendChild(elem)
 		return doc
 
-	elem.setAttribute('success', '0')
-	elem.setAttribute('message', str(ricci_xml.toxml()))
+	try:
+		mod_elem = ricci_xml.getElementsByTagName('module')
+		status_code = int(mod_elem[0].getAttribute('status'))
+		if status_code == 0:
+			var_elem = mod_elem[0].getElementsByTagName('var')
+			for i in var_elem:
+				name = i.getAttribute('name').lower()
+				if name == 'success':
+					success = i.getAttribute('value').lower()
+					if success == 'true':
+						elem.setAttribute('success', '1')
+						elem.setAttribute('message', 'success')
+					else:
+						elem.setAttribute('message', 'operation failed')
+					break
+		else:
+			err_msg = mod_elem[0].childNodes[1].getAttribute('description')
+			elem.setAttribute('message', err_msg)
+	except Exception, e:
+		elem.setAttribute('message', 'operation failed')
+
 	doc.appendChild(elem)
 	return doc
 
--- conga/luci/site/luci/Extensions/system_adapters.py	2007/02/23 22:07:45	1.1
+++ conga/luci/site/luci/Extensions/system_adapters.py	2007/02/24 07:02:42	1.2
@@ -1,6 +1,7 @@
 from ricci_communicator import RicciCommunicator
 from ricci_bridge import list_services, updateServices, svc_manage
 from LuciSyslog import LuciSyslog
+from xml.dom import minidom
 
 try: 
 	luci_log = LuciSyslog()
@@ -104,31 +105,45 @@
 	request.RESPONSE.redirect(request['URL'] + '?pagetype=90&systemname=' + hostname)
 
 def validate_manage_svc(self, request):
+	ret = minidom.Document()
+
+	result = ret.createElement('result')
+	result.setAttribute('success', '0')
+
+	servicename = None
 	try:
-		hostname = request['systemname'].strip()
+		servicename = request['svcname'].strip()
+		result.setAttribute('service', servicename)
 	except:
-		return None
+		result.setAttribute('service', 'this service')
 
-	servicename = None
 	op = None
 	try:
-		servicename = request['svcname'].strip()
 		op = request['operation'].strip()
 	except:
-		pass
+		result.setAttribute('operation', 'manage')
 
 	try:
-		rc = RicciCommunicator(hostname)
-		if not rc:
-			raise Exception, 'none'
+		hostname = request['systemname'].strip()
+		if not hostname:
+			raise Exception, 'blank'
 	except Exception, e:
-		return None
+		hostname = None
+		result.setAttribute('message', 'No system was specified')
+		ret.appendChild(result)
 
-	ret = None
-	try:
-		ret = svc_manage(rc, hostname, servicename, op)
-		luci_log.debug_verbose('VMC0: returning %s' % str(ret.toxml()))
-	except:
-		pass
-
-	return ret
+	if hostname and op and servicename:
+		try:
+			rc = RicciCommunicator(hostname)
+			if not rc:
+				raise Exception, 'none'
+			ret = svc_manage(rc, hostname, servicename, op)
+		except Exception, e:
+			result.setAttribute('message', str(e))
+			ret.appendChild(result)
+	else:
+		ret.appendChild(result)
+
+	request.RESPONSE.setHeader('Content-Type', 'text/xml; charset=UTF-8')
+	request.RESPONSE.setHeader('Cache-Control', 'no-cache, no-store, private')
+	request.RESPONSE.write(str(ret.toxml()))



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-16  5:29 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-16  5:29 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL4
Changes by:	rmccabe at sourceware.org	2007-02-16 05:29:38

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

Log message:
	- Only set the totem params cman actually reads
	- Fix a bunch of bugs relating to qdisk properties

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.176.2.11&r2=1.176.2.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_qdisk.js.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.5&r2=1.5.2.1
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.8&r2=1.227.2.9

--- conga/luci/cluster/form-macros	2007/02/16 02:12:46	1.176.2.11
+++ conga/luci/cluster/form-macros	2007/02/16 05:29:38	1.176.2.12
@@ -640,12 +640,56 @@
 					<table class="systemsTable">
 						<tr class="systemsTable">
 							<td class="systemsTable">
+								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#token', 55, 65);">Token Timeout</a> (ms)
+							</td>
+							<td class="systemsTable">
+								<input type="text" size="10" name="token"
+									tal:attributes="value clusterinfo/totem/token | string:10000" />
+							</td>
+						</tr>
+
+						<tr class="systemsTable">
+							<td class="systemsTable">
+								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#retransmits_before_loss', 55, 65);">Number of token retransmits before loss</a>
+							</td>
+							<td class="systemsTable">
+								<input type="text" size="10"
+									name="token_retransmits_before_loss_const"
+									tal:attributes="value clusterinfo/totem/token_retransmits_before_loss_const | string:20" />
+							</td>
+						</tr>
+
+						<tr class="systemsTable">
+							<td class="systemsTable">
+								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#join', 55, 65);">Join Timeout</a> (ms)
+							</td>
+							<td class="systemsTable">
+								<input type="text" size="10" name="join"
+									tal:attributes="value clusterinfo/totem/join | string:60" />
+							</td>
+						</tr>
+
+						<tr class="systemsTable">
+							<td class="systemsTable">
+								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#consensus', 55, 65);">Consensus Timeout</a> (ms)
+							</td>
+							<td class="systemsTable">
+								<input type="text" size="10"
+									name="consensus"
+									tal:attributes="value clusterinfo/totem/consensus | string:4800" />
+							</td>
+						</tr>
+
+<tal:comment tal:replace="nothing">
+						<tr class="systemsTable">
+							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#secauth', 55, 65);">Secure Authentication</a>
 							</td>
 							<td class="systemsTable">
 								<input type="checkbox" name="secauth" checked="checked" />
 						</tr>
 
+
 						<tr class="systemsTable">
 							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#rrp_mode', 55, 65);">Redundant Ring Protocol Mode</a>
@@ -703,16 +747,6 @@
 
 						<tr class="systemsTable">
 							<td class="systemsTable">
-								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#token', 55, 65);">Token Timeout</a> (ms)
-							</td>
-							<td class="systemsTable">
-								<input type="text" size="10" name="token"
-									tal:attributes="value string:5000" />
-							</td>
-						</tr>
-
-						<tr class="systemsTable">
-							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#token_retransmit', 55, 65);">Token Retransmit</a> (ms)
 							</td>
 							<td class="systemsTable">
@@ -734,27 +768,6 @@
 
 						<tr class="systemsTable">
 							<td class="systemsTable">
-								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#retransmits_before_loss', 55, 65);">Number of retransmits before loss</a>
-							</td>
-							<td class="systemsTable">
-								<input type="text" size="10"
-									name="retransmits_before_loss"
-									tal:attributes="value string:4" />
-							</td>
-						</tr>
-
-						<tr class="systemsTable">
-							<td class="systemsTable">
-								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#join', 55, 65);">Join Timeout</a> (ms)
-							</td>
-							<td class="systemsTable">
-								<input type="text" size="10" name="join"
-									tal:attributes="value string:100" />
-							</td>
-						</tr>
-
-						<tr class="systemsTable">
-							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#send_join', 55, 65);">Maximum time to wait before sending a join message</a> (ms)
 							</td>
 							<td class="systemsTable">
@@ -765,17 +778,6 @@
 
 						<tr class="systemsTable">
 							<td class="systemsTable">
-								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#consensus', 55, 65);">Consensus Timeout</a> (ms)
-							</td>
-							<td class="systemsTable">
-								<input type="text" size="10"
-									name="consensus"
-									tal:attributes="value string:100" />
-							</td>
-						</tr>
-
-						<tr class="systemsTable">
-							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#merge', 55, 65);">Merge Detection Timeout</a> (ms)
 							</td>
 							<td class="systemsTable">
@@ -894,6 +896,7 @@
 									tal:attributes="value string:47" />
 							</td>
 						</tr>
+</tal:comment>
 					</table>
 				</td></tr>
 			</table>
@@ -1092,14 +1095,14 @@
 				<tr class="systemsTable" id="st_row"><td class="systemsTable" id="st_col">
 					<input type="radio" name="quorumd" value="False"
 						onClick="disableChildrenInput('quorumdisk');"
-						tal:attributes="checked python: clusterinfo['is_quorumd'] != 'True'"/>
+						tal:attributes="checked python: (not clusterinfo['is_quorumd']) and 'checked' or ''" />
 					Do not use a Quorum Partition
 				</td></tr>
 
 				<tr class="systemsTable"><td class="systemsTable">
 					<input type="radio" name="quorumd" value="True"
 						onClick="enableChildrenInput('quorumdisk');"
-						tal:attributes="checked python: clusterinfo['is_quorumd'] == 'True'"/>
+						tal:attributes="checked python: (clusterinfo['is_quorumd']) and 'checked' or ''" />
 						Use a Quorum Partition
 				</td></tr>
 			</tbody>
@@ -1114,48 +1117,48 @@
 			<tr class="systemsTable">
 				<td class="systemsTable">Interval</td>
 				<td class="systemsTable">
-					<input type="text" name="interval" value=""
-						tal:attributes="value clusterinfo/interval"/>
+					<input type="text" name="interval"
+						tal:attributes="value clusterinfo/interval | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">Votes</td>
 				<td class="systemsTable">
-					<input type="text" name="votes" value=""
-						tal:attributes="value clusterinfo/votes"/>
+					<input type="text" name="votes"
+						tal:attributes="value clusterinfo/votes | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">TKO</td>
 				<td class="systemsTable">
-					<input type="text" name="tko" value=""
-						tal:attributes="value clusterinfo/tko"/>
+					<input type="text" name="tko"
+						tal:attributes="value clusterinfo/tko | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">Minimum Score</td>
 				<td class="systemsTable">
-					<input type="text" name="min_score" value=""
-						tal:attributes="value clusterinfo/min_score"/>
+					<input type="text" name="min_score"
+						tal:attributes="value clusterinfo/min_score | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">Device</td>
 				<td class="systemsTable">
-					<input type="text" name="device" value=""
-						tal:attributes="value clusterinfo/device"/>
+					<input type="text" name="device"
+						tal:attributes="value clusterinfo/device | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">Label</td>
 				<td class="systemsTable">
-					<input type="text" name="label" value=""
-						tal:attributes="value clusterinfo/label"/>
+					<input type="text" name="label"
+						tal:attributes="value clusterinfo/label | nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1172,9 +1175,6 @@
 
 				<tr class="systemsTable">
 					<th class="systemsTable">
-						<div class="systemsTableTop">Name</div>
-					</th>
-					<th class="systemsTable">
 						<div class="systemsTableTop">Path to Program</div>
 					</th>
 					<th class="systemsTable">
@@ -1190,22 +1190,22 @@
 			</thead>
 
 			<tbody class="systemsTable" id="heuristicList"
-				tal:define="global heuristics clusterinfo/hlist">
+				tal:define="global heuristics clusterinfo/hlist | nothing">
 
-				<tal:block tal:condition="python: not len(heuristics)">
+				<tal:block tal:condition="python: not heuristics or not len(heuristics)">
 				<input type="hidden" name="num_heuristics" id="num_heuristics" value="0">
 				<tr class="systemsTable" id="heuristic0">
 					<td class="systemsTable">
-						<input class="qdname qdisk" type="text" name="heuristic0:hname" id="heuristic0:hname" value="">
-					</td>
-					<td class="systemsTable">
-						<input class="qdpath qdisk" type="text" name="heuristic0:hprog" id="heuristic0:hprog" value="">
+						<input class="qdpath qdisk" type="text"
+							name="heuristic0:hprog" id="heuristic0:hprog" />
 					</td>
 					<td class="systemsTable">
-						<input class="qdint qdisk" type="text" name="heuristic0:hinterval" id="heuristic0:hinterval" value="">
+						<input class="qdint qdisk" type="text"
+							name="heuristic0:hinterval" id="heuristic0:hinterval" />
 					</td>
 					<td class="systemsTable">
-						<input class="qdscore qdisk" type="text" name="heuristic0:hscore" id="heuristic0:hscore" value="">
+						<input class="qdscore qdisk" type="text"
+							name="heuristic0:hscore" id="heuristic0:hscore" />
 					</td>
 					<td class="systemsTable">
 						<img class="qdisk deleteRow"
@@ -1230,32 +1230,27 @@
 					tal:define="global curHeur python: curHeur + 1">
 
 					<td class="systemsTable">
-						<input class="qdname qdisk" type="text"
-							tal:attributes="
-								value heuristic/hname;
-								id python: 'heuristic' + str(curHeur) + ':hname';
-								name python: 'heuristic' + str(curHeur) + ':hname';"/>
-					</td>
-					<td class="systemsTable">
 						<input class="qdpath qdisk" type="text"
 							tal:attributes="
 								value heuristic/hprog;
 								id python: 'heuristic' + str(curHeur) + ':hprog';
-								name python: 'heuristic' + str(curHeur) + ':hprog';"/>
+								name python: 'heuristic' + str(curHeur) + ':hprog'" />
 					</td>
+
 					<td class="systemsTable">
 						<input class="qdint qdisk" type="text"
 							tal:attributes="
 								value heuristic/hinterval;
 								id python: 'heuristic' + str(curHeur) + ':hinterval';
-								name python: 'heuristic' + str(curHeur) + ':hinterval';"/>
+								name python: 'heuristic' + str(curHeur) + ':hinterval'" />
 					</td>
+
 					<td class="systemsTable">
 						<input class="qdscore qdisk" type="text"
 							tal:attributes="
 								value heuristic/hscore;
 								id python: 'heuristic' + str(curHeur) + ':hscore';
-								name python: 'heuristic' + str(curHeur) + ':hscore';"/>
+								name python: 'heuristic' + str(curHeur) + ':hscore'" />
 					</td>
 					<td class="systemsTable">
 						<img class="qdisk deleteRow"
@@ -1264,14 +1259,15 @@
 							onClick="delete_qdisk_heur(this, document.quorum_partition);"
 							tal:attributes="
 								id python: 'heuristic' + str(curHeur) + ':hdel';
-								name python: 'heuristic' + str(curHeur) + ':hdel';"/>
+								name python: 'heuristic' + str(curHeur) + ':hdel'" />
 					</td>
 				</tr>
 				</tal:block>
 			</tbody>
+
 			<tfoot>
 				<tr class="systemsTable"><td class="systemsTable">
-					<input class="addrow" type="button" value="Add another heuristic" onClick="addHeuristic('heuristicList');">
+					<input class="addrow" type="button" value="Add another heuristic" onClick="addHeuristic('heuristicList')">
 				</td></tr>
 			</tfoot>
 		</table>
@@ -1281,10 +1277,9 @@
 		<div class="spacing configTabContent"></div>
 		<div class="hbSubmit spacing configTabContent">
 			<input type="button" value="Apply"
-				onClick="validate_form(this.form);"
-			>
+				onClick="validate_form(this.form)" />
 		</div>
-		<script tal:condition="python: clusterinfo['is_quorumd'] != 'True'">
+		<script tal:condition="not: clusterinfo/is_quorumd">
 			disableChildrenInput('quorumdisk');
 		</script>
 		</form>
--- conga/luci/cluster/validate_config_qdisk.js	2006/12/21 05:08:48	1.5
+++ conga/luci/cluster/validate_config_qdisk.js	2007/02/16 05:29:38	1.5.2.1
@@ -1,4 +1,4 @@
-var heuristic_names = [ ':hname', ':hprog', ':hinterval', ':hscore', ':hdel' ];
+var heuristic_names = [ ':hprog', ':hinterval', ':hscore', ':hdel' ];
 
 function clear_heuristic(form, heur_num) {
 	var str_prefix = 'heuristic' + heur_num;
@@ -82,26 +82,14 @@
 
 	var hstr = 'heuristic' + hnum;
 
-	var hname = document.getElementById(hstr + ':hname');
-	if (!hname || str_is_blank(hname.value)) {
-		++blank;
-		errors.push('No name was given for heuristic ' + (hnum + 1));
-		set_form_err(hname);
-	} else {
-		/* XXX sanity check the name */
-		hname = hname.value;
-		clr_form_err(hname);
-	}
-
-	var hpath = document.getElementById(hstr + ':hpath');
-	if (!hpath || str_is_blank(hpath.value)) {
+	var hprog = document.getElementById(hstr + ':hprog');
+	if (!hprog || str_is_blank(hprog.value)) {
 		++blank;
 		errors.push('No path was given for heuristic ' + (hnum + 1));
-		set_form_err(hpath);
+		set_form_err(hprog);
 	} else {
 		/* XXX sanity check the path */
-		hpath = hpath.value;
-		clr_form_err(hpath);
+		clr_form_err(hprog);
 	}
 
 	var hint = document.getElementById(hstr + ':hinterval');
@@ -110,8 +98,7 @@
 		errors.push('No interval was given for heuristic ' + (hnum + 1));
 		set_form_err(hint);
 	} else {
-		hint = hint.value;
-		if (!is_valid_int(hint, 1, null)) {
+		if (!is_valid_int(hint.value, 1, null)) {
 			errors.push('Heuristic interval values must be greater than 0.');
 			set_form_err(hint);
 		} else
@@ -124,18 +111,16 @@
 		errors.push('No score was given for heuristic ' + (hnum + 1));
 		set_form_err(hscore);
 	} else {
-		hscore = hscore.value;
-		if (!is_valid_int(hscore, 0, null)) {
+		if (!is_valid_int(hscore.value, 0, null)) {
 			errors.push('Heuristic score values must be 0 or greater.');
 			set_form_err(hscore);
 		} else
 			clr_form_err(hscore);
 	}
 
-	if (blank == 4) {
+	if (blank == 3) {
 		/* The entry is blank -- ignore it. */
-		clr_form_err(hname);
-		clr_form_err(hpath);
+		clr_form_err(hprog);
 		clr_form_err(hint);
 		clr_form_err(hscore);
 		return (null);
@@ -219,30 +204,15 @@
 				clr_form_err(form.min_score);
 		}
 
-		if (!form.device || str_is_blank(form.device.value)) {
-			errors.push('No device setting was given.');
-			set_form_err(form.device);
-		} else {
-			/* TODO: check this */
-			var device = form.device.value;
-			clr_form_err(form.device);
-		}
-
-		if (!form.label || str_is_blank(form.label.value)) {
-			errors.push('No label setting was given.');
-			set_form_err(form.label);
-		} else {
-			/* TODO: check this */
-			var label = form.device.label;
-			clr_form_err(form.label);
-		}
+		var no_dev = !form.device || str_is_blank(form.device.value);
+		var no_label = !form.label || str_is_blank(form.label.value);
+		if (no_dev && no_label)
+			errors.push('You must give either a label or a device.');
 
 		var hnum = document.getElementById('num_heuristics');
 		if (hnum) {
-			hnum = Number(hnum.value);
-			if (hnum === 0)
-				hnum++;
-			for (var i = 0 ; i < hnum ; i++) {
+			hnum = Number(hnum.value) + 1;
+			for (var i = 0 ; i <= hnum ; i++) {
 				var err = check_heuristic(i, form);
 				if (err)
 					errors = errors.concat(err);
@@ -252,6 +222,7 @@
 
 	if (error_dialog(errors))
 		return (-1);
+
 	if (confirm('Update quorum partition properties?'))
 		form.submit();
 }
@@ -275,15 +246,6 @@
 
 	var hstr = 'heuristic' + cur_hnum;
 
-	var name_td = document.createElement('td');
-	name_td.className = 'systemsTable';
-	var name_input = document.createElement('input');
-	name_input.className = 'qdname qdisk';
-	name_input.setAttribute('name', hstr + ':hname');
-	name_input.setAttribute('id', hstr + ':hname');
-	name_input.setAttribute('type', 'text');
-	name_td.appendChild(name_input);
-
 	var path_td = document.createElement('td');
 	path_td.className = 'systemsTable';
 	var path_input = document.createElement('input');
@@ -325,7 +287,6 @@
 	var tr = document.createElement('tr');
 	tr.className = 'systemsTable';
 	tr.setAttribute('id', 'heuristic' + cur_hnum);
-	tr.appendChild(name_td);
 	tr.appendChild(path_td);
 	tr.appendChild(interval_td);
 	tr.appendChild(score_td);
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/16 02:12:46	1.227.2.8
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/16 05:29:38	1.227.2.9
@@ -1013,8 +1013,16 @@
 	except KeyError, e:
 		return (False, {'errors': ['An invalid quorum partition selection was made']})
 
+	cp = model.getClusterPtr()
+	qdp = model.getQuorumdPtr()
+
 	if not qdisk_val:
-		return (True, {'messages': ['Changes accepted. - FILL ME IN']})
+		if qdp:
+			try:
+				cp.removeChild(qdp)
+			except Exception, e:
+				return (False, {'errors': [ 'Error disabling quorum partition: %s' % str(e) ] })
+		return (True, {})
 
 	try:
 		interval = int(form['interval'])
@@ -1054,22 +1062,25 @@
 
 	#Either device or label must be present
 	device = None
-	label = None
 	try:
 		device = form['device'].strip()
+	except:
+		device = None
+
+	label = None
+	try:
 		label = form['label'].strip()
-		if not device and not label:
-			raise KeyError, 'device and label are both none'
-	except KeyError, e:
+	except:
+		label = None
+
+	if not device and not label:
 		errors.append('No Device or Label value was given')
 
 	num_heuristics = 0
 	try:
-		num_heuristics = int(form['num_heuristics'])
-		if num_heuristics < 0:
-			raise ValueError, 'invalid number of heuristics: %s' % form['num_heuristics']
-		if num_heuristics == 0:
-			num_heuristics = 1
+		num_heuristics = int(form['num_heuristics']) + 1
+		if num_heuristics < 1:
+			raise ValueError, form['num_heuristics']
 	except KeyError, e:
 		errors.append('No number of heuristics was given.')
 	except ValueError, e:
@@ -1077,65 +1088,67 @@
 
 	heuristics = list()
 	for i in xrange(num_heuristics):
-		prefix = 'heuristic' + str(i) + ':'
 		try:
-			hname = form[prefix + 'hname'].strip()
-			if not hname:
-				raise KeyError(prefix + 'hname')
-		except KeyError, e:
-			if ((not prefix + 'hpath' in form or not form['hpath'].strip()) and
-				(not prefix + 'hint' in form or not form['hint'].strip()) and
-				(not prefix + 'hscore' in form or not form['hscore'].strip())):
-				# The row is blank; ignore it.
+			h = form['heuristic%d' % i]
+			if not h or len(h) != 3:
 				continue
-			errors.append('No heuristic name was given for heuristic #%d' % i + 1)
+		except:
+			continue
 
 		try:
-			hpath = form[prefix + 'hpath']
-		except KeyError, e:
-			errors.append('No heuristic path was given for heuristic #%d' % i + 1)
-
+			hprog = h[0]
+			if not hprog:
+				raise Exception, 'no hprog'
+		except Exception, e:
+			errors.append('No program was given for heuristic %d' % i + 1)
 		try:
-			hint = int(form[prefix + 'hint'])
+			hint = int(h[1])
 			if hint < 1:
 				raise ValueError, 'Heuristic interval values must be greater than 0'
 		except KeyError, e:
-			errors.append('No heuristic interval was given for heuristic #%d' % i + 1)
+			errors.append('No interval was given for heuristic #%d' % i + 1)
 		except ValueError, e:
-			errors.append('An invalid heuristic interval was given for heuristic #%d: %s' % (i + 1, str(e)))
+			errors.append('An invalid interval was given for heuristic %d: %s' \
+				% (i + 1, str(e)))
 
 		try:
-			hscore = int(form[prefix + 'score'])
+			hscore = int(h[2])
 			if hscore < 1:
 				raise ValueError, 'Heuristic scores must be greater than 0'
 		except KeyError, e:
-			errors.append('No heuristic score was given for heuristic #%d' % i + 1)
+			errors.append('No score was given for heuristic %d' % i + 1)
 		except ValueError, e:
-			errors.append('An invalid heuristic score was given for heuristic #%d: %s' % (i + 1, str(e)))
-		heuristics.append([ hname, hpath, hint, hscore ])
+			errors.append('An invalid score was given for heuristic %d: %s' \
+				% (i + 1, str(e)))
+
+		heuristics.append([ hprog, hint, hscore ])
 
 	if len(errors) > 0:
 		return (False, {'errors': errors })
 
 	qd = QuorumD()
-	qd.addAttribute('interval', interval)
-	qd.addAttribute('votes', votes)
-	qd.addAttribute('tko', tko)
-	qd.addAttribute('min_score', min_score)
+	qd.addAttribute('interval', str(interval))
+	qd.addAttribute('votes', str(votes))
+	qd.addAttribute('tko', str(tko))
+	qd.addAttribute('min_score', str(min_score))
 
 	if device:
-		qd.addAttribute('device', device)
+		qd.addAttribute('device', str(device))
 	else:
-		qd.addAttribute('label', label)
+		qd.addAttribute('label', str(label))
 
-	cp = model.getClusterPtr()
+	if qdp:
+		try:
+			cp.removeChild(qdp)
+		except:
+			pass
 	cp.addChild(qd)
 
 	for h in heuristics:
 		new_h = Heuristic()
-		new_h.addAttribute('program', h[1])
-		new_h.addAttribute('interval', h[2])
-		new_h.addAttribute('score', h[3])
+		new_h.addAttribute('program', str(h[0]))
+		new_h.addAttribute('interval', str(h[1]))
+		new_h.addAttribute('score', str(h[2]))
 		qd.addChild(new_h)
 
 	if len(errors) > 0:
@@ -1169,8 +1182,9 @@
 		version_num = int(form['cfgver'])
 		if version_num < old_ver:
 			raise ValueError, 'configuration version number must be %d or greater.' % old_ver
-		# we'll increment the cluster version before propagating it.
-		version_num -= 1
+		if version_num != old_ver:
+			# we'll increment the cluster version before propagating it.
+			version_num -= 1
 	except KeyError, e:
 		errors.append('No cluster configuration version was given.')
 	except ValueError, e:
@@ -1194,79 +1208,11 @@
 			return (False, {'errors': errors})
 		return (True, {})
 
-#	totem = model.getTotemPtr()
-#	if totem is None:
-#		cp = model.getClusterPtr()
-#		totem = Totem()
-#		cp.addChild(totem)
-	totem = Totem()
-
-	if form.has_key('secauth'):
-		totem.addAttribute('secauth', '1')
-	else:
-		totem.addAttribute('secauth', '0')
-
-	try:
-		rrp_mode = form['rrp_mode'].strip().lower()
-		if not rrp_mode:
-			raise KeyError, 'rrp_mode'
-		if rrp_mode != 'none' and rrp_mode != 'active' and 'rrp_mode' != 'passive':
-			raise Exception, '%s is an invalid value for redundant ring protocol mode' % rrp_mode
-		totem.addAttribute('rrp_mode', str(rrp_mode))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('rrp_mode')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		net_mtu = form['net_mtu'].strip()
-		if not net_mtu:
-			raise KeyError, 'net_mtu'
-		net_mtu = int(net_mtu)
-		if net_mtu < 1:
-			raise ValueError, '%d is an invalid value for network MTU' % net_mtu
-		totem.addAttribute('net_mtu', str(net_mtu))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('net_mtu')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		threads = form['threads'].strip()
-		if not threads:
-			raise KeyError, 'threads'
-		threads = int(threads)
-		if threads < 0:
-			raise ValueError, '%d is an invalid value for number of threads' % threads
-		totem.addAttribute('threads', str(threads))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('threads')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		vsftype = form['vsftype'].strip().lower()
-		if not vsftype:
-			raise KeyError, 'vsftype'
-		if vsftype != 'none' and vsftype != 'ykd':
-			raise ValueError, '%s is an invalid value for virtual synchrony type' % vsftype
-		totem.addAttribute('vsftype', str(vsftype))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('vsftype')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
+	totem = model.getTotemPtr()
+	if totem is None:
+		cp = model.getClusterPtr()
+		totem = Totem()
+		cp.addChild(totem)
 
 	try:
 		token = form['token'].strip()
@@ -1285,48 +1231,16 @@
 		errors.append(str(e))
 
 	try:
-		token_retransmit = form['token_retransmit'].strip()
-		if not token_retransmit:
-			raise KeyError, 'token_retransmit'
-		token_retransmit = int(token_retransmit)
-		if token_retransmit < 1:
-			raise ValueError, '%d is an invalid value for token retransmit' % token_retransmit
-		totem.addAttribute('token_retransmit', str(token_retransmit))
+		token_retransmits_before_loss_const = form['token_retransmits_before_loss_const'].strip()
+		if not token_retransmits_before_loss_const:
+			raise KeyError, 'token_retransmits_before_loss_const'
+		token_retransmits_before_loss_const = int(token_retransmits_before_loss_const)
+		if token_retransmits_before_loss_const < 1:
+			raise ValueError, '%d is an invalid value for number of token retransmits before loss' % token_retransmits_before_loss_const
+		totem.addAttribute('token_retransmits_before_loss_const', str(token_retransmits_before_loss_const))
 	except KeyError, e:
 		try:
-			totem.removeAttribute('token_retransmit')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		hold = form['hold'].strip()
-		if not hold:
-			raise KeyError, 'hold'
-		hold = int(hold)
-		if hold < 1:
-			raise ValueError, '%d is not a valid value for hold token timeout' % hold
-		totem.addAttribute('hold', str(hold))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('hold')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		retransmits_before_loss = form['retransmits_before_loss'].strip()
-		if not retransmits_before_loss:
-			raise KeyError, 'retransmits_before_loss'
-		retransmits_before_loss = int(retransmits_before_loss)
-		if retransmits_before_loss < 1:
-			raise ValueError, '%d is an invalid value for number of retransmits before loss' % retransmits_before_loss
-		totem.addAttribute('retransmits_before_loss', str(retransmits_before_loss))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('retransmits_before_loss')
+			totem.removeAttribute('token_retransmits_before_loss_const')
 		except:
 			pass
 	except Exception, e:
@@ -1349,22 +1263,6 @@
 		errors.append(str(e))
 
 	try:
-		send_join = form['send_join'].strip()
-		if not send_join:
-			raise KeyError, 'send_join'
-		send_join = int(send_join)
-		if send_join < 0:
-			raise ValueError, '%d is an invalid value for time to wait before sending a join message' % send_join
-		totem.addAttribute('send_join', str(send_join))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('send_join')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
 		consensus = form['consensus'].strip()
 		if not consensus:
 			raise KeyError, 'consensus'
@@ -1380,182 +1278,6 @@
 	except Exception, e:
 		errors.append(str(e))
 
-	try:
-		merge = form['merge'].strip()
-		if not merge:
-			raise KeyError, 'merge'
-		merge = int(merge)
-		if merge < 1:
-			raise ValueError, '%d is an invalid value for merge detection timeout' % merge
-		totem.addAttribute('merge', str(merge))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('merge')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		downcheck = form['downcheck'].strip()
-		if not downcheck:
-			raise KeyError, 'downcheck'
-		downcheck = int(downcheck)
-		if downcheck < 1:
-			raise ValueError, '%d is an invalid value for interface down check timeout' % downcheck
-		totem.addAttribute('downcheck', str(downcheck))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('downcheck')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		fail_to_recv_const = form['fail_to_recv_const'].strip()
-		if not fail_to_recv_const:
-			raise KeyError, 'fail_to_recv_const'
-		fail_to_recv_const = int(fail_to_recv_const)
-		if fail_to_recv_const < 1:
-			raise ValueError, '%d is an invalid value for fail to receive constant' % fail_to_recv_const
-		totem.addAttribute('fail_to_recv_const', str(fail_to_recv_const))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('fail_to_recv_const')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		seqno_unchanged_const = form['seqno_unchanged_const'].strip()
-		if not seqno_unchanged_const:
-			raise KeyError, 'seqno_unchanged_const'
-		seqno_unchanged_const = int(seqno_unchanged_const)
-		if seqno_unchanged_const < 1:
-			raise ValueError, '%d is an invalid value for rotations with no multicast traffic before merge detection timeout started' % seqno_unchanged_const
-		totem.addAttribute('seqno_unchanged_const', str(seqno_unchanged_const))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('seqno_unchanged_const')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		heartbeat_failures_allowed = form['heartbeat_failures_allowed'].strip()
-		if not heartbeat_failures_allowed:
-			raise KeyError, 'heartbeat_failures_allowed'
-		heartbeat_failures_allowed = int(heartbeat_failures_allowed)
-		if heartbeat_failures_allowed < 0:
-			raise ValueError, '%d is an invalid value for number of heartbeat failures allowed' % heartbeat_failures_allowed
-		totem.addAttribute('heartbeat_failures_allowed', str(heartbeat_failures_allowed))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('heartbeat_failures_allowed')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		max_network_delay = form['max_network_delay'].strip()
-		if not max_network_delay:
-			raise KeyError, 'max_network_delay'
-		max_network_delay = int(max_network_delay)
-		if max_network_delay < 1:
-			raise ValueError, '%d is an invalid value for maximum network delay' % max_network_delay
-		totem.addAttribute('max_network_delay', str(max_network_delay))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('max_network_delay')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		window_size = form['window_size'].strip()
-		if not window_size:
-			raise KeyError, 'window_size'
-		window_size = int(window_size)
-		if window_size < 1:
-			raise ValueError, '%d is an invalid value for window size' % window_size
-		totem.addAttribute('window_size', str(window_size))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('window_size')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		max_messages = form['max_messages'].strip()
-		if not max_messages:
-			raise KeyError, 'max_messages'
-		max_messages = int(max_messages)
-		if max_messages < 1:
-			raise ValueError, '%d is an invalid value for maximum messages' % max_messages
-		totem.addAttribute('max_messages', str(max_messages))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('max_messages')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		rrp_problem_count_timeout = form['rrp_problem_count_timeout'].strip()
-		if not rrp_problem_count_timeout:
-			raise KeyError, 'rrp_problem_count_timeout'
-		rrp_problem_count_timeout = int(rrp_problem_count_timeout)
-		if rrp_problem_count_timeout < 1:
-			raise ValueError, '%d is an invalid value for RRP problem count timeout' % rrp_problem_count_timeout
-		totem.addAttribute('rrp_problem_count_timeout', str(rrp_problem_count_timeout))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('rrp_problem_count_timeout')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		rrp_problem_count_threshold = form['rrp_problem_count_threshold'].strip()
-		if not rrp_problem_count_threshold:
-			raise KeyError, 'rrp_problem_count_threshold'
-		rrp_problem_count_threshold = int(rrp_problem_count_threshold)
-		if rrp_problem_count_threshold < 1:
-			raise ValueError, '%d is an invalid value for RRP problem count threshold' % rrp_problem_count_threshold
-		totem.addAttribute('rrp_problem_count_threshold', str(rrp_problem_count_threshold))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('rrp_problem_count_threshold')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		rrp_token_expired_timeout = form['rrp_token_expired_timeout'].strip()
-		if not rrp_token_expired_timeout:
-			raise KeyError, 'rrp_token_expired_timeout'
-		rrp_token_expired_timeout = int(rrp_token_expired_timeout)
-		if rrp_token_expired_timeout < 1:
-			raise ValueError, '%d is an invalid value for RRP token expired timeout' % rrp_token_expired_timeout
-		totem.addAttribute('rrp_token_expired_timeout', str(rrp_token_expired_timeout))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('rrp_token_expired_timeout')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
 	if len(errors) > 0:
 		return (False, {'errors': errors})
 	return (True, {})
@@ -4173,6 +3895,7 @@
         luci_log.debug_verbose('GCI0: unable to determine cluster name')
         return {}
 
+  clumap = {}
   if model is None:
     try:
       model = getModelForCluster(self, cluname)
@@ -4182,9 +3905,12 @@
     except Exception, e:
       luci_log.debug_verbose('GCI1: unable to get model for cluster %s: %s' % (cluname, str(e)))
       return {}
+  else:
+    totem = model.getTotemPtr()
+    if totem:
+      clumap['totem'] = totem.getAttributes()
 
   prop_baseurl = req['URL'] + '?' + PAGETYPE + '=' + CLUSTER_CONFIG + '&' + CLUNAME + '=' + cluname + '&'
-  clumap = {}
   basecluster_url = prop_baseurl + PROPERTIES_TAB + "=" + PROP_GENERAL_TAB
   #needed:
   clumap['basecluster_url'] = basecluster_url
@@ -4286,27 +4012,21 @@
       clumap['label'] = label
 
     heuristic_kids = qdp.getChildren()
-    h_ctr = 0
+
     for kid in heuristic_kids:
       hmap = {}
-      hname = kid.getAttribute('name')
-      if hname is None:
-        hname = h_ctr
-        h_ctr = h_ctr + 1
       hprog = kid.getAttribute('program')
-      hscore = kid.getAttribute('score')
-      hinterval = kid.getAttribute('interval')
       if hprog is None:
         continue
-      if hname is not None:
-        hmap['hname'] = hname
-      else:
-        hmap['hname'] = ""
+
+      hscore = kid.getAttribute('score')
       hmap['hprog'] = hprog
       if hscore is not None:
         hmap['hscore'] = hscore
       else:
         hmap['hscore'] = ""
+
+      hinterval = kid.getAttribute('interval')
       if hinterval is not None:
         hmap['hinterval'] = hinterval
       else:



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-16  5:26 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-16  5:26 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-02-16 05:26:18

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

Log message:
	- Only set the totem params cman actually reads
	- Fix a bunch of bugs relating to qdisk properties

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.190&r2=1.191
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_qdisk.js.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.240&r2=1.241

--- conga/luci/cluster/form-macros	2007/02/16 02:06:08	1.190
+++ conga/luci/cluster/form-macros	2007/02/16 05:26:18	1.191
@@ -640,12 +640,56 @@
 					<table class="systemsTable">
 						<tr class="systemsTable">
 							<td class="systemsTable">
+								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#token', 55, 65);">Token Timeout</a> (ms)
+							</td>
+							<td class="systemsTable">
+								<input type="text" size="10" name="token"
+									tal:attributes="value clusterinfo/totem/token | string:10000" />
+							</td>
+						</tr>
+
+						<tr class="systemsTable">
+							<td class="systemsTable">
+								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#retransmits_before_loss', 55, 65);">Number of token retransmits before loss</a>
+							</td>
+							<td class="systemsTable">
+								<input type="text" size="10"
+									name="token_retransmits_before_loss_const"
+									tal:attributes="value clusterinfo/totem/token_retransmits_before_loss_const | string:20" />
+							</td>
+						</tr>
+
+						<tr class="systemsTable">
+							<td class="systemsTable">
+								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#join', 55, 65);">Join Timeout</a> (ms)
+							</td>
+							<td class="systemsTable">
+								<input type="text" size="10" name="join"
+									tal:attributes="value clusterinfo/totem/join | string:60" />
+							</td>
+						</tr>
+
+						<tr class="systemsTable">
+							<td class="systemsTable">
+								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#consensus', 55, 65);">Consensus Timeout</a> (ms)
+							</td>
+							<td class="systemsTable">
+								<input type="text" size="10"
+									name="consensus"
+									tal:attributes="value clusterinfo/totem/consensus | string:4800" />
+							</td>
+						</tr>
+
+<tal:comment tal:replace="nothing">
+						<tr class="systemsTable">
+							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#secauth', 55, 65);">Secure Authentication</a>
 							</td>
 							<td class="systemsTable">
 								<input type="checkbox" name="secauth" checked="checked" />
 						</tr>
 
+
 						<tr class="systemsTable">
 							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#rrp_mode', 55, 65);">Redundant Ring Protocol Mode</a>
@@ -703,16 +747,6 @@
 
 						<tr class="systemsTable">
 							<td class="systemsTable">
-								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#token', 55, 65);">Token Timeout</a> (ms)
-							</td>
-							<td class="systemsTable">
-								<input type="text" size="10" name="token"
-									tal:attributes="value string:5000" />
-							</td>
-						</tr>
-
-						<tr class="systemsTable">
-							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#token_retransmit', 55, 65);">Token Retransmit</a> (ms)
 							</td>
 							<td class="systemsTable">
@@ -734,27 +768,6 @@
 
 						<tr class="systemsTable">
 							<td class="systemsTable">
-								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#retransmits_before_loss', 55, 65);">Number of retransmits before loss</a>
-							</td>
-							<td class="systemsTable">
-								<input type="text" size="10"
-									name="retransmits_before_loss"
-									tal:attributes="value string:4" />
-							</td>
-						</tr>
-
-						<tr class="systemsTable">
-							<td class="systemsTable">
-								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#join', 55, 65);">Join Timeout</a> (ms)
-							</td>
-							<td class="systemsTable">
-								<input type="text" size="10" name="join"
-									tal:attributes="value string:100" />
-							</td>
-						</tr>
-
-						<tr class="systemsTable">
-							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#send_join', 55, 65);">Maximum time to wait before sending a join message</a> (ms)
 							</td>
 							<td class="systemsTable">
@@ -765,17 +778,6 @@
 
 						<tr class="systemsTable">
 							<td class="systemsTable">
-								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#consensus', 55, 65);">Consensus Timeout</a> (ms)
-							</td>
-							<td class="systemsTable">
-								<input type="text" size="10"
-									name="consensus"
-									tal:attributes="value string:100" />
-							</td>
-						</tr>
-
-						<tr class="systemsTable">
-							<td class="systemsTable">
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#merge', 55, 65);">Merge Detection Timeout</a> (ms)
 							</td>
 							<td class="systemsTable">
@@ -894,6 +896,7 @@
 									tal:attributes="value string:47" />
 							</td>
 						</tr>
+</tal:comment>
 					</table>
 				</td></tr>
 			</table>
@@ -1092,14 +1095,14 @@
 				<tr class="systemsTable" id="st_row"><td class="systemsTable" id="st_col">
 					<input type="radio" name="quorumd" value="False"
 						onClick="disableChildrenInput('quorumdisk');"
-						tal:attributes="checked python: clusterinfo['is_quorumd'] != 'True'"/>
+						tal:attributes="checked python: (not clusterinfo['is_quorumd']) and 'checked' or ''" />
 					Do not use a Quorum Partition
 				</td></tr>
 
 				<tr class="systemsTable"><td class="systemsTable">
 					<input type="radio" name="quorumd" value="True"
 						onClick="enableChildrenInput('quorumdisk');"
-						tal:attributes="checked python: clusterinfo['is_quorumd'] == 'True'"/>
+						tal:attributes="checked python: (clusterinfo['is_quorumd']) and 'checked' or ''" />
 						Use a Quorum Partition
 				</td></tr>
 			</tbody>
@@ -1114,48 +1117,48 @@
 			<tr class="systemsTable">
 				<td class="systemsTable">Interval</td>
 				<td class="systemsTable">
-					<input type="text" name="interval" value=""
-						tal:attributes="value clusterinfo/interval"/>
+					<input type="text" name="interval"
+						tal:attributes="value clusterinfo/interval | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">Votes</td>
 				<td class="systemsTable">
-					<input type="text" name="votes" value=""
-						tal:attributes="value clusterinfo/votes"/>
+					<input type="text" name="votes"
+						tal:attributes="value clusterinfo/votes | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">TKO</td>
 				<td class="systemsTable">
-					<input type="text" name="tko" value=""
-						tal:attributes="value clusterinfo/tko"/>
+					<input type="text" name="tko"
+						tal:attributes="value clusterinfo/tko | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">Minimum Score</td>
 				<td class="systemsTable">
-					<input type="text" name="min_score" value=""
-						tal:attributes="value clusterinfo/min_score"/>
+					<input type="text" name="min_score"
+						tal:attributes="value clusterinfo/min_score | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">Device</td>
 				<td class="systemsTable">
-					<input type="text" name="device" value=""
-						tal:attributes="value clusterinfo/device"/>
+					<input type="text" name="device"
+						tal:attributes="value clusterinfo/device | nothing" />
 				</td>
 			</tr>
 
 			<tr class="systemsTable">
 				<td class="systemsTable">Label</td>
 				<td class="systemsTable">
-					<input type="text" name="label" value=""
-						tal:attributes="value clusterinfo/label"/>
+					<input type="text" name="label"
+						tal:attributes="value clusterinfo/label | nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1172,9 +1175,6 @@
 
 				<tr class="systemsTable">
 					<th class="systemsTable">
-						<div class="systemsTableTop">Name</div>
-					</th>
-					<th class="systemsTable">
 						<div class="systemsTableTop">Path to Program</div>
 					</th>
 					<th class="systemsTable">
@@ -1190,22 +1190,22 @@
 			</thead>
 
 			<tbody class="systemsTable" id="heuristicList"
-				tal:define="global heuristics clusterinfo/hlist">
+				tal:define="global heuristics clusterinfo/hlist | nothing">
 
-				<tal:block tal:condition="python: not len(heuristics)">
+				<tal:block tal:condition="python: not heuristics or not len(heuristics)">
 				<input type="hidden" name="num_heuristics" id="num_heuristics" value="0">
 				<tr class="systemsTable" id="heuristic0">
 					<td class="systemsTable">
-						<input class="qdname qdisk" type="text" name="heuristic0:hname" id="heuristic0:hname" value="">
-					</td>
-					<td class="systemsTable">
-						<input class="qdpath qdisk" type="text" name="heuristic0:hprog" id="heuristic0:hprog" value="">
+						<input class="qdpath qdisk" type="text"
+							name="heuristic0:hprog" id="heuristic0:hprog" />
 					</td>
 					<td class="systemsTable">
-						<input class="qdint qdisk" type="text" name="heuristic0:hinterval" id="heuristic0:hinterval" value="">
+						<input class="qdint qdisk" type="text"
+							name="heuristic0:hinterval" id="heuristic0:hinterval" />
 					</td>
 					<td class="systemsTable">
-						<input class="qdscore qdisk" type="text" name="heuristic0:hscore" id="heuristic0:hscore" value="">
+						<input class="qdscore qdisk" type="text"
+							name="heuristic0:hscore" id="heuristic0:hscore" />
 					</td>
 					<td class="systemsTable">
 						<img class="qdisk deleteRow"
@@ -1230,32 +1230,27 @@
 					tal:define="global curHeur python: curHeur + 1">
 
 					<td class="systemsTable">
-						<input class="qdname qdisk" type="text"
-							tal:attributes="
-								value heuristic/hname;
-								id python: 'heuristic' + str(curHeur) + ':hname';
-								name python: 'heuristic' + str(curHeur) + ':hname';"/>
-					</td>
-					<td class="systemsTable">
 						<input class="qdpath qdisk" type="text"
 							tal:attributes="
 								value heuristic/hprog;
 								id python: 'heuristic' + str(curHeur) + ':hprog';
-								name python: 'heuristic' + str(curHeur) + ':hprog';"/>
+								name python: 'heuristic' + str(curHeur) + ':hprog'" />
 					</td>
+
 					<td class="systemsTable">
 						<input class="qdint qdisk" type="text"
 							tal:attributes="
 								value heuristic/hinterval;
 								id python: 'heuristic' + str(curHeur) + ':hinterval';
-								name python: 'heuristic' + str(curHeur) + ':hinterval';"/>
+								name python: 'heuristic' + str(curHeur) + ':hinterval'" />
 					</td>
+
 					<td class="systemsTable">
 						<input class="qdscore qdisk" type="text"
 							tal:attributes="
 								value heuristic/hscore;
 								id python: 'heuristic' + str(curHeur) + ':hscore';
-								name python: 'heuristic' + str(curHeur) + ':hscore';"/>
+								name python: 'heuristic' + str(curHeur) + ':hscore'" />
 					</td>
 					<td class="systemsTable">
 						<img class="qdisk deleteRow"
@@ -1264,14 +1259,15 @@
 							onClick="delete_qdisk_heur(this, document.quorum_partition);"
 							tal:attributes="
 								id python: 'heuristic' + str(curHeur) + ':hdel';
-								name python: 'heuristic' + str(curHeur) + ':hdel';"/>
+								name python: 'heuristic' + str(curHeur) + ':hdel'" />
 					</td>
 				</tr>
 				</tal:block>
 			</tbody>
+
 			<tfoot>
 				<tr class="systemsTable"><td class="systemsTable">
-					<input class="addrow" type="button" value="Add another heuristic" onClick="addHeuristic('heuristicList');">
+					<input class="addrow" type="button" value="Add another heuristic" onClick="addHeuristic('heuristicList')">
 				</td></tr>
 			</tfoot>
 		</table>
@@ -1281,10 +1277,9 @@
 		<div class="spacing configTabContent"></div>
 		<div class="hbSubmit spacing configTabContent">
 			<input type="button" value="Apply"
-				onClick="validate_form(this.form);"
-			>
+				onClick="validate_form(this.form)" />
 		</div>
-		<script tal:condition="python: clusterinfo['is_quorumd'] != 'True'">
+		<script tal:condition="not: clusterinfo/is_quorumd">
 			disableChildrenInput('quorumdisk');
 		</script>
 		</form>
--- conga/luci/cluster/validate_config_qdisk.js	2006/12/21 05:08:48	1.5
+++ conga/luci/cluster/validate_config_qdisk.js	2007/02/16 05:26:18	1.6
@@ -1,4 +1,4 @@
-var heuristic_names = [ ':hname', ':hprog', ':hinterval', ':hscore', ':hdel' ];
+var heuristic_names = [ ':hprog', ':hinterval', ':hscore', ':hdel' ];
 
 function clear_heuristic(form, heur_num) {
 	var str_prefix = 'heuristic' + heur_num;
@@ -82,26 +82,14 @@
 
 	var hstr = 'heuristic' + hnum;
 
-	var hname = document.getElementById(hstr + ':hname');
-	if (!hname || str_is_blank(hname.value)) {
-		++blank;
-		errors.push('No name was given for heuristic ' + (hnum + 1));
-		set_form_err(hname);
-	} else {
-		/* XXX sanity check the name */
-		hname = hname.value;
-		clr_form_err(hname);
-	}
-
-	var hpath = document.getElementById(hstr + ':hpath');
-	if (!hpath || str_is_blank(hpath.value)) {
+	var hprog = document.getElementById(hstr + ':hprog');
+	if (!hprog || str_is_blank(hprog.value)) {
 		++blank;
 		errors.push('No path was given for heuristic ' + (hnum + 1));
-		set_form_err(hpath);
+		set_form_err(hprog);
 	} else {
 		/* XXX sanity check the path */
-		hpath = hpath.value;
-		clr_form_err(hpath);
+		clr_form_err(hprog);
 	}
 
 	var hint = document.getElementById(hstr + ':hinterval');
@@ -110,8 +98,7 @@
 		errors.push('No interval was given for heuristic ' + (hnum + 1));
 		set_form_err(hint);
 	} else {
-		hint = hint.value;
-		if (!is_valid_int(hint, 1, null)) {
+		if (!is_valid_int(hint.value, 1, null)) {
 			errors.push('Heuristic interval values must be greater than 0.');
 			set_form_err(hint);
 		} else
@@ -124,18 +111,16 @@
 		errors.push('No score was given for heuristic ' + (hnum + 1));
 		set_form_err(hscore);
 	} else {
-		hscore = hscore.value;
-		if (!is_valid_int(hscore, 0, null)) {
+		if (!is_valid_int(hscore.value, 0, null)) {
 			errors.push('Heuristic score values must be 0 or greater.');
 			set_form_err(hscore);
 		} else
 			clr_form_err(hscore);
 	}
 
-	if (blank == 4) {
+	if (blank == 3) {
 		/* The entry is blank -- ignore it. */
-		clr_form_err(hname);
-		clr_form_err(hpath);
+		clr_form_err(hprog);
 		clr_form_err(hint);
 		clr_form_err(hscore);
 		return (null);
@@ -219,30 +204,15 @@
 				clr_form_err(form.min_score);
 		}
 
-		if (!form.device || str_is_blank(form.device.value)) {
-			errors.push('No device setting was given.');
-			set_form_err(form.device);
-		} else {
-			/* TODO: check this */
-			var device = form.device.value;
-			clr_form_err(form.device);
-		}
-
-		if (!form.label || str_is_blank(form.label.value)) {
-			errors.push('No label setting was given.');
-			set_form_err(form.label);
-		} else {
-			/* TODO: check this */
-			var label = form.device.label;
-			clr_form_err(form.label);
-		}
+		var no_dev = !form.device || str_is_blank(form.device.value);
+		var no_label = !form.label || str_is_blank(form.label.value);
+		if (no_dev && no_label)
+			errors.push('You must give either a label or a device.');
 
 		var hnum = document.getElementById('num_heuristics');
 		if (hnum) {
-			hnum = Number(hnum.value);
-			if (hnum === 0)
-				hnum++;
-			for (var i = 0 ; i < hnum ; i++) {
+			hnum = Number(hnum.value) + 1;
+			for (var i = 0 ; i <= hnum ; i++) {
 				var err = check_heuristic(i, form);
 				if (err)
 					errors = errors.concat(err);
@@ -252,6 +222,7 @@
 
 	if (error_dialog(errors))
 		return (-1);
+
 	if (confirm('Update quorum partition properties?'))
 		form.submit();
 }
@@ -275,15 +246,6 @@
 
 	var hstr = 'heuristic' + cur_hnum;
 
-	var name_td = document.createElement('td');
-	name_td.className = 'systemsTable';
-	var name_input = document.createElement('input');
-	name_input.className = 'qdname qdisk';
-	name_input.setAttribute('name', hstr + ':hname');
-	name_input.setAttribute('id', hstr + ':hname');
-	name_input.setAttribute('type', 'text');
-	name_td.appendChild(name_input);
-
 	var path_td = document.createElement('td');
 	path_td.className = 'systemsTable';
 	var path_input = document.createElement('input');
@@ -325,7 +287,6 @@
 	var tr = document.createElement('tr');
 	tr.className = 'systemsTable';
 	tr.setAttribute('id', 'heuristic' + cur_hnum);
-	tr.appendChild(name_td);
 	tr.appendChild(path_td);
 	tr.appendChild(interval_td);
 	tr.appendChild(score_td);
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/16 02:06:09	1.240
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/16 05:26:18	1.241
@@ -1013,8 +1013,16 @@
 	except KeyError, e:
 		return (False, {'errors': ['An invalid quorum partition selection was made']})
 
+	cp = model.getClusterPtr()
+	qdp = model.getQuorumdPtr()
+
 	if not qdisk_val:
-		return (True, {'messages': ['Changes accepted. - FILL ME IN']})
+		if qdp:
+			try:
+				cp.removeChild(qdp)
+			except Exception, e:
+				return (False, {'errors': [ 'Error disabling quorum partition: %s' % str(e) ] })
+		return (True, {})
 
 	try:
 		interval = int(form['interval'])
@@ -1054,22 +1062,25 @@
 
 	#Either device or label must be present
 	device = None
-	label = None
 	try:
 		device = form['device'].strip()
+	except:
+		device = None
+
+	label = None
+	try:
 		label = form['label'].strip()
-		if not device and not label:
-			raise KeyError, 'device and label are both none'
-	except KeyError, e:
+	except:
+		label = None
+
+	if not device and not label:
 		errors.append('No Device or Label value was given')
 
 	num_heuristics = 0
 	try:
-		num_heuristics = int(form['num_heuristics'])
-		if num_heuristics < 0:
-			raise ValueError, 'invalid number of heuristics: %s' % form['num_heuristics']
-		if num_heuristics == 0:
-			num_heuristics = 1
+		num_heuristics = int(form['num_heuristics']) + 1
+		if num_heuristics < 1:
+			raise ValueError, form['num_heuristics']
 	except KeyError, e:
 		errors.append('No number of heuristics was given.')
 	except ValueError, e:
@@ -1077,65 +1088,67 @@
 
 	heuristics = list()
 	for i in xrange(num_heuristics):
-		prefix = 'heuristic' + str(i) + ':'
 		try:
-			hname = form[prefix + 'hname'].strip()
-			if not hname:
-				raise KeyError(prefix + 'hname')
-		except KeyError, e:
-			if ((not prefix + 'hpath' in form or not form['hpath'].strip()) and
-				(not prefix + 'hint' in form or not form['hint'].strip()) and
-				(not prefix + 'hscore' in form or not form['hscore'].strip())):
-				# The row is blank; ignore it.
+			h = form['heuristic%d' % i]
+			if not h or len(h) != 3:
 				continue
-			errors.append('No heuristic name was given for heuristic #%d' % i + 1)
+		except:
+			continue
 
 		try:
-			hpath = form[prefix + 'hpath']
-		except KeyError, e:
-			errors.append('No heuristic path was given for heuristic #%d' % i + 1)
-
+			hprog = h[0]
+			if not hprog:
+				raise Exception, 'no hprog'
+		except Exception, e:
+			errors.append('No program was given for heuristic %d' % i + 1)
 		try:
-			hint = int(form[prefix + 'hint'])
+			hint = int(h[1])
 			if hint < 1:
 				raise ValueError, 'Heuristic interval values must be greater than 0'
 		except KeyError, e:
-			errors.append('No heuristic interval was given for heuristic #%d' % i + 1)
+			errors.append('No interval was given for heuristic #%d' % i + 1)
 		except ValueError, e:
-			errors.append('An invalid heuristic interval was given for heuristic #%d: %s' % (i + 1, str(e)))
+			errors.append('An invalid interval was given for heuristic %d: %s' \
+				% (i + 1, str(e)))
 
 		try:
-			hscore = int(form[prefix + 'score'])
+			hscore = int(h[2])
 			if hscore < 1:
 				raise ValueError, 'Heuristic scores must be greater than 0'
 		except KeyError, e:
-			errors.append('No heuristic score was given for heuristic #%d' % i + 1)
+			errors.append('No score was given for heuristic %d' % i + 1)
 		except ValueError, e:
-			errors.append('An invalid heuristic score was given for heuristic #%d: %s' % (i + 1, str(e)))
-		heuristics.append([ hname, hpath, hint, hscore ])
+			errors.append('An invalid score was given for heuristic %d: %s' \
+				% (i + 1, str(e)))
+
+		heuristics.append([ hprog, hint, hscore ])
 
 	if len(errors) > 0:
 		return (False, {'errors': errors })
 
 	qd = QuorumD()
-	qd.addAttribute('interval', interval)
-	qd.addAttribute('votes', votes)
-	qd.addAttribute('tko', tko)
-	qd.addAttribute('min_score', min_score)
+	qd.addAttribute('interval', str(interval))
+	qd.addAttribute('votes', str(votes))
+	qd.addAttribute('tko', str(tko))
+	qd.addAttribute('min_score', str(min_score))
 
 	if device:
-		qd.addAttribute('device', device)
+		qd.addAttribute('device', str(device))
 	else:
-		qd.addAttribute('label', label)
+		qd.addAttribute('label', str(label))
 
-	cp = model.getClusterPtr()
+	if qdp:
+		try:
+			cp.removeChild(qdp)
+		except:
+			pass
 	cp.addChild(qd)
 
 	for h in heuristics:
 		new_h = Heuristic()
-		new_h.addAttribute('program', h[1])
-		new_h.addAttribute('interval', h[2])
-		new_h.addAttribute('score', h[3])
+		new_h.addAttribute('program', str(h[0]))
+		new_h.addAttribute('interval', str(h[1]))
+		new_h.addAttribute('score', str(h[2]))
 		qd.addChild(new_h)
 
 	if len(errors) > 0:
@@ -1169,8 +1182,9 @@
 		version_num = int(form['cfgver'])
 		if version_num < old_ver:
 			raise ValueError, 'configuration version number must be %d or greater.' % old_ver
-		# we'll increment the cluster version before propagating it.
-		version_num -= 1
+		if version_num != old_ver:
+			# we'll increment the cluster version before propagating it.
+			version_num -= 1
 	except KeyError, e:
 		errors.append('No cluster configuration version was given.')
 	except ValueError, e:
@@ -1200,73 +1214,6 @@
 		totem = Totem()
 		cp.addChild(totem)
 
-	if form.has_key('secauth'):
-		totem.addAttribute('secauth', '1')
-	else:
-		totem.addAttribute('secauth', '0')
-
-	try:
-		rrp_mode = form['rrp_mode'].strip().lower()
-		if not rrp_mode:
-			raise KeyError, 'rrp_mode'
-		if rrp_mode != 'none' and rrp_mode != 'active' and 'rrp_mode' != 'passive':
-			raise Exception, '%s is an invalid value for redundant ring protocol mode' % rrp_mode
-		totem.addAttribute('rrp_mode', str(rrp_mode))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('rrp_mode')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		net_mtu = form['net_mtu'].strip()
-		if not net_mtu:
-			raise KeyError, 'net_mtu'
-		net_mtu = int(net_mtu)
-		if net_mtu < 1:
-			raise ValueError, '%d is an invalid value for network MTU' % net_mtu
-		totem.addAttribute('net_mtu', str(net_mtu))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('net_mtu')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		threads = form['threads'].strip()
-		if not threads:
-			raise KeyError, 'threads'
-		threads = int(threads)
-		if threads < 0:
-			raise ValueError, '%d is an invalid value for number of threads' % threads
-		totem.addAttribute('threads', str(threads))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('threads')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		vsftype = form['vsftype'].strip().lower()
-		if not vsftype:
-			raise KeyError, 'vsftype'
-		if vsftype != 'none' and vsftype != 'ykd':
-			raise ValueError, '%s is an invalid value for virtual synchrony type' % vsftype
-		totem.addAttribute('vsftype', str(vsftype))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('vsftype')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
 	try:
 		token = form['token'].strip()
 		if not token:
@@ -1284,48 +1231,16 @@
 		errors.append(str(e))
 
 	try:
-		token_retransmit = form['token_retransmit'].strip()
-		if not token_retransmit:
-			raise KeyError, 'token_retransmit'
-		token_retransmit = int(token_retransmit)
-		if token_retransmit < 1:
-			raise ValueError, '%d is an invalid value for token retransmit' % token_retransmit
-		totem.addAttribute('token_retransmit', str(token_retransmit))
+		token_retransmits_before_loss_const = form['token_retransmits_before_loss_const'].strip()
+		if not token_retransmits_before_loss_const:
+			raise KeyError, 'token_retransmits_before_loss_const'
+		token_retransmits_before_loss_const = int(token_retransmits_before_loss_const)
+		if token_retransmits_before_loss_const < 1:
+			raise ValueError, '%d is an invalid value for number of token retransmits before loss' % token_retransmits_before_loss_const
+		totem.addAttribute('token_retransmits_before_loss_const', str(token_retransmits_before_loss_const))
 	except KeyError, e:
 		try:
-			totem.removeAttribute('token_retransmit')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		hold = form['hold'].strip()
-		if not hold:
-			raise KeyError, 'hold'
-		hold = int(hold)
-		if hold < 1:
-			raise ValueError, '%d is not a valid value for hold token timeout' % hold
-		totem.addAttribute('hold', str(hold))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('hold')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		retransmits_before_loss = form['retransmits_before_loss'].strip()
-		if not retransmits_before_loss:
-			raise KeyError, 'retransmits_before_loss'
-		retransmits_before_loss = int(retransmits_before_loss)
-		if retransmits_before_loss < 1:
-			raise ValueError, '%d is an invalid value for number of retransmits before loss' % retransmits_before_loss
-		totem.addAttribute('retransmits_before_loss', str(retransmits_before_loss))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('retransmits_before_loss')
+			totem.removeAttribute('token_retransmits_before_loss_const')
 		except:
 			pass
 	except Exception, e:
@@ -1348,22 +1263,6 @@
 		errors.append(str(e))
 
 	try:
-		send_join = form['send_join'].strip()
-		if not send_join:
-			raise KeyError, 'send_join'
-		send_join = int(send_join)
-		if send_join < 0:
-			raise ValueError, '%d is an invalid value for time to wait before sending a join message' % send_join
-		totem.addAttribute('send_join', str(send_join))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('send_join')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
 		consensus = form['consensus'].strip()
 		if not consensus:
 			raise KeyError, 'consensus'
@@ -1379,182 +1278,6 @@
 	except Exception, e:
 		errors.append(str(e))
 
-	try:
-		merge = form['merge'].strip()
-		if not merge:
-			raise KeyError, 'merge'
-		merge = int(merge)
-		if merge < 1:
-			raise ValueError, '%d is an invalid value for merge detection timeout' % merge
-		totem.addAttribute('merge', str(merge))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('merge')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		downcheck = form['downcheck'].strip()
-		if not downcheck:
-			raise KeyError, 'downcheck'
-		downcheck = int(downcheck)
-		if downcheck < 1:
-			raise ValueError, '%d is an invalid value for interface down check timeout' % downcheck
-		totem.addAttribute('downcheck', str(downcheck))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('downcheck')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		fail_to_recv_const = form['fail_to_recv_const'].strip()
-		if not fail_to_recv_const:
-			raise KeyError, 'fail_to_recv_const'
-		fail_to_recv_const = int(fail_to_recv_const)
-		if fail_to_recv_const < 1:
-			raise ValueError, '%d is an invalid value for fail to receive constant' % fail_to_recv_const
-		totem.addAttribute('fail_to_recv_const', str(fail_to_recv_const))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('fail_to_recv_const')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		seqno_unchanged_const = form['seqno_unchanged_const'].strip()
-		if not seqno_unchanged_const:
-			raise KeyError, 'seqno_unchanged_const'
-		seqno_unchanged_const = int(seqno_unchanged_const)
-		if seqno_unchanged_const < 1:
-			raise ValueError, '%d is an invalid value for rotations with no multicast traffic before merge detection timeout started' % seqno_unchanged_const
-		totem.addAttribute('seqno_unchanged_const', str(seqno_unchanged_const))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('seqno_unchanged_const')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		heartbeat_failures_allowed = form['heartbeat_failures_allowed'].strip()
-		if not heartbeat_failures_allowed:
-			raise KeyError, 'heartbeat_failures_allowed'
-		heartbeat_failures_allowed = int(heartbeat_failures_allowed)
-		if heartbeat_failures_allowed < 0:
-			raise ValueError, '%d is an invalid value for number of heartbeat failures allowed' % heartbeat_failures_allowed
-		totem.addAttribute('heartbeat_failures_allowed', str(heartbeat_failures_allowed))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('heartbeat_failures_allowed')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		max_network_delay = form['max_network_delay'].strip()
-		if not max_network_delay:
-			raise KeyError, 'max_network_delay'
-		max_network_delay = int(max_network_delay)
-		if max_network_delay < 1:
-			raise ValueError, '%d is an invalid value for maximum network delay' % max_network_delay
-		totem.addAttribute('max_network_delay', str(max_network_delay))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('max_network_delay')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		window_size = form['window_size'].strip()
-		if not window_size:
-			raise KeyError, 'window_size'
-		window_size = int(window_size)
-		if window_size < 1:
-			raise ValueError, '%d is an invalid value for window size' % window_size
-		totem.addAttribute('window_size', str(window_size))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('window_size')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		max_messages = form['max_messages'].strip()
-		if not max_messages:
-			raise KeyError, 'max_messages'
-		max_messages = int(max_messages)
-		if max_messages < 1:
-			raise ValueError, '%d is an invalid value for maximum messages' % max_messages
-		totem.addAttribute('max_messages', str(max_messages))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('max_messages')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		rrp_problem_count_timeout = form['rrp_problem_count_timeout'].strip()
-		if not rrp_problem_count_timeout:
-			raise KeyError, 'rrp_problem_count_timeout'
-		rrp_problem_count_timeout = int(rrp_problem_count_timeout)
-		if rrp_problem_count_timeout < 1:
-			raise ValueError, '%d is an invalid value for RRP problem count timeout' % rrp_problem_count_timeout
-		totem.addAttribute('rrp_problem_count_timeout', str(rrp_problem_count_timeout))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('rrp_problem_count_timeout')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		rrp_problem_count_threshold = form['rrp_problem_count_threshold'].strip()
-		if not rrp_problem_count_threshold:
-			raise KeyError, 'rrp_problem_count_threshold'
-		rrp_problem_count_threshold = int(rrp_problem_count_threshold)
-		if rrp_problem_count_threshold < 1:
-			raise ValueError, '%d is an invalid value for RRP problem count threshold' % rrp_problem_count_threshold
-		totem.addAttribute('rrp_problem_count_threshold', str(rrp_problem_count_threshold))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('rrp_problem_count_threshold')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
-	try:
-		rrp_token_expired_timeout = form['rrp_token_expired_timeout'].strip()
-		if not rrp_token_expired_timeout:
-			raise KeyError, 'rrp_token_expired_timeout'
-		rrp_token_expired_timeout = int(rrp_token_expired_timeout)
-		if rrp_token_expired_timeout < 1:
-			raise ValueError, '%d is an invalid value for RRP token expired timeout' % rrp_token_expired_timeout
-		totem.addAttribute('rrp_token_expired_timeout', str(rrp_token_expired_timeout))
-	except KeyError, e:
-		try:
-			totem.removeAttribute('rrp_token_expired_timeout')
-		except:
-			pass
-	except Exception, e:
-		errors.append(str(e))
-
 	if len(errors) > 0:
 		return (False, {'errors': errors})
 	return (True, {})
@@ -4172,6 +3895,7 @@
         luci_log.debug_verbose('GCI0: unable to determine cluster name')
         return {}
 
+  clumap = {}
   if model is None:
     try:
       model = getModelForCluster(self, cluname)
@@ -4181,9 +3905,12 @@
     except Exception, e:
       luci_log.debug_verbose('GCI1: unable to get model for cluster %s: %s' % (cluname, str(e)))
       return {}
+  else:
+    totem = model.getTotemPtr()
+    if totem:
+      clumap['totem'] = totem.getAttributes()
 
   prop_baseurl = req['URL'] + '?' + PAGETYPE + '=' + CLUSTER_CONFIG + '&' + CLUNAME + '=' + cluname + '&'
-  clumap = {}
   basecluster_url = prop_baseurl + PROPERTIES_TAB + "=" + PROP_GENERAL_TAB
   #needed:
   clumap['basecluster_url'] = basecluster_url
@@ -4285,27 +4012,21 @@
       clumap['label'] = label
 
     heuristic_kids = qdp.getChildren()
-    h_ctr = 0
+
     for kid in heuristic_kids:
       hmap = {}
-      hname = kid.getAttribute('name')
-      if hname is None:
-        hname = h_ctr
-        h_ctr = h_ctr + 1
       hprog = kid.getAttribute('program')
-      hscore = kid.getAttribute('score')
-      hinterval = kid.getAttribute('interval')
       if hprog is None:
         continue
-      if hname is not None:
-        hmap['hname'] = hname
-      else:
-        hmap['hname'] = ""
+
+      hscore = kid.getAttribute('score')
       hmap['hprog'] = hprog
       if hscore is not None:
         hmap['hscore'] = hscore
       else:
         hmap['hscore'] = ""
+
+      hinterval = kid.getAttribute('interval')
       if hinterval is not None:
         hmap['hinterval'] = hinterval
       else:



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-12 23:28 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-12 23:28 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL4
Changes by:	rmccabe at sourceware.org	2007-02-12 23:28:17

Modified files:
	luci/cluster   : form-macros validate_fence.js 
	luci/site/luci/Extensions: FenceHandler.py 

Log message:
	Support the 'passwd_script' fence device attribute

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.176.2.8&r2=1.176.2.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_fence.js.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.1&r2=1.3.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.17&r2=1.17.2.1

--- conga/luci/cluster/form-macros	2007/02/09 20:33:21	1.176.2.8
+++ conga/luci/cluster/form-macros	2007/02/12 23:28:15	1.176.2.9
@@ -651,7 +651,7 @@
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#rrp_mode', 55, 65);">Redundant Ring Protocol Mode</a>
 							</td>
 							<td class="systemsTable">
-								<select name="text" name="rrp_mode">
+								<select type="text" name="rrp_mode">
 									<option value="none">
 										None
 									</option>
@@ -1489,6 +1489,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1547,6 +1558,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1596,6 +1618,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1646,6 +1679,17 @@
 						tal:attributes="value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1694,6 +1738,18 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="value nothing" />
 				</td>
+			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1743,6 +1799,17 @@
 						tal:attributes="value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1800,6 +1867,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1858,6 +1936,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1907,6 +1996,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -2046,6 +2146,17 @@
 						tal:attributes="value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -2104,6 +2215,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -2259,6 +2381,17 @@
 				</td>
 			</tr>
 			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
+			<tr>
 				<td>Authentication Type</td>
 				<td>
 					<input name="auth" type="text" title="Options are to leave blank for none, password, or md5"
@@ -4855,8 +4988,6 @@
 			<input type="hidden" name="pagetype" value="54" />
 			<input type="hidden" name="clustername"
 				tal:attributes="value request/clustername" />
-			<input type="hidden" name="orig_name"
-				tal:attributes="value request/fencename"/>
 			<input type="hidden" name="fencename"
 				tal:attributes="value request/fencename" />
 
--- conga/luci/cluster/validate_fence.js	2007/02/09 18:32:03	1.3.2.1
+++ conga/luci/cluster/validate_fence.js	2007/02/12 23:28:15	1.3.2.2
@@ -13,27 +13,27 @@
 fence_inst_validator['xvm'] = [ 'domain' ];
 
 var fence_validator = new Array();
-fence_validator['apc'] = [ 'ipaddr', 'login', 'passwd' ];
-fence_validator['bladecenter'] = [ 'ipaddr', 'login', 'passwd' ];
-fence_validator['brocade'] = [ 'ipaddr', 'login', 'passwd' ];
-fence_validator['bullpap'] = [ 'ipaddr', 'login', 'passwd' ];
-fence_validator['drac'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['apc'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
+fence_validator['bladecenter'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
+fence_validator['brocade'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
+fence_validator['bullpap'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
+fence_validator['drac'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
 fence_validator['egenera'] = [ 'cserver' ];
 fence_validator['gnbd'] = [ 'servers' ];
-fence_validator['ilo'] = [ 'hostname', 'login', 'passwd' ];
-fence_validator['ipmilan'] = [ 'ipaddr', 'login', 'passwd', 'lanplus', 'auth' ];
+fence_validator['ilo'] = [ 'hostname', 'login', 'passwd', 'passwd_script' ];
+fence_validator['ipmilan'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script', 'lanplus', 'auth' ];
 fence_validator['manual'] = [];
-fence_validator['mcdata'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['mcdata'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
 fence_validator['rps10'] = [ 'device', 'port'];
-fence_validator['rsa'] = [ 'hostname', 'login', 'passwd' ];
-fence_validator['sanbox2'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['rsa'] = [ 'hostname', 'login', 'passwd', 'passwd_script' ];
+fence_validator['sanbox2'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
 fence_validator['scsi'] = [];
 fence_validator['unknown'] = [];
-fence_validator['vixel'] = [ 'ipaddr', 'passwd' ];
-fence_validator['wti'] = [ 'ipaddr', 'passwd' ];
+fence_validator['vixel'] = [ 'ipaddr', 'passwd', 'passwd_script' ];
+fence_validator['wti'] = [ 'ipaddr', 'passwd', 'passwd_script' ];
 fence_validator['xvm'] = [];
 
-function validate_field_str(form_elem) {
+function validate_field_str(form, form_elem) {
 	var errors = new Array();
 
 	if (!form_elem || str_is_blank(form_elem.value)) {
@@ -50,26 +50,33 @@
 	return (null);
 }
 
-function validate_field_passwd(form_elem) {
+function validate_field_passwd(form, form_elem) {
 	if (form_elem.disabled) {
 		clr_form_err(form_elem);
 		return (null);
 	}
-	return validate_field_str(form_elem);
+
+	var errors = validate_field_str(form, form_elem);
+	if (errors && errors.length > 0 && form.passwd_script && !str_is_blank(form.passwd_script.value))
+	{
+		clr_form_err(form_elem);
+		return (null);
+	}
+	return errors;
 }
 
 /* Very loose checking for now -- just make sure it's not blank */
-function validate_field_host(form_elem) {
-	return (validate_field_str(form_elem));
+function validate_field_host(form, form_elem) {
+	return (validate_field_str(form, form_elem));
 }
 
-function validate_field_noop(form_elem) {
+function validate_field_noop(form, form_elem) {
 	if (form_elem)
 		clr_form_err(form_elem);
 	return (null);
 }
 
-function validate_field_ipmilan_auth(form_elem) {
+function validate_field_ipmilan_auth(form, form_elem) {
 	var errors = new Array();
 
 	if (!form_elem || str_is_blank(form_elem.value))
@@ -95,6 +102,7 @@
 field_validator['cserver'] = validate_field_str;
 field_validator['device'] = validate_field_str;
 field_validator['port'] = validate_field_str;
+field_validator['passwd_script'] = validate_field_noop;
 
 /* IPMI fence device */
 field_validator['lanplus'] = validate_field_noop;
@@ -138,7 +146,7 @@
 
 	for (var i = 0 ; i < fields.length ; i++) {
 		var field_name = fields[i];
-		var err = field_validator[field_name](form[field_name]);
+		var err = field_validator[field_name](form, form[field_name]);
 		if (err)
 			errors = errors.concat(err);
 	}
--- conga/luci/site/luci/Extensions/FenceHandler.py	2007/01/25 19:55:09	1.17
+++ conga/luci/site/luci/Extensions/FenceHandler.py	2007/02/12 23:28:16	1.17.2.1
@@ -221,16 +221,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_wti_fd(form, fencedev):
@@ -243,15 +263,35 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_IP)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_brocade_fd(form, fencedev):
@@ -271,16 +311,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_vixel_fd(form, fencedev):
@@ -293,15 +353,35 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_IP)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_mcdata_fd(form, fencedev):
@@ -321,16 +401,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_gnbd_fd(form, fencedev):
@@ -376,16 +476,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_bladecenter_fd(form, fencedev):
@@ -405,16 +525,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_bullpap_fd(form, fencedev):
@@ -434,16 +574,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_noop_fd(dummy, _dummy):
@@ -468,16 +628,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('hostname', hostname)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_drac_fd(form, fencedev):
@@ -497,16 +677,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_rps10_fd(form, fencedev):
@@ -547,11 +747,32 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	try:
@@ -578,7 +799,6 @@
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_ilo_fd(form, fencedev):
@@ -598,14 +818,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
+		if not pwd:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('hostname', hostname)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 FD_VALIDATE = {



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-12 23:26 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-12 23:26 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-02-12 23:26:54

Modified files:
	luci/cluster   : form-macros validate_fence.js 
	luci/site/luci/Extensions: FenceHandler.py 

Log message:
	Support the 'passwd_script' fence device attribute

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.186&r2=1.187
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_fence.js.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.17&r2=1.18

--- conga/luci/cluster/form-macros	2007/02/09 20:32:52	1.186
+++ conga/luci/cluster/form-macros	2007/02/12 23:26:54	1.187
@@ -651,7 +651,7 @@
 								<a class="cluster_help" href="javascript:popup_window('/luci/doc/config_rhel5#rrp_mode', 55, 65);">Redundant Ring Protocol Mode</a>
 							</td>
 							<td class="systemsTable">
-								<select name="text" name="rrp_mode">
+								<select type="text" name="rrp_mode">
 									<option value="none">
 										None
 									</option>
@@ -1489,6 +1489,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1547,6 +1558,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1596,6 +1618,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1646,6 +1679,17 @@
 						tal:attributes="value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1694,6 +1738,18 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="value nothing" />
 				</td>
+			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1743,6 +1799,17 @@
 						tal:attributes="value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1800,6 +1867,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1858,6 +1936,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -1907,6 +1996,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -2046,6 +2146,17 @@
 						tal:attributes="value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -2104,6 +2215,17 @@
 							value nothing" />
 				</td>
 			</tr>
+			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
 		</table>
 
 		<tal:block tal:condition="exists: cur_fencedev">
@@ -2259,6 +2381,17 @@
 				</td>
 			</tr>
 			<tr>
+				<td>
+					<span title="Full path to a script to generate fence password">Password Script (optional)</span>
+				</td>
+				<td>
+					<input type="text" name="passwd_script"
+						tal:attributes="
+							disabled cur_fencedev/isShared | nothing;
+							value cur_fencedev/passwd_script | nothing" />
+				</td>
+			</tr>
+			<tr>
 				<td>Authentication Type</td>
 				<td>
 					<input name="auth" type="text" title="Options are to leave blank for none, password, or md5"
@@ -4855,8 +4988,6 @@
 			<input type="hidden" name="pagetype" value="54" />
 			<input type="hidden" name="clustername"
 				tal:attributes="value request/clustername" />
-			<input type="hidden" name="orig_name"
-				tal:attributes="value request/fencename"/>
 			<input type="hidden" name="fencename"
 				tal:attributes="value request/fencename" />
 
--- conga/luci/cluster/validate_fence.js	2007/02/09 18:30:43	1.4
+++ conga/luci/cluster/validate_fence.js	2007/02/12 23:26:54	1.5
@@ -13,27 +13,27 @@
 fence_inst_validator['xvm'] = [ 'domain' ];
 
 var fence_validator = new Array();
-fence_validator['apc'] = [ 'ipaddr', 'login', 'passwd' ];
-fence_validator['bladecenter'] = [ 'ipaddr', 'login', 'passwd' ];
-fence_validator['brocade'] = [ 'ipaddr', 'login', 'passwd' ];
-fence_validator['bullpap'] = [ 'ipaddr', 'login', 'passwd' ];
-fence_validator['drac'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['apc'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
+fence_validator['bladecenter'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
+fence_validator['brocade'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
+fence_validator['bullpap'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
+fence_validator['drac'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
 fence_validator['egenera'] = [ 'cserver' ];
 fence_validator['gnbd'] = [ 'servers' ];
-fence_validator['ilo'] = [ 'hostname', 'login', 'passwd' ];
-fence_validator['ipmilan'] = [ 'ipaddr', 'login', 'passwd', 'lanplus', 'auth' ];
+fence_validator['ilo'] = [ 'hostname', 'login', 'passwd', 'passwd_script' ];
+fence_validator['ipmilan'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script', 'lanplus', 'auth' ];
 fence_validator['manual'] = [];
-fence_validator['mcdata'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['mcdata'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
 fence_validator['rps10'] = [ 'device', 'port'];
-fence_validator['rsa'] = [ 'hostname', 'login', 'passwd' ];
-fence_validator['sanbox2'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['rsa'] = [ 'hostname', 'login', 'passwd', 'passwd_script' ];
+fence_validator['sanbox2'] = [ 'ipaddr', 'login', 'passwd', 'passwd_script' ];
 fence_validator['scsi'] = [];
 fence_validator['unknown'] = [];
-fence_validator['vixel'] = [ 'ipaddr', 'passwd' ];
-fence_validator['wti'] = [ 'ipaddr', 'passwd' ];
+fence_validator['vixel'] = [ 'ipaddr', 'passwd', 'passwd_script' ];
+fence_validator['wti'] = [ 'ipaddr', 'passwd', 'passwd_script' ];
 fence_validator['xvm'] = [];
 
-function validate_field_str(form_elem) {
+function validate_field_str(form, form_elem) {
 	var errors = new Array();
 
 	if (!form_elem || str_is_blank(form_elem.value)) {
@@ -50,26 +50,33 @@
 	return (null);
 }
 
-function validate_field_passwd(form_elem) {
+function validate_field_passwd(form, form_elem) {
 	if (form_elem.disabled) {
 		clr_form_err(form_elem);
 		return (null);
 	}
-	return validate_field_str(form_elem);
+
+	var errors = validate_field_str(form, form_elem);
+	if (errors && errors.length > 0 && form.passwd_script && !str_is_blank(form.passwd_script.value))
+	{
+		clr_form_err(form_elem);
+		return (null);
+	}
+	return errors;
 }
 
 /* Very loose checking for now -- just make sure it's not blank */
-function validate_field_host(form_elem) {
-	return (validate_field_str(form_elem));
+function validate_field_host(form, form_elem) {
+	return (validate_field_str(form, form_elem));
 }
 
-function validate_field_noop(form_elem) {
+function validate_field_noop(form, form_elem) {
 	if (form_elem)
 		clr_form_err(form_elem);
 	return (null);
 }
 
-function validate_field_ipmilan_auth(form_elem) {
+function validate_field_ipmilan_auth(form, form_elem) {
 	var errors = new Array();
 
 	if (!form_elem || str_is_blank(form_elem.value))
@@ -95,6 +102,7 @@
 field_validator['cserver'] = validate_field_str;
 field_validator['device'] = validate_field_str;
 field_validator['port'] = validate_field_str;
+field_validator['passwd_script'] = validate_field_noop;
 
 /* IPMI fence device */
 field_validator['lanplus'] = validate_field_noop;
@@ -138,7 +146,7 @@
 
 	for (var i = 0 ; i < fields.length ; i++) {
 		var field_name = fields[i];
-		var err = field_validator[field_name](form[field_name]);
+		var err = field_validator[field_name](form, form[field_name]);
 		if (err)
 			errors = errors.concat(err);
 	}
--- conga/luci/site/luci/Extensions/FenceHandler.py	2007/01/25 19:55:09	1.17
+++ conga/luci/site/luci/Extensions/FenceHandler.py	2007/02/12 23:26:54	1.18
@@ -221,16 +221,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_wti_fd(form, fencedev):
@@ -243,15 +263,35 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_IP)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_brocade_fd(form, fencedev):
@@ -271,16 +311,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_vixel_fd(form, fencedev):
@@ -293,15 +353,35 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_IP)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_mcdata_fd(form, fencedev):
@@ -321,16 +401,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_gnbd_fd(form, fencedev):
@@ -376,16 +476,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_bladecenter_fd(form, fencedev):
@@ -405,16 +525,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_bullpap_fd(form, fencedev):
@@ -434,16 +574,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_noop_fd(dummy, _dummy):
@@ -468,16 +628,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('hostname', hostname)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_drac_fd(form, fencedev):
@@ -497,16 +677,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_rps10_fd(form, fencedev):
@@ -547,11 +747,32 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
 		if not pwd:
 			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	try:
@@ -578,7 +799,6 @@
 
 	fencedev.addAttribute('ipaddr', ip)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 def val_ilo_fd(form, fencedev):
@@ -598,14 +818,36 @@
 	except Exception, e:
 		errors.append(FD_PROVIDE_LOGIN)
 
+	has_passwd = False
 	try:
 		pwd = form['passwd'].strip()
+		if not pwd:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd', pwd)
+		has_passwd = True
+	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd')
+		except:
+			pass
+
+	try:
+		pwd_script = form['passwd_script'].strip()
+		if not pwd_script:
+			raise Exception, 'blank'
+		fencedev.addAttribute('passwd_script', pwd_script)
+		has_passwd = True
 	except Exception, e:
+		try:
+			fencedev.removeAttribute('passwd_script')
+		except:
+			pass
+
+	if not has_passwd:
 		errors.append(FD_PROVIDE_PASSWD)
 
 	fencedev.addAttribute('hostname', hostname)
 	fencedev.addAttribute('login', log)
-	fencedev.addAttribute('passwd', pwd)
 	return errors
 
 FD_VALIDATE = {



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-09 18:30 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-09 18:30 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-02-09 18:30:44

Modified files:
	luci/cluster   : form-macros validate_fence.js 
	luci/homebase  : form-macros homebase_common.js 
	                 validate_cluster_add.js 
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	don't let passwords get into the server's html output

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.184&r2=1.185
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_fence.js.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/form-macros.diff?cvsroot=cluster&r1=1.55&r2=1.56
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_cluster_add.js.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.48&r2=1.49

--- conga/luci/cluster/form-macros	2007/02/08 16:00:36	1.184
+++ conga/luci/cluster/form-macros	2007/02/09 18:30:43	1.185
@@ -275,7 +275,8 @@
 					<ul class="vanilla">
 						<li class="vanilla">
 							<input name="check_certs" type="checkbox"
-								tal:attributes="checked python: (add_cluster and add_cluster['check_certs']) and 'checked'" />
+								id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)" />
 							View system certificates before sending any passwords.
 						</li>
 						<li class="vanilla">
@@ -404,7 +405,7 @@
 								onChange="pwd0Change(this.form)"
 								autocomplete="off"
 								tal:attributes="
-									value sys/passwd | nothing;
+									value nothing;
 									class python: 'hbInputPass' + ('errors' in sys and ' error' or '');
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum" />
@@ -1485,7 +1486,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1543,7 +1544,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1592,7 +1593,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1642,7 +1643,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1691,7 +1692,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 		</table>
 
@@ -1739,7 +1740,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1796,7 +1797,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1854,7 +1855,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -1903,7 +1904,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -2042,7 +2043,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -2100,7 +2101,7 @@
 					<input name="passwd" type="password" autocomplete="off"
 						tal:attributes="
 							disabled cur_fencedev/isShared | nothing;
-							value cur_fencedev/passwd | nothing" />
+							value nothing" />
 				</td>
 			</tr>
 		</table>
@@ -2254,7 +2255,7 @@
 				<td>Password</td>
 				<td>
 					<input name="passwd" type="password" autocomplete="off"
-						tal:attributes="value cur_fencedev/passwd | nothing" />
+						tal:attributes="value nothing" />
 				</td>
 			</tr>
 			<tr>
@@ -3567,7 +3568,8 @@
 					<ul class="vanilla">
 						<li class="vanilla">
 							<input name="check_certs" type="checkbox"
-								tal:attributes="checked python: (add_cluster and add_cluster['check_certs']) and 'checked'" />
+								id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)" />
 							View system certificates before sending any passwords.
 						</li>
 						<li class="vanilla"
@@ -3608,7 +3610,7 @@
 								autocomplete="off"
 								onChange="pwd0Change(this.form)"
 								tal:attributes="
-									value sys/passwd | nothing;
+									value nothing;
 									class python: 'hbInputPass' + ('errors' in sys and ' error' or '');
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum" />
--- conga/luci/cluster/validate_fence.js	2007/01/25 21:03:47	1.3
+++ conga/luci/cluster/validate_fence.js	2007/02/09 18:30:43	1.4
@@ -50,6 +50,14 @@
 	return (null);
 }
 
+function validate_field_passwd(form_elem) {
+	if (form_elem.disabled) {
+		clr_form_err(form_elem);
+		return (null);
+	}
+	return validate_field_str(form_elem);
+}
+
 /* Very loose checking for now -- just make sure it's not blank */
 function validate_field_host(form_elem) {
 	return (validate_field_str(form_elem));
@@ -82,7 +90,7 @@
 field_validator['ipaddr'] = validate_field_host;
 field_validator['hostname'] = validate_field_host;
 field_validator['login'] = validate_field_str;
-field_validator['passwd'] = validate_field_str;
+field_validator['passwd'] = validate_field_passwd;
 field_validator['servers'] = validate_field_str;
 field_validator['cserver'] = validate_field_str;
 field_validator['device'] = validate_field_str;
--- conga/luci/homebase/form-macros	2007/01/29 20:43:29	1.55
+++ conga/luci/homebase/form-macros	2007/02/09 18:30:43	1.56
@@ -373,7 +373,7 @@
 								tal:attributes="
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum;
-									value sys/passwd | nothing" />
+									value nothing" />
 						</td>
 						<td class="systemsTable">
 							<img 
@@ -413,7 +413,10 @@
 			<tfoot class="systemsTable">
 				<tr class="systemsTable"><td colspan="2" class="systemsTable">
 					<ul class="vanilla">
-						<li class="vanilla"><input name="check_certs" type="checkbox">View system certificates before sending any passwords.</li>
+						<li class="vanilla">
+							<input name="check_certs" id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)"
+								type="checkbox">View system certificates before sending any passwords.</li>
 						<li class="vanilla"
 							tal:attributes="id python: cur_sysnum < 2 and 'allSameDiv' or ''">
 							<input type="checkbox" name="allSameCheckBox"
@@ -666,7 +669,7 @@
 								tal:attributes="
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum;
-									value sys/passwd | nothing" />
+									value nothing" />
 									
 						</td>
 						<td class="systemsTable">
@@ -707,7 +710,10 @@
 			<tfoot class="systemsTable">
 				<tr class="systemsTable"><td colspan="2" class="systemsTable">
 					<ul class="vanilla">
-						<li class="vanilla"><input name="check_certs" type="checkbox">View system certificates before sending any passwords.</li>
+						<li class="vanilla">
+							<input name="check_certs" id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)"
+								type="checkbox">View system certificates before sending any passwords.</li>
 						<li class="vanilla"
 							tal:attributes="id python: cur_sysnum < 2 and 'allSameDiv' or ''"><input type="checkbox" name="allSameCheckBox" id="allSameCheckBox" onClick="allPasswdsSame(this.form);"/>Check if storage system passwords are identical.</li>
 					</ul>
@@ -804,7 +810,8 @@
 					<ul class="vanilla">
 						<li class="vanilla">
 							<input name="check_certs" type="checkbox"
-								tal:attributes="checked python: add_cluster['check_certs'] and 'checked'" />
+								id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)" />
 							View system certificates before sending any passwords.
 						</li>
 						<li class="vanilla" id="allSameDiv">
@@ -848,7 +855,7 @@
 								autocomplete="off"
 								onChange="pwd0Change(this.form)"
 								tal:attributes="
-									value sys/passwd | nothing;
+									value nothing;
 									class python: 'hbInputPass' + ('errors' in sys and ' error' or '');
 									id python: '__SYSTEM%d:Passwd' % cur_sysnum;
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum" />
@@ -956,8 +963,11 @@
 						tal:condition="cur_sys" />
 
 					<ul class="vanilla">
-						<li class="vanilla"><input name="check_certs" type="checkbox">View system certificates before sending any passwords.</li>
-						<li class="vanilla"><input type="checkbox" name="allSameCheckBox" id="allSameCheckBox" onClick="allPasswdsSame(this.form);"/>Authenticate to all cluster nodes using the password provided above.</li>
+						<li class="vanilla">
+							<input name="check_certs" id="view_certs"
+								onchange="view_certs_only(this.form, this.checked)"
+								type="checkbox">View system certificates before sending any passwords.
+						</li>
 					</ul>
 				</td></tr>
 			</tfoot>
@@ -976,7 +986,7 @@
 							autocomplete="off"
 							id="__SYSTEM0:Passwd" name="__SYSTEM0:Passwd"
 							tal:attributes="
-								value cur_sys/passwd | nothing" />
+								value nothing" />
 					</td>
 					<tal:block tal:condition="cur_sys">
 						<td class="systemsTable">
--- conga/luci/homebase/homebase_common.js	2007/01/25 21:03:47	1.16
+++ conga/luci/homebase/homebase_common.js	2007/02/09 18:30:44	1.17
@@ -132,6 +132,26 @@
 	return (null);
 }
 
+function view_certs_only(form, state) {
+	var num_systems = form.numStorage.value;
+	if (!form.numStorage)
+		return (-1);
+
+	if (state) {
+		var cb = document.getElementById('allSameCheckBox');
+		if (cb && cb.checked)
+			cb.checked = false;
+	}
+
+	for (var i = 0 ; i < num_systems ; i++) {
+		var passwd = document.getElementById('__SYSTEM' + i + ':Passwd');
+		if (passwd) {
+			passwd.value = "";
+			passwd.disabled = state;
+		}
+	}
+}
+
 function allPasswdsSame(form) {
 	var cb = document.getElementById('allSameCheckBox');
 	if (!cb)
@@ -252,6 +272,12 @@
 	var added_storage = new Array();
 	var num_systems = form.numStorage.value;
 
+	var view_certs = document.getElementById('view_certs');
+	if (view_certs)
+		view_certs = view_certs.checked;
+	else
+		view_certs = false;
+
 	for (var i = 0 ; i < num_systems ; i++) {
 		var element = document.getElementById('__SYSTEM' + i + ':Addr');
 
@@ -260,18 +286,31 @@
 		element.disabled = false;
 
 		var pwdElem = document.getElementById('__SYSTEM' + i + ':Passwd');
-		if (!element.value) {
-			if (pwdElem.value) {
+		if (!element.value || str_is_blank(element.value)) {
+			if (pwdElem && pwdElem.value && !str_is_blank(pwdElem.value)) {
 				set_form_err(element);
-				if (!allSameCB.checked) {
+				if (!allSameCB || !allSameCB.checked) {
 					errors.push('You entered a password, but no hostname for system ' + (i + 1));
 					clr_form_err(pwdElem);
 				} else
 					pwdElem.value = '';
 			}
-			clr_form_err(pwdElem);
+			if (pwdElem)
+				clr_form_err(pwdElem);
+			continue;
+		}
+
+		if (view_certs) {
+			if (pwdElem) {
+				pwdElem.value = ' ';
+				pwdElem.disabled = false;
+			}
+			added_storage.push(element.value);
+			clr_form_err(element);
 			continue;
-		} else if (!pwdElem || !pwdElem.value) {
+		}
+
+		if (!pwdElem || !pwdElem.value) {
 			errors.push('No password was given for \"' + element.value + '\"');
 			set_form_err(pwdElem);
 		} else if (str_is_blank(pwdElem.value)) {
--- conga/luci/homebase/validate_cluster_add.js	2007/01/29 16:56:50	1.7
+++ conga/luci/homebase/validate_cluster_add.js	2007/02/09 18:30:44	1.8
@@ -34,13 +34,17 @@
 	if (error_dialog(errors))
 		return (-1);
 
-	var confirm_str = '';
-	if (form.addnode)
-		confirm_str = 'Add ' + (added_storage.length > 1 ? 'these nodes' : 'this node') + ' to the \"' + clusterName + '\" cluster?';
-	else
-		confirm_str = 'Add the cluster \"' + clusterName + '\" to the Luci management interface?';
+	var view_certs = document.getElementById('view_certs');
+	if (!view_certs || !view_certs.checked) {
+		var confirm_str = '';
+		if (form.addnode)
+			confirm_str = 'Add ' + (added_storage.length > 1 ? 'these nodes' : 'this node') + ' to the \"' + clusterName + '\" cluster?';
+		else
+			confirm_str = 'Add the cluster \"' + clusterName + '\" to the Luci management interface?';
 
-	if (confirm(confirm_str))
+		if (confirm(confirm_str))
+			form.submit();
+	} else
 		form.submit();
 
 	return (0);
--- conga/luci/site/luci/Extensions/homebase_adapters.py	2007/01/29 23:30:00	1.48
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2007/02/09 18:30:44	1.49
@@ -156,7 +156,7 @@
 		if len(sysData) < 2 or not sysData[1]:
 			raise Exception, 'no password'
 		cur_pass = sysData[1]
-		cur_entry['passwd'] = cur_pass
+		cur_entry['passwd'] = ''
 	except:
 		luci_log.debug_verbose('vACI1: %s no password given')
 		request.SESSION.set('add_cluster_initial', cur_entry)
@@ -338,7 +338,7 @@
 	for i in node_list:
 		cur_node = { 'host': i }
 		if same_node_passwds:
-			cur_node['passwd'] = cur_pass
+			cur_node['passwd'] = ''
 		add_cluster['nodes'][i] = cur_node
 	request.SESSION.set('add_cluster', add_cluster)
 	request.response.redirect('/luci/homebase/index_html?pagetype=%s' % HOMEBASE_ADD_CLUSTER)
@@ -382,7 +382,7 @@
 			cur_passwd = None
 		else:
 			cur_passwd = sysData[1]
-			cur_system['passwd'] = cur_passwd
+			cur_system['passwd'] = ''
 
 		try:
 			cur_fp = request.form['__SYSTEM%dFingerprint' % i].strip()



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-08  3:43 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-08  3:43 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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"):



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-08  2:34 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-08  2:34 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-02-08 02:34:36

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

Log message:
	Support for adding failover domains

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.180&r2=1.181
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_fdom.js.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FailoverDomain.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ModelBuilder.py.diff?cvsroot=cluster&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.232&r2=1.233

--- conga/luci/cluster/form-macros	2007/02/07 22:06:40	1.180
+++ conga/luci/cluster/form-macros	2007/02/08 02:34:35	1.181
@@ -4324,6 +4324,9 @@
 
 <tal:block metal:define-macro="fdom-macro">
 <script type="text/javascript"
+	src="/luci/homebase/homebase_common.js">
+</script>
+<script type="text/javascript"
 	src="/luci/cluster/validate_fdom.js">
 </script>
 
@@ -4348,8 +4351,8 @@
 			<tr class="systemsTable">
 				<td>Prioritized</td>
 				<td>
-					<input type="checkbox" name="prioritized"
-						onchange="fdom_set_prioritized(this.form, !this.checked)"
+					<input type="checkbox" name="prioritized" id="prioritized"
+						onchange="fdom_set_prioritized(this.form, this.checked)"
 						tal:attributes="checked fdom/prioritied | nothing" />
 				</td>
 			</tr>
@@ -4371,7 +4374,8 @@
 		<tfoot class="systemsTable">
 			<tr class="systemsTable"><td>
 				<div class="hbSubmit">
-					<input type="button" name="submit" value="Submit" />
+					<input type="button" name="add" value="Submit"
+						onclick="validate_add_fdom(this.form)" />
 				</div>
 			</td></tr>
 		</tfoot>
@@ -4387,12 +4391,15 @@
 					<td class="systemsTable" width="33%">
 						<tal:block tal:replace="n" />
 					<td class="systemsTable" width="10%">
-						<input type="checkbox" name="n" />
+						<input type="checkbox"
+							onchange="fdom_set_member(this.form, this.name, this.checked)"
+							tal:attributes="name n" />
 					</td>
 					<td class="systemsTable" width="75%">
 						<input type="text" class="fdom_priority"
 							tal:attributes="
-								name python: '__PRIORITY__:' + n;
+								id n;
+								name python: '__PRIORITY__' + n;
 								value from/members/n/priority | string:1;
 								disabled not:fdom/prioritied | nothing" />
 					</td>
--- conga/luci/cluster/validate_fdom.js	2007/02/07 22:06:40	1.1
+++ conga/luci/cluster/validate_fdom.js	2007/02/08 02:34:35	1.2
@@ -4,14 +4,25 @@
 		return (-1);
 	for (var i = 0 ; i < prilist.length ; i++) {
 		if (prilist[i].type == 'text' && prilist[i].className == 'fdom_priority')
-			prilist[i].disabled = state;
+			prilist[i].disabled = !state || !form[prilist[i].id][0].checked;
 	}
 }
 
+function fdom_set_member(form, name, state) {
+	var prioritized = document.getElementById('prioritized');
+	if (!prioritized)
+		return (-1);
+	prioritized = prioritized.checked;
+	var member_pri_elem = document.getElementById(name);
+	if (!member_pri_elem)
+		return (-1);
+	member_pri_elem.disabled = !prioritized || !state;
+}
+
 function validate_add_fdom(form) {
 	var errors = new Array();
 
-	if (!form.name || str_is_blank(fdom.name.value)) {
+	if (!form.name || str_is_blank(form.name.value)) {
 		set_form_err(form.name);
 		errors.append('No name was given for this failover domain.');
 	} else
--- conga/luci/site/luci/Extensions/FailoverDomain.py	2006/05/30 20:17:21	1.1
+++ conga/luci/site/luci/Extensions/FailoverDomain.py	2007/02/08 02:34:36	1.2
@@ -22,7 +22,7 @@
   def getProperties(self):
     stringbuf = ""
     restricted_status = ""
-    ordereded_status = ""
+    ordered_status = ""
     string_restricted = ""
     string_ordered = ""
     string_num_kin = ""
--- conga/luci/site/luci/Extensions/ModelBuilder.py	2007/02/07 16:55:15	1.21
+++ conga/luci/site/luci/Extensions/ModelBuilder.py	2007/02/08 02:34:36	1.22
@@ -627,10 +627,17 @@
       return list()
     else:
       return self.failoverdomains_ptr.getChildren()
-        
+
   def getFailoverDomainPtr(self):
     return self.failoverdomains_ptr
 
+  def getFailoverDomainByName(self, fdom_name):
+    fdoms = self.getFailoverDomains()
+    for i in fdoms:
+      if i.getName() == fdom_name:
+        return i
+    return None
+
   def getFailoverDomainsForNode(self, nodename):
     matches = list()
     faildoms = self.getFailoverDomains()
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/07 22:06:40	1.232
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/08 02:34:36	1.233
@@ -11,6 +11,8 @@
 from Ip import Ip
 from Clusterfs import Clusterfs
 from Fs import Fs
+from FailoverDomain import FailoverDomain
+from FailoverDomainNode import FailoverDomainNode
 from RefObject import RefObject
 from ClusterNode import ClusterNode
 from NFSClient import NFSClient
@@ -2009,6 +2011,130 @@
 
 	response.redirect(request['URL'] + "?pagetype=" + NODE + "&clustername=" + clustername + '&nodename=' + nodename + '&busyfirst=true')
 
+def validateFdom(self, request):
+	errors = list()
+	model = request.SESSION.get('model')
+
+	prioritized = False
+	try:
+		prioritized = request.form.has_key('prioritized')
+	except:
+		pass
+
+	restricted = False
+	try:
+		restricted = request.form.has_key('restricted')
+	except:
+		pass
+
+	clustername = None
+	try:
+		clustername = request.form['clustername'].strip()
+		if not clustername:
+			raise Exception, 'blank'
+	except:
+		try:
+			clustername = model.getClusterName()
+			if not clustername:
+				raise Exception, 'blank'
+		except:
+			clustername = None
+
+	if not clustername:
+		errors.append('Unable to determine this cluster\'s name.')
+
+	try:
+		name = request.form['name'].strip()
+		if not name:
+			raise Exception, 'blank'
+	except Exception, e:
+		errors.append('No name was given for this failover domain.')
+		luci_log.debug_verbose('validateFdom0: %s' % str(e))
+
+	oldname = None
+	try:
+		oldname = request.form['oldname'].strip()
+		if not oldname:
+			raise Exception, 'blank'
+	except:
+		pass
+
+	if oldname is None or oldname != name:
+		if model.getFailoverDomainByName(name) is not None:
+			errors.append('A failover domain named \"%s\" already exists.' % name)
+
+	fdom = None
+	if oldname is not None:
+		fdom = model.getFailoverDomainByName(oldname)
+		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 = FailoverDomain()
+		fdom.addAttribute('name', name)
+
+	if fdom is None:
+		return (False, {'errors': errors })
+
+	if prioritized:
+		fdom.addAttribute('ordered', '1')
+	else:
+		fdom.addAttribute('ordered', '0')
+
+	if restricted:
+		fdom.addAttribute('restricted', '1')
+	else:
+		fdom.addAttribute('restricted', '0')
+
+	cluster_nodes = map(lambda x: str(x.getName()), model.getNodes())
+
+	for i in cluster_nodes:
+		if request.form.has_key(i):
+			fdn = FailoverDomainNode()
+			fdn.addAttribute('name', i)
+			if prioritized:
+				priority = 1
+				try:
+					priority = int(request.form['__PRIORITY__' + i].strip())
+					if priority < 1:
+						priority = 1
+				except Exception, e:
+					priority = 1
+				fdn.addAttribute('priority', str(priority))
+			fdom.addChild(fdn)
+
+	try:
+		fdom_ptr = model.getFailoverDomainPtr()
+		fdom_ptr.addChild(fdom)
+		model.setModified(True)
+		conf = str(model.exportModelAsString())
+	except Exception, e:
+		luci_log.debug_verbose('validateFdom2: %s' % str(e))
+		errors.append('Unable to update the cluster configuration.')
+
+	if len(errors) > 0:
+		return (False, {'errors': errors })
+
+	rc = getRicciAgent(self, clustername)
+	if not rc:
+		luci_log.debug_verbose('validateFdom3: unable to find a ricci agent for cluster %s' % clustername)
+		return (False, {'errors': ['Unable to find a ricci agent for the %s cluster' % clustername ]})
+	ragent = rc.hostname()
+
+	batch_number, result = setClusterConf(rc, conf)
+	if batch_number is None or result is None:
+		luci_log.debug_verbose('validateFdom4: missing batch and/or result')
+		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)
+	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')
+
 def validateVM(self, request):
 	errors = list()
 
@@ -2122,6 +2248,7 @@
 	24: validateServiceAdd,
 	31: validateResourceAdd,
 	33: validateResourceAdd,
+	41: validateFdom,
 	51: validateFenceAdd,
 	54: validateFenceEdit,
 	55: validateDaemonProperties,



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-02-01 23:48 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-02-01 23:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-02-01 23:48:51

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

Log message:
	Allow addition of external GULM lockservers in the GULM properties tab after a cluster has been deployed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.171&r2=1.172
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_gulm.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.224&r2=1.225

--- conga/luci/cluster/form-macros	2007/02/01 20:49:08	1.171
+++ conga/luci/cluster/form-macros	2007/02/01 23:48:51	1.172
@@ -1291,8 +1291,45 @@
 						</td>
 					</tr>
 				</tal:block>
+
+				<tr><td colspan="2">
+					<div class="spacing" />
+					<p><em class="cluster">You may have exactly 1, 3, or 5 GULM lock servers, in any combination of the hosts checked above and given below.</em></p>
+				</td></tr>
+
+				<tr>
+					<td class="pad_right">External Lock Server 1</td>
+					<td>
+						<input type="text" name="__GULM__:server1" value="" />
+					</td>
+				</tr>
+				<tr>
+					<td class="pad_right">External Lock Server 2</td>
+					<td>
+						<input type="text" name="__GULM__:server2" value="" />
+					</td>
+				</tr>
+				<tr>
+					<td class="pad_right">External Lock Server 3</td>
+					<td>
+						<input type="text" name="__GULM__:server3" value="" />
+					</td>
+				</tr>
+				<tr>
+					<td class="pad_right">External Lock Server 4</td>
+					<td>
+						<input type="text" name="__GULM__:server4" value="" />
+					</td>
+				</tr>
+				<tr>
+					<td class="pad_right">External Lock Server 5</td>
+					<td>
+						<input type="text" name="__GULM__:server5" value="" />
+					</td>
+				</tr>
 			</tbody>
 		</table>
+
 		<div class="spacing configTabContent"></div>
 		<div class="hbSubmit spacing configTabContent">
 			<input type="button" value="Apply"
--- conga/luci/cluster/validate_config_gulm.js	2007/01/24 19:45:43	1.2
+++ conga/luci/cluster/validate_config_gulm.js	2007/02/01 23:48:51	1.3
@@ -4,9 +4,9 @@
 
 	var elem = form.getElementsByTagName('input');
 	for (var i = 0 ; i < elem.length ; i++) {
-		if (elem[i].type != 'checkbox')
-			continue;
-		if (elem[i].checked)
+		if (elem[i].type == 'text' && !str_is_blank(elem[i].value))
+			lscount++;
+		else if (elem[i].type == 'checkbox' && elem[i].checked)
 			lscount++;
 	}
 
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/01 20:49:08	1.224
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/01 23:48:51	1.225
@@ -1185,6 +1185,7 @@
 	gulm_ptr = model.getGULMPtr()
 	if not gulm_ptr:
 		return (False, {'errors': [ 'This cluster appears not to be using GULM locking.' ]})
+
 	node_list = map(lambda x: x.getName(), gulm_ptr.getChildren())
 	for i in map(lambda x: x.getName(), model.getNodes()):
 		if not i in node_list:
@@ -1197,6 +1198,17 @@
 			ls.addAttribute('name', node)
 			gulm_lockservers.append(ls)
 
+	try:
+		xlockservers = filter(lambda x: x.strip(), form['__GULM__'])
+	except:
+		xlockservers = list()
+
+	for i in xlockservers:
+		if not i in node_list:
+			ls = Lockserver()
+			ls.addAttribute('name', i)
+			gulm_lockservers.append(ls)
+
 	num_ls = len(gulm_lockservers)
 	if not num_ls in (1, 3, 5):
 		return (False, {'errors': [ 'You must have exactly 1, 3, or 5 GULM lock servers. You submitted %d lock servers.' % num_ls ]})



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
@ 2007-01-25 19:55 rmccabe
  0 siblings, 0 replies; 17+ messages in thread
From: rmccabe @ 2007-01-25 19:55 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-01-25 19:55:09

Modified files:
	luci/cluster   : form-macros validate_fence.js 
	luci/site/luci/Extensions: FenceHandler.py 

Log message:
	front-end fence validation

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.159&r2=1.160
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_fence.js.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.16&r2=1.17

--- conga/luci/cluster/form-macros	2007/01/24 20:05:38	1.159
+++ conga/luci/cluster/form-macros	2007/01/25 19:55:08	1.160
@@ -1235,7 +1235,6 @@
 	<option name="fence_egenera" value="fence_egenera">Egenera SAN Controller</option>
 	<option name="fence_bladecenter" value="fence_bladecenter">IBM Blade Center</option>
 	<option name="fence_bullpap" value="fence_bullpap">Bull PAP</option>
-	<option name="fence_rps10" value="fence_rps10">RPS10 Serial Switch</option>
 	<option name="fence_xvm" value="fence_xvm">Virtual Machine Fencing</option>
 	<option name="fence_scsi" value="fence_scsi">SCSI Fencing</option>
 </div>
@@ -4138,6 +4137,15 @@
 	<script type="text/javascript"
 		src="/luci/cluster/fence_device.js">
 	</script>
+
+	<script type="text/javascript"
+		src="/luci/homebase/homebase_common.js">
+	</script>
+
+	<script type="text/javascript"
+		src="/luci/cluster/validate_fence.js">
+	</script>
+
 	<script type="text/javascript">
 		set_page_title('Luci ??? cluster ??? fence devices - Add a new fence device');
 	</script>
@@ -4175,10 +4183,13 @@
 					<div id="fence_container">
 					</div>
 					<div class="hbSubmit">
-						<input type="submit"
-							value="Add this shared fence device" />
+						<input type="button"
+							value="Add this shared fence device"
+							onclick="validate_fence_form(this.form)" />
+
 						<input type="hidden" name="pagetype"
 							value="51" id="pagetype" />
+
 						<input type="hidden" name="clustername" id="pagetype"
 							tal:attributes="value request/clustername" />
 				</form>
@@ -4307,6 +4318,18 @@
 
 
 <div metal:define-macro="fencedev-form">
+	<script type="text/javascript">
+		set_page_title('Luci ??? cluster ??? fence devices - Configure a fence device');
+	</script>
+
+	<script type="text/javascript"
+		src="/luci/homebase/homebase_common.js">
+	</script>
+
+	<script type="text/javascript"
+		src="/luci/cluster/validate_fence.js">
+	</script>
+
 	<h2>Fence Device Form</h2>
 
 	<div class="cluster fencedev fence">
@@ -4334,7 +4357,8 @@
 				tal:attributes="value request/fencename" />
 
 			<div class="hbSubmit">
-				<input type="submit" value="Update this fence device" />
+				<input type="button" value="Update this fence device"
+					onclick="validate_fence_form(this.form)" />
 			</div>
 		</form>
 
--- conga/luci/cluster/validate_fence.js	2006/10/04 17:25:20	1.1
+++ conga/luci/cluster/validate_fence.js	2007/01/25 19:55:09	1.2
@@ -1,48 +1,153 @@
-function validate_fence_apc(form) {
-	return (0);
-}
+var fence_inst_validator = new Array();
+fence_inst_validator['apc'] = [ 'port', 'switch' ];
+fence_inst_validator['bladecenter'] = [ 'blade' ];
+fence_inst_validator['brocade'] = [ 'port' ];
+fence_inst_validator['bullpap'] = [ 'domain' ];
+fence_inst_validator['egenera'] = [ 'lpan', 'pserver' ];
+fence_inst_validator['gndb'] = [ 'ipaddress' ];
+fence_inst_validator['mcdata'] = [ 'port' ];
+fence_inst_validator['sanbox2'] = [ 'port' ];
+fence_inst_validator['scsi'] = [ 'nodename' ];
+fence_inst_validator['vixel'] = [ 'port' ];
+fence_inst_validator['wti'] = [ 'port' ];
+fence_inst_validator['xvm'] = [ 'domain' ];
+
+var fence_validator = new Array();
+fence_validator['apc'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['bladecenter'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['brocade'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['bullpap'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['drac'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['egenera'] = [ 'cserver' ];
+fence_validator['gnbd'] = [ 'servers' ];
+fence_validator['ilo'] = [ 'hostname', 'login', 'passwd' ];
+fence_validator['ipmilan'] = [ 'ipaddr', 'login', 'passwd', 'lanplus', 'auth' ];
+fence_validator['manual'] = [];
+fence_validator['mcdata'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['rps10'] = [ 'device', 'port'];
+fence_validator['rsa'] = [ 'hostname', 'login', 'passwd' ];
+fence_validator['sanbox2'] = [ 'ipaddr', 'login', 'passwd' ];
+fence_validator['scsi'] = [];
+fence_validator['unknown'] = [];
+fence_validator['vixel'] = [ 'ipaddr', 'passwd' ];
+fence_validator['wti'] = [ 'ipaddr', 'passwd' ];
+fence_validator['xvm'] = [];
+
+function validate_field_str(form_elem) {
+	var errors = new Array();
+
+	if (!form_elem || str_is_blank(form_elem.value)) {
+		if (!form_elem)
+			errors.push('No value was given for this field.');
+		else {
+			set_form_err(form_elem);
+			errors.push(form_elem.name + ' values must not be blank.');
+		}
+		return (errors);
+	}
 
-function validate_fence_wti(form) {
-	return (0);
+	clr_form_err(form_elem);
+	return (null);
 }
 
-function validate_fence_rsa(form) {
-	return (0);
+/* Very loose checking for now -- just make sure it's not blank */
+function validate_field_host(form_elem) {
+	return (validate_field_str(form_elem));
 }
 
-function validate_fence_ilo(form) {
-	return (0);
+function validate_field_noop(form_elem) {
+	if (form_elem)
+		clr_form_err(form_elem);
+	return (null);
 }
 
-function validate_fence_drac(form) {
-	return (0);
-}
+function validate_field_ipmilan_auth(form_elem) {
+	var errors = new Array();
 
-function validate_fence_ipmilan(form) {
-	return (0);
-}
+	if (!form_elem || str_is_blank(form_elem.value))
+		return (null);
 
-var fence_validator = new Object();
-fence_validator['apc'] = validate_fence_apc;
-fence_validator['wti'] = validate_fence_wti;
-fence_validator['rsa'] = validate_fence_rsa;
-fence_validator['ilo'] = validate_fence_ilo;
-fence_validator['drac'] = validate_fence_drac;
-fence_validator['ipmilan'] = validate_fence_ipmilan;
+	var auth_type = form_elem.value.strip();
+	if (auth_type != 'none' && auth_type != 'password' && auth_type != 'md5') {
+		errors.push('Auth type must be either \'none\' (or blank), \'md5\' or \'password\'');
+		set_form_err(form_elem);
+		return (errors);
+	}
 
-function validate_fence_common(form) {
+	clr_form_err(form_elem);
 	return (null);
 }
 
+var field_validator = new Object();
+field_validator['ipaddr'] = validate_field_host;
+field_validator['hostname'] = validate_field_host;
+field_validator['login'] = validate_field_str;
+field_validator['passwd'] = validate_field_str;
+field_validator['servers'] = validate_field_str;
+field_validator['cserver'] = validate_field_str;
+field_validator['device'] = validate_field_str;
+field_validator['port'] = validate_field_str;
+
+/* IPMI fence device */
+field_validator['lanplus'] = validate_field_noop;
+field_validator['auth'] = validate_field_ipmilan_auth;
+
+/* APC instance switch */
+field_validator['switch'] = validate_field_noop;
+
+field_validator['ipaddress'] = validate_field_host;
+field_validator['blade'] = validate_field_str;
+field_validator['nodename'] = validate_field_host;
+field_validator['lpan'] = validate_field_str;
+field_validator['pserver'] = validate_field_str;
+field_validator['domain'] = validate_field_str;
+
 function validate_fence(form) {
-	if (!form || !form.fence_type || !form.fence_type.value)
-		return (-1);
-	var errors = validate_fence_common(form);
-	var f = fence_validator[form.fence_type.value];
-	if (!f)
-		return (-1);
-	var err = f(form);
-	if (err)
-		errors = errors.concat(err);
+	var errors = new Array();
+
+	if (!form.fence_type || str_is_blank(form.fence_type.value))
+		errors.push('No fence device was selected.');
+
+	if (errors.length > 0)
+		return (errors);
+
+	if (!form.name || str_is_blank(form.name.value)) {
+		errors.push('A unique name must be given for all fence devices.');
+		set_form_err(form.name);
+	} else
+		clr_form_err(form.name);
+
+	if (errors.length > 0)
+		return (errors);
+
+	var fence_type = form.fence_type.value.replace(/^fence_/, '');
+	var fields = fence_validator[fence_type];
+	if (!fields)
+		errors.push('An unknown fence device type was given: \"' + fence_type + '.\"');
+
+	if (errors.length > 0)
+		return (errors);
+
+	for (var i = 0 ; i < fields.length ; i++) {
+		var field_name = fields[i];
+		var err = field_validator[field_name](form[field_name]);
+		if (err)
+			errors = errors.concat(err);
+	}
+
 	return (errors);
 }
+
+function validate_fence_form(form) {
+	var errors = validate_fence(form);
+
+	if (error_dialog(errors))
+		return (-1);
+
+	if (confirm('Update fence device properties?'))
+		form.submit();
+}
+
+function validate_fence_instance(form) {
+	var errors = new Array();
+}
--- conga/luci/site/luci/Extensions/FenceHandler.py	2007/01/20 04:50:20	1.16
+++ conga/luci/site/luci/Extensions/FenceHandler.py	2007/01/25 19:55:09	1.17
@@ -128,7 +128,7 @@
 	'fence_wti': ['name', 'ipaddr', 'passwd'],
 	'fence_brocade': ['name', 'ipaddr', 'login', 'passwd'],
 	'fence_vixel': ['name', 'ipaddr', 'passwd'],
-	'fence_gnbd': ['name', 'server'],
+	'fence_gnbd': ['name', 'servers'],
 	'fence_sanbox2': ['name', 'ipaddr', 'login', 'passwd'],
 	'fence_bladecenter': ['name', 'ipaddr', 'login', 'passwd'],
 	'fence_mcdata': ['name', 'ipaddr', 'login', 'passwd'],
@@ -337,13 +337,13 @@
 	errors = list()
 
 	try:
-		server = form['server'].strip()
+		server = form['servers'].strip()
 		if not server:
 			raise Exception, 'blank'
 	except Exception, e:
 		errors.append(FD_PROVIDE_SERVER)
 
-	fencedev.addAttribute('server', server)
+	fencedev.addAttribute('servers', server)
 	return errors
 
 def val_egenera_fd(form, fencedev):



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2007-08-24 22:01 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-09 18:32 [Cluster-devel] conga/luci cluster/form-macros cluster/validat rmccabe
  -- strict thread matches above, loose matches on Subject: below --
2007-08-24 22:01 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:30 rmccabe
2007-02-08  3:43 rmccabe
2007-02-08  2:34 rmccabe
2007-02-01 23:48 rmccabe
2007-01-25 19:55 rmccabe

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.