Skip to contentSkip to conversation

conga luci/cluster/form-macros luci/homebase/v ...

Cluster-devel [email protected] 1 participant 1 message Dec 11, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Branch: RHEL5
Changes by: rmccabe at sourceware.org 2006-12-11 23:58:01

Modified files:
luci/cluster : form-macros
luci/homebase : validate_cluster_add.js luci/site/luci/Extensions: cluster_adapters.py ricci_bridge.py ricci/modules/cluster: ClusterConf.cpp

Log message:

	Related: bz212021, bz218941, bz219156

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.90.2.7&r2=1.90.2.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_cluster_add.js.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4&r2=1.4.2.1
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.13&r2=1.120.2.14
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.30.2.11&r2=1.30.2.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterConf.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.8&r2=1.8.2.1

luci/cluster/form-macros +95 -43
@@ -1325,7 +1325,7 @@
 				<td>Hostname</td>
 				<td>
 					<input name="hostname" type="text"
-						tal:attributes="value cur_fencedev/hostname | nothing" />
+						tal:attributes="value cur_fencedev/hostname | cur_fencedev/ipaddr | nothing" />
 				</td>
 			</tr>
 			<tr>
@@ -2299,9 +2299,7 @@
 		global nodestatus python: here.getClusterStatus(request, ricci_agent);
 		global nodeinfo python: here.getNodeInfo(modelb, nodestatus, request);
 		global status_class python: 'node_' + (nodeinfo['nodestate'] == '0' and 'active' or (nodeinfo['nodestate'] == '1' and 'inactive' or 'unknown'));
-		global cluster_node_status_str python: (nodeinfo['nodestate'] == '0' and 'Cluster member' or (nodeinfo['nodestate'] == '1' and 'Currently not a cluster participant' or 'This node is not responding'));
-		global fenceinfo python: here.getFenceInfo(modelb, request);
-		global fencedevinfo python: here.getFencesInfo(modelb, request)"
+		global cluster_node_status_str python: (nodeinfo['nodestate'] == '0' and 'Cluster member' or (nodeinfo['nodestate'] == '1' and 'Currently not a cluster participant' or 'This node is not responding'))"
 	/>
 
 	 <table class="cluster node" width="100%">
@@ -2320,14 +2318,20 @@
 				<form method="post" onSubmit="return dropdown(this.gourl)">
 				<select name="gourl">
 					<option value="">Choose a Task...</option>
-					<option tal:attributes="value nodeinfo/jl_url">
+					<option tal:attributes="value nodeinfo/jl_url"
+						tal:condition="python: not 'ricci_error' in nodeinfo">
 						Have node <span tal:replace="python: nodeinfo['nodestate'] == '0' and 'leave' or 'join'" /> cluster
 					</option>
 					<option value="">----------</option>
 					<option tal:attributes="value nodeinfo/fence_url">Fence this node</option>
-					<option value="" tal:attributes="value nodeinfo/reboot_url">Reboot this node</option>
+					<option value="" tal:attributes="value nodeinfo/reboot_url"
+						tal:condition="python: not 'ricci_error' in nodeinfo">
+						Reboot this node
+					</option>
 					<option value="">----------</option>
-					<option tal:attributes="value nodeinfo/delete_url">Delete this node</option>
+					<option tal:attributes="value nodeinfo/delete_url"
+						tal:condition="python: not 'ricci_error' in nodeinfo">
+						Delete this node</option>
 				</select>
 				<input type="submit" value="Go"/>
 				</form>
@@ -2344,7 +2348,7 @@
 		</tr>
 
 		<tr class="cluster node info_bottom"
-			tal:condition="python: nodeinfo['nodestate'] == '0' or nodeinfo['nodestate'] == '1'">
+			tal:condition="python: (nodeinfo['nodestate'] == '0' or nodeinfo['nodestate'] == '1') and not 'ricci_error' in nodeinfo">
 			<td class="cluster node node_log" colspan="2">
 				<a class="cluster node"
 					tal:attributes="href nodeinfo/logurl" onClick="return popup_log(this, 'notes')">
@@ -2354,6 +2358,7 @@
 		</tr>
 	</table>
 
+	<tal:block tal:condition="python: not 'ricci_error' in nodeinfo">
 	<hr/>
 
 	<tal:block
@@ -2443,6 +2448,10 @@
 		<tal:block metal:use-macro="here/form-macros/macros/fence-form-list" />
 	</div>
 
+	<tal:block tal:define="
+		global fenceinfo python: here.getFenceInfo(modelb, request);
+		global fencedevinfo python: here.getFencesInfo(modelb, request)" />
+
 	<div class="invisible" id="shared_fence_devices">
 		<tal:block tal:repeat="cur_fencedev fencedevinfo/fencedevs">
 			<tal:block metal:use-macro="here/form-macros/macros/shared-fence-device-list" />
@@ -2494,36 +2503,67 @@
 		</tr>
 
 		<tr class="cluster node info_top fence">
-			<td class="cluster node fence_main fence"><div class="fence_container">
-				<div id="fence_list_level1">
-					<tal:comment tal:replace="nothing">
-						XXX - fill in any existing fence devices for this node
-						and update the counter number for this level
-					</tal:comment>
+			<td class="cluster node fence_main fence">
+				<div class="fence_container">
+				<div id="fence_list_level1" tal:define="global cur_fence_num python: 0">
+					<tal:block tal:condition="exists: fenceinfo/level1">
+						<tal:block tal:repeat="cur_fencedev fenceinfo/level1">
+							<tal:block tal:define="
+								cur_fence_type cur_fencedev/agent | nothing;
+								cur_fence_level python: 1;">
+								<div tal:attributes="id python: 'fence1_' + str(cur_fence_num)">
+									<tal:block
+										metal:use-macro="here/form-macros/macros/fencedev-cond-ladder" />
+								</div>
+							</tal:block>
+							<tal:block tal:define="global cur_fence_num python: cur_fence_num + 1" />
+						</tal:block>
+					</tal:block>
+					<tal:block
+						tal:replace="structure python: '<script type='+chr(0x22)+'text/javascript'+chr(0x22)+'>num_fences_level[0] = ' + str(cur_fence_num) + ';</script>'" />
 				</div>
 
 				<div class="fence_control">
 					<input type="button" value="Add a fence to this level"
 						onclick="add_node_fence_device(1);" />
 				</div>
-			</div></td>
+				</div>
+			</td>
 
-			<td class="cluster node fence_main fence"><div class="fence_container">
-				<div id="fence_list_level2">
-					<tal:comment tal:replace="nothing">
-						XXX - fill in any existing fence devices for this node
-						and update the counter number for this level
-					</tal:comment>
+			<td class="cluster node fence_main fence">
+				<div class="fence_container">
+				<div id="fence_list_level2" tal:define="global cur_fence_num python: 0">
+					<tal:block tal:condition="exists: fenceinfo/level2">
+						<tal:block tal:repeat="cur_fencedev fenceinfo/level2">
+							<tal:block tal:define="cur_fence_type cur_fencedev/agent | nothing">
+								<div tal:attributes="id python: 'fence2_' + str(cur_fence_num)">
+									<tal:block
+										metal:use-macro="here/form-macros/macros/fencedev-cond-ladder" />
+								</div>
+							</tal:block>
+							<tal:block tal:define="global cur_fence_num python: cur_fence_num + 1" />
+						</tal:block>
+					</tal:block>
+					<tal:block
+						tal:replace="structure python: '<script type='+chr(0x22)+'text/javascript'+chr(0x22)+'>num_fences_level[1] = ' + str(cur_fence_num) + ';</script>'" />
 				</div>
 
 				<div class="fence_control">
 					<input type="button" value="Add a fence to this level"
 						onclick="add_node_fence_device(2)" />
 				</div>
-			</div></td>
+				</div>
+			</td>
 		</tr>
 		</tbody>
 	</table>
+	</tal:block>
+	<tal:block tal:condition="python: 'ricci_error' in nodeinfo">
+		<hr/>
+		<strong class="errmsgs">
+			The ricci agent for this node is unresponsive. Node-specific information is not available at this time.
+		</strong>
+	</tal:block>
 </div>
 
 <div metal:define-macro="nodes-form">
@@ -2671,6 +2711,7 @@
 	<form name="adminform" action="" method="post">
 		<input name="numStorage" type="hidden" value="1" />
 		<input name="pagetype" type="hidden" value="15" />
+		<input name="addnode" type="hidden" value="1" />
 		<input type="hidden" name="clusterName"
 			tal:attributes="
 				value request/form/clusterName | request/clustername | nothing"
@@ -2740,11 +2781,19 @@
 
 <div metal:define-macro="nodeprocess-form">
 	<tal:block
-		tal:define="result python: here.nodeTaskProcess(modelb, request)"/>
+		tal:define="result python: here.nodeTaskProcess(modelb, request)">
 
-	<div>
-		<span tal:replace="result | nothing" />
-	</div>
+		<div id="errmsgsdiv" class="errmsgs"
+			tal:condition="python: result and len(result) > 1 and 'errors' in result[1]">
+            <p class="errmsgs">The following errors occurred:</p>
+
+            <ul class="errmsgs">
+                <tal:block tal:repeat="e python: result[1]['errors']">
+                    <li class="errmsgs" tal:content="python:e" />
+                </tal:block>
+            </ul>
+        </div>
+	</tal:block>
 </div>
 
 <div metal:define-macro="services-form">
@@ -3430,20 +3479,7 @@
 	</tal:block>
 </div>
 
-<div metal:define-macro="fencedev-form">
-	<h2>Fence Device Form</h2>
-
-	<div class="cluster fencedev">
-  <tal:block tal:define="
-		global cur_fencename request/fencename | nothing;
-		global cur_cluster request/clustername | nothing;
-		global cur_fence_type python: 'fence_apc'"/>
-
-  <span tal:condition="cur_fencename">
-    <span tal:define="global cur_fencedev python:here.getFence(modelb,request);
-                      global cur_fence_type cur_fencedev/agent"/>
-  </span>
-	
+<div metal:define-macro="fencedev-cond-ladder">
 	<tal:block tal:condition="python: cur_fence_type == 'fence_apc'">
 		<tal:block metal:use-macro="here/form-macros/macros/fence-form-apc" />
 	</tal:block>
@@ -3515,10 +3551,26 @@
 	<tal:block tal:condition="python: cur_fence_type == 'fence_manual'">
 		<tal:block metal:use-macro="here/form-macros/macros/fence-form-manual" />
 	</tal:block>
+</div>
 
-	<div class="fence_submit">
-		<input class="hbInput" type="button" value="Submit" name="Submit" />
-	</div>
+
+<div metal:define-macro="fencedev-form">
+	<h2>Fence Device Form</h2>
+
+	<div class="cluster fencedev">
+		<tal:block tal:define="
+			global cur_fencename request/fencename | nothing;
+			global cur_cluster request/clustername | nothing;
+			global cur_fence_type python: 'fence_apc'"/>
+
+		<span tal:condition="cur_fencename">
+			<span tal:define="
+					global cur_fencedev python:here.getFence(modelb,request);
+					global cur_fence_type cur_fencedev/agent" />
+		</span>
+	
+		<tal:block
+			metal:use-macro="here/form-macros/macros/fencedev-cond-ladder" />
 	</div>
 </div>
 
luci/homebase/validate_cluster_add.js +7 -1
@@ -29,7 +29,13 @@
 	if (error_dialog(errors))
 		return (-1);
 
-	if (confirm('Add the cluster \"' + clusterName + '\" to the Luci management interface?'))
+	var confirm_str = '';
+	if (form.addnode)
+		confirm_str = 'Add node' + (added_storage.length > 1 ? 's' : '') + ' to the \"' + clusterName + '\" cluster?';
+	else
+		confirm_str = 'Add the cluster \"' + clusterName + '\" to the Luci management interface?';
+
+	if (confirm(confirm_str))
 		form.submit();
 
 	return (0);
luci/site/luci/Extensions/cluster_adapters.py +177 -68

444 lines not on this page · raw message

luci/site/luci/Extensions/ricci_bridge.py +26 -12
@@ -1,7 +1,7 @@
 import xml
 from time import time, ctime
 from xml.dom import minidom
-from ricci_communicator import RicciCommunicator
+from ricci_communicator import RicciCommunicator, extract_module_status
 from LuciSyslog import LuciSyslog
 
 try:
@@ -10,23 +10,37 @@
 	pass
 
 def checkBatch(rc, batch_id):
+	err_msg = 'An unknown Ricci error occurred on %s' % rc.hostname()
+
 	try:
 		batch = rc.batch_report(batch_id)
 		if batch is None:
-			return True
-	except:
-		return False
+			return (True, 'batch id was not found')
+	except Exception, e:
+		luci_log.debug_verbose('checkBatch0: %s: %s' % (rc.hostname(), str(e)))
+		return (-1, err_msg)
 
 	try:
-		dummy = batch.getAttribute('batch_id')
-		result = batch.getAttribute('status')
-	except:
-		return False
-
-	if result == '0':
-		return True
+		code, new_err_msg = extract_module_status(batch, 1)
+		if new_err_msg:
+			err_msg = 'A Ricci error occurred on %s: %s' \
+				% (rc.hostname(), str(new_err_msg))
+	except Exception, e:
+		luci_log.debug_verbose('checkBatch1: %s: %s' % (rc.hostname(), str(e)))
+		return (-1, err_msg)
 
-	return False
+	# In progress.
+	if code == -101 or code == -102:
+		return (False, 'in progress')
+
+	# Done successfully.
+	if code == 0:
+		return (True, 'completed sucessfully')
+
+	# Error
+	luci_log.debug_verbose('checkBatch2: %s: %s: %s' \
+		% (str(code), rc.hostname(), str(e)))
+	return (-1, err_msg)
 
 def addClusterNodeBatch(os_str,
 						cluster_name,
ricci/modules/cluster/ClusterConf.cpp +1 -0
@@ -85,6 +85,7 @@
   fstream fs(tmp_path.c_str(), 
 	     ios_base::out | ios_base::trunc);
   fs << generateXML(xml);
+  fs.close();
   
   // propagate/move to proper place
   if (propagate) {