From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/fence_device.js cluster/for ...
Date: 25 Jan 2007 21:03:48 -0000 [thread overview]
Message-ID: <20070125210348.29434.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-01-25 21:03:47
Modified files:
luci/cluster : fence_device.js form-macros validate_fence.js
luci/homebase : homebase_common.js
Log message:
more frontend fence validation
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/fence_device.js.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.160&r2=1.161
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_fence.js.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.15&r2=1.16
--- conga/luci/cluster/fence_device.js 2007/01/17 03:52:16 1.10
+++ conga/luci/cluster/fence_device.js 2007/01/25 21:03:46 1.11
@@ -190,48 +190,3 @@
container.appendChild(div_elem);
num_fences_level[fence_level - 1]++;
}
-
-function validate_fence(master_form, container_id) {
- var errors = new Array();
- var div_elem = document.getElementById(container_id);
- if (!div_elem)
- return (-1);
- var form_xml = '';
-
- var form = div_elem.getElementsByTagName('form');
- for (var i = 0 ; i < form.length ; i++) {
- var input_elem = form[i].getElementsByTagName('input');
- var temp = '';
- for (var j = 0 ; j < input_elem.length ; j++) {
- var res_type = input_elem[j].type;
- if (res_type == 'hidden' || res_type == 'text' ||
- res_type == 'password')
- {
- temp += '<input type="' + res_type + '" name="' + input_elem[j].name + '" value="' + input_elem[j].value + '" />';
- } else if (res_type == 'checkbox' || res_type == 'radio') {
- if (input_elem[j].checked) {
- temp += '<input type="' + res_type + '" name="' + input_elem[j].name + '"';
- if (res_type == 'checkbox')
- temp += ' value="1"';
- else if (res_type == 'radio')
- temp += ' value="' + input_elem[j].value + '"';
- temp += ' />';
- } else if (res_type == 'checkbox') {
- temp += '<input type="' + res_type + '" name="' + input_elem[j].name + '" value="0" />';
- }
- }
- }
-
- var select_elem = form[i].getElementsByTagName('select');
- for (var j = 0 ; j < select_elem.length ; j++) {
- temp += '<input type="text" name="' + select_elem[j].name + '" value="' + select_elem[j].options[select_elem[j].options.selectedIndex].value + '" />';
- }
-
- form_xml += '<form id="' + form[i].getAttribute('name') + '">' + temp + '</form>';
- }
-
- master_form.fence_xml.value = '<formlist>' + form_xml + '</formlist>';
-
- if (confirm('Update this node\'s fence configuration?'))
- master_form.submit();
-}
--- conga/luci/cluster/form-macros 2007/01/25 19:55:08 1.160
+++ conga/luci/cluster/form-macros 2007/01/25 21:03:47 1.161
@@ -2270,6 +2270,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_apc" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2312,6 +2313,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_egenera" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2347,6 +2349,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_wti" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2382,6 +2385,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_brocade" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2417,6 +2421,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_vixel" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2452,6 +2457,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_sanbox2" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2487,6 +2493,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_mcdata" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2522,6 +2529,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_gnbd" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2557,6 +2565,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_bladecenter" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2592,6 +2601,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_bullpap" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2614,6 +2624,7 @@
</tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_scsi" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2649,6 +2660,7 @@
</td></tr>
</table>
+ <input type="hidden" name="fence_type" value="fence_xvm" />
<input type="hidden" name="fence_instance" value="1" />
<input tal:condition="exists: cur_instance"
type="hidden" name="existing_instance" value="1" />
@@ -2755,6 +2767,9 @@
<script type="text/javascript"
src="/luci/cluster/fence_device.js">
</script>
+ <script type="text/javascript"
+ src="/luci/cluster/validate_fence.js">
+ </script>
<script type="text/javascript">
set_page_title('Luci ??? cluster ??? nodes ??? properties');
</script>
@@ -2866,7 +2881,8 @@
<tfoot class="systemsTable">
<tr class="systemsTable"><td class="systemsTable" colspan="3">
<div class="systemsTableEnd">
- <input type="Submit" value="Update node daemon properties" />
+ <input type="button" value="Update node daemon properties"
+ onclick="if (confirm('Update daemon properties?')) this.form.submit()" />
</div>
</td></tr>
</tfoot>
@@ -3137,7 +3153,7 @@
<input type="hidden" name="pagetype" value="58" />
<input type="button"
value="Update main fence properties"
- onclick="validate_fence(this.form, 'fence_list_level1')" />
+ onclick="validate_node_fence_form(this.form, 'fence_list_level1')" />
</form>
</div>
</td>
@@ -3153,7 +3169,7 @@
<input type="hidden" name="pagetype" value="58" />
<input type="button"
value="Update backup fence properties"
- onclick="validate_fence(this.form, 'fence_list_level2')" />
+ onclick="validate_node_fence_form(this.form, 'fence_list_level2')" />
</form>
</div>
</td>
@@ -4371,7 +4387,8 @@
<input type="hidden" name="orig_name"
tal:attributes="value request/fencename" />
<div class="hbSubmit">
- <input type="submit" value="Delete this fence device" />
+ <input type="button" value="Delete this fence device"
+ onclick="if (confirm('Delete this fence device?')) this.form.submit()" />
</div>
</form>
</div>
--- conga/luci/cluster/validate_fence.js 2007/01/25 19:55:09 1.2
+++ conga/luci/cluster/validate_fence.js 2007/01/25 21:03:47 1.3
@@ -67,7 +67,7 @@
if (!form_elem || str_is_blank(form_elem.value))
return (null);
- var auth_type = form_elem.value.strip();
+ var auth_type = form_elem.value;
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);
@@ -78,7 +78,7 @@
return (null);
}
-var field_validator = new Object();
+var field_validator = new Array();
field_validator['ipaddr'] = validate_field_host;
field_validator['hostname'] = validate_field_host;
field_validator['login'] = validate_field_str;
@@ -150,4 +150,82 @@
function validate_fence_instance(form) {
var errors = new Array();
+
+ if (!form.fence_type || str_is_blank(form.fence_type.value))
+ errors.push('The fence device associated with this instance could not be determined.');
+
+ if (errors.length > 0)
+ return (errors);
+
+ var fence_type = form.fence_type.value.replace(/^fence_/, '');
+ var fields = fence_inst_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_node_fence_form(master_form, container_id) {
+ var errors = new Array();
+ var div_elem = document.getElementById(container_id);
+ if (!div_elem)
+ return (-1);
+ var form_xml = '';
+
+ var form = div_elem.getElementsByTagName('form');
+ for (var i = 0 ; i < form.length ; i++) {
+ var err = null;
+ if (form[i].fence_instance)
+ err = validate_fence_instance(form[i]);
+ else if (form[i].fence_type)
+ err = validate_fence(form[i]);
+ if (err)
+ errors = errors.concat(err);
+ var input_elem = form[i].getElementsByTagName('input');
+ var temp = '';
+ for (var j = 0 ; j < input_elem.length ; j++) {
+ var res_type = input_elem[j].type;
+ if (res_type == 'hidden' || res_type == 'text' ||
+ res_type == 'password')
+ {
+ temp += '<input type="' + res_type + '" name="' + input_elem[j].name + '" value="' + input_elem[j].value + '" />';
+ } else if (res_type == 'checkbox' || res_type == 'radio') {
+ if (input_elem[j].checked) {
+ temp += '<input type="' + res_type + '" name="' + input_elem[j].name + '"';
+ if (res_type == 'checkbox')
+ temp += ' value="1"';
+ else if (res_type == 'radio')
+ temp += ' value="' + input_elem[j].value + '"';
+ temp += ' />';
+ } else if (res_type == 'checkbox') {
+ temp += '<input type="' + res_type + '" name="' + input_elem[j].name + '" value="0" />';
+ }
+ }
+ }
+
+ var select_elem = form[i].getElementsByTagName('select');
+ for (var j = 0 ; j < select_elem.length ; j++) {
+ temp += '<input type="text" name="' + select_elem[j].name + '" value="' + select_elem[j].options[select_elem[j].options.selectedIndex].value + '" />';
+ }
+
+ form_xml += '<form id="' + form[i].getAttribute('name') + '">' + temp + '</form>';
+ }
+
+ master_form.fence_xml.value = '<formlist>' + form_xml + '</formlist>';
+
+ if (error_dialog(errors))
+ return (-1);
+
+ if (confirm('Update this node\'s fence configuration?'))
+ master_form.submit();
}
--- conga/luci/homebase/homebase_common.js 2006/12/21 05:08:48 1.15
+++ conga/luci/homebase/homebase_common.js 2007/01/25 21:03:47 1.16
@@ -5,7 +5,7 @@
function clr_form_err(ielem) {
if (ielem)
- ielem.className = ielem.className.replace(/ formerror/, '');
+ ielem.className = ielem.className.replace(/( )?formerror/, '');
}
function toggle_visible(img_obj, elem_id, label_id) {
next reply other threads:[~2007-01-25 21:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-25 21:03 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-08-08 21:18 [Cluster-devel] conga/luci cluster/fence_device.js cluster/for rmccabe
2007-01-10 23:49 rmccabe
2007-01-10 23:47 rmccabe
2007-01-10 22:53 rmccabe
2007-01-08 21:58 rmccabe
2007-01-05 23:44 rmccabe
2006-12-01 14:56 rmccabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070125210348.29434.qmail@sourceware.org \
--to=rmccabe@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).