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

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



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2007-01-09 18:27:04

Modified files:
	luci/cluster   : fence_device.js form-macros 

Log message:
	final node-specific fence device frontend bits

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/fence_device.js.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.145&r2=1.146

--- conga/luci/cluster/fence_device.js	2007/01/08 21:58:33	1.5
+++ conga/luci/cluster/fence_device.js	2007/01/09 18:27:04	1.6
@@ -1,3 +1,6 @@
+var num_fences_level = Array(0, 0)
+var num_fence_instances = new Array()
+
 function del_fence_instance(fi_div_id) {
 	delete_element_id(fi_div_id);
 }
@@ -6,7 +9,33 @@
 	delete_element_id(fence_id);
 }
 
-function add_fence_instance(fi_cont_id) {
+function add_fence_instance(fi_cont_id, fence_type) {
+	var instance_div = document.getElementById(fi_cont_id + '_instances');
+	if (!instance_div)
+		return (-1);
+
+	var fi_form = document.getElementById(fence_type + '_instance');
+	if (fi_form) {
+		var cloned_iform = fi_form.cloneNode(1);
+		var fencei_name = fi_cont_id + '_' + num_fence_instances[fi_cont_id]++;
+		cloned_iform.id = fencei_name;
+		cloned_iform.name = fencei_name;
+		cloned_iform.className = 'fence_instance';
+
+		var form_elem = document.createElement('form');
+		form_elem.name = cloned_iform.id;
+		form_elem.appendChild(cloned_iform);
+		var ielem = cloned_iform.getElementsByTagName('input');
+		for (var i = 0 ; i < ielem.length ; i++) {
+			if (ielem[i].type == 'button' && ielem[i].name == 'remove_fence') {
+				ielem[i].setAttribute('onclick',
+					'del_fence_instance(\'' + cloned_iform.id + '\')');
+				break;
+			}
+		}
+
+		instance_div.appendChild(cloned_iform);
+	}
 }
 
 function swap_fence_div(container_id, element_id) {
@@ -82,25 +111,33 @@
 				break;
 			}
 		}
-
 		idiv.appendChild(form_elem);
 		container_element.appendChild(idiv);
+		num_fence_instances[container_id] = 1;
 	}
 
 	var remove_div = document.createElement('div');
 	remove_div.className = 'hbSubmit';
+
 	var remove_button = document.createElement('input');
 	remove_button.setAttribute('type', 'button');
-	remove_button.setAttribute('value', 'Remove this fence device');
+	remove_button.setAttribute('value', 'Remove this device');
 	remove_button.setAttribute('onclick', "del_fence('" + container_element.id + "');");
+
+	var add_instance_button = document.createElement('input');
+	add_instance_button.setAttribute('type', 'button');
+	add_instance_button.setAttribute('name', 'add_fence_inst');
+	add_instance_button.setAttribute('value', 'Add an instance');
+	add_instance_button.setAttribute('onclick', "add_fence_instance('" + container_element.id + "','" + fence_type + "');");
+	add_instance_button.className = 'pad_left';
+
 	var remove_form = document.createElement('form');
 	remove_form.appendChild(remove_button);
+	remove_form.appendChild(add_instance_button);
 	remove_div.appendChild(remove_form);
 	container_element.appendChild(remove_div);
 }
 
-var num_fences_level = Array(0, 0)
-
 function add_node_fence_device(fence_level) {
 	var cont_name = 'fence_list_level' + fence_level;
 	var container = document.getElementById(cont_name);
--- conga/luci/cluster/form-macros	2007/01/08 21:58:33	1.145
+++ conga/luci/cluster/form-macros	2007/01/09 18:27:04	1.146
@@ -1283,16 +1283,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_apc" />
 	</div>
 </div>
@@ -1351,16 +1341,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_mcdata" />
 	</div>
 </div>
@@ -1410,16 +1390,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_wti" />
 	</div>
 </div>
@@ -1624,16 +1594,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_brocade" />
 	</div>
 </div>
@@ -1687,16 +1647,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_sanbox2" />
 	</div>
 </div>
@@ -1746,16 +1696,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_vixel" />
 	</div>
 </div>
@@ -1796,16 +1736,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_gnbd" />
 	</div>
 </div>
@@ -1855,16 +1785,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_egenera" />
 	</div>
 </div>
@@ -1915,16 +1835,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_bladecenter" />
 	</div>
 </div>
@@ -1983,16 +1893,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="fence_bullpap" />
 	</div>
 </div>
@@ -2066,16 +1966,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="xvm" />
 	</div>
 </div>
@@ -2107,16 +1997,6 @@
 		</tal:block>
 
 		<input type="hidden" name="sharable" value="1" />
-		<tal:block tal:condition="exists: cur_fencedev">
-			<tal:block tal:condition="exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances"
-					tal:attributes="
-						value python: len(cur_fencedev['instance_list'])" />
-			</tal:block>
-			<tal:block tal:condition="not:exists: cur_fencedev/instance_list">
-				<input type="hidden" name="num_instances" value="1" />
-			</tal:block>
-		</tal:block>
 		<input type="hidden" name="fence_type" value="scsi" />
 	</div>
 </div>
@@ -2277,8 +2157,11 @@
 </tal:block>
 </div>
 
-<div metal:define-macro="fence-instance-form-apc">
-	<div id="fence_apc_instance" name="fence_apc" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-apc"
+	tal:omit-tag="exists: cur_fence_dev_id">
+
+	<div id="fence_apc_instance" name="fence_apc" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>Port</td>
@@ -2316,8 +2199,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-egenera">
-	<div id="fence_egenera_instance" name="fence_egenera" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-egenera"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_egenera_instance" name="fence_egenera" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>lpan</td>
@@ -2355,8 +2240,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-wti">
-	<div id="fence_wti_instance" name="fence_wti" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-wti"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_wti_instance" name="fence_wti" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>Port</td>
@@ -2387,8 +2274,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-brocade">
-	<div id="fence_brocade_instance" name="fence_brocade" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-brocade"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_brocade_instance" name="fence_brocade" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>Port</td>
@@ -2419,8 +2308,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-vixel">
-	<div id="fence_vixel_instance" name="fence_vixel" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-vixel"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_vixel_instance" name="fence_vixel" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>Port</td>
@@ -2451,8 +2342,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-sanbox2">
-	<div id="fence_sanbox2_instance" name="fence_sanbox2" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-sanbox2"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_sanbox2_instance" name="fence_sanbox2" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>Port</td>
@@ -2483,8 +2376,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-mcdata">
-	<div id="fence_mcdata_instance" name="fence_mcdata" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-mcdata"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_mcdata_instance" name="fence_mcdata" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>Port</td>
@@ -2515,8 +2410,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-gndb">
-	<div id="fence_gnbd_instance" name="fence_gnbd" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-gndb"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_gnbd_instance" name="fence_gnbd" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>IP Address</td>
@@ -2547,8 +2444,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-bladecenter">
-	<div id="fence_bladecenter_instance" name="fence_bladecenter" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-bladecenter"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_bladecenter_instance" name="fence_bladecenter" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>Blade</td>
@@ -2579,8 +2478,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-bullpap">
-	<div id="fence_bullpap_instance" name="fence_bullpap" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-bullpap"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_bullpap_instance" name="fence_bullpap" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>Domain</td>
@@ -2611,8 +2512,10 @@
 	</div>
 </div>
 
-<div metal:define-macro="fence-instance-form-xvm">
-	<div id="fence_xvm_instance" name="fence_xvm" class="fencedev_instance">
+<div metal:define-macro="fence-instance-form-xvm"
+	tal:omit-tag="exists: cur_fence_dev_id">
+	<div id="fence_xvm_instance" name="fence_xvm" class="fencedev_instance"
+		tal:omit-tag="exists: cur_fence_dev_id">
 		<table>
 			<tr>
 				<td>Domain</td>
@@ -2965,11 +2868,6 @@
 
 								<form tal:attributes="name cur_fence_dev_id | string:[unknown]">
 									<tal:block metal:use-macro="here/form-macros/macros/fencedev-cond-ladder" />
-									<tal:block tal:condition="exists: cur_fencedev/instance_list">
-										<input type="hidden"
-											name="num_instances"
-											tal:attributes="value python: len(cur_fencedev['instance_list'])" />
-									</tal:block>
 								</form>
 
 								<tal:block
@@ -2977,6 +2875,7 @@
 
 								<div tal:attributes="id python: cur_fence_dev_id + '_instances'">
 									<tal:block tal:condition="exists: cur_fencedev/instance_list">
+										<tal:block tal:replace="structure python: '<script type='+chr(0x22)+'text/javascript'+chr(0x22)+'>num_fence_instances[\'' + cur_fence_dev_id + '\'] = ' + str(len(cur_fencedev['instance_list'])) + ';</script>'" />
 										<tal:block tal:repeat="cur_instance cur_fencedev/instance_list">
 											<tal:block
 												tal:define="global cur_fence_instance_id python: cur_fence_dev_id + '_' + str(cur_instance_num)" />
@@ -2998,9 +2897,13 @@
 								</div>
 								<div class="hbSubmit">
 									<input type="button" name="remove_fence_dev"
-										value="Remove this fence device"
+										value="Remove this device"
 										tal:attributes="
 											onclick python: 'del_fence(\'' + cur_fence_dev_id + '\')'" />
+									<input tal:condition="exists: cur_fencedev/isShared"
+										name="add_instance" type="button"
+										value="Add an instance"
+										tal:attributes="onclick python: 'add_fence_instance(\'' + cur_fence_dev_id + '\',\'' + cur_fence_type + '\')'" />
 								</div>
 								<tal:block tal:define="global cur_fence_num python: cur_fence_num + 1" />
 							</tal:block>
@@ -3041,6 +2944,7 @@
 
 								<div tal:attributes="id python: cur_fence_dev_id + '_instances'">
 									<tal:block tal:condition="exists: cur_fencedev/instance_list">
+										<tal:block tal:replace="structure python: '<script type='+chr(0x22)+'text/javascript'+chr(0x22)+'>num_fence_instances[\'' + cur_fence_dev_id + '\'] = ' + str(len(cur_fencedev['instance_list'])) + ';</script>'" />
 										<tal:block tal:repeat="cur_instance cur_fencedev/instance_list">
 											<tal:block
 												tal:define="global cur_fence_instance_id python: cur_fence_dev_id + '_' + str(cur_instance_num)" />
@@ -3062,9 +2966,13 @@
 								</div>
 								<div class="hbSubmit">
 									<input type="button" name="remove_fence_dev"
-										value="Remove this fence device"
+										value="Remove this device"
 										tal:attributes="
 											onclick python: 'del_fence(\'' + cur_fence_dev_id + '\')'" />
+									<input tal:condition="exists: cur_fencedev/isShared"
+										name="add_instance" type="button"
+										value="Add an instance"
+										tal:attributes="onclick python: 'add_fence_instance(\'' + cur_fence_dev_id + '\',\'' + cur_fence_type + '\')'" />
 								</div>
 								<tal:block tal:define="global cur_fence_num python: cur_fence_num + 1" />
 							</tal:block>


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