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

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



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe 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):


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