[prev in list] [next in list] [prev in thread] [next in thread] 

List:       luci-commits
Subject:    [Luci-commits] [luci] Fix rhbz#633983: "nodename" param not handled well
From:       jpokorny () fedoraproject ! org (Jan Pokorny)
Date:       2010-09-15 21:22:12
Message-ID: 20100915212212.900B3120356 () lists ! fedorahosted ! org
[Download RAW message or body]

commit 55e6b9548a381c0b8a780566d83736d742079852
Author: Jan Pokorny <jpokorny at redhat.com>
Date:   Wed Sep 15 23:19:51 2010 +0200

    Fix rhbz#633983: "nodename" param not handled well

 luci/templates/fence_devices.html        |    7 -
 luci/templates/fence_instances.html      |    5 +-
 luci/templates/node.html                 |  298 +++++++++++++++---------------
 luci/widget_validators/validate_fence.py |   11 +-
 4 files changed, 159 insertions(+), 162 deletions(-)
---
diff --git a/luci/templates/fence_devices.html b/luci/templates/fence_devices.html
index 0eb589c..af2c002 100644
--- a/luci/templates/fence_devices.html
+++ b/luci/templates/fence_devices.html
@@ -855,13 +855,6 @@
 					py:attrs="cur_fencedev and {'value': cur_fencedev.getName()} or {}"/>
 			</td>
 		</tr>
-		<tr>
-			<td>Node name</td>
-			<td>
-				<input type="text" class="text" name="nodename"
-					py:attrs="cur_fencedev and {'value': cur_fencedev.getAttribute('nodename')} or \
                {}"/>
-			</td>
-		</tr>
 		<!--
 		<tr>
 			<td>Devices to be used for action</td>
diff --git a/luci/templates/fence_instances.html \
b/luci/templates/fence_instances.html index ede58ba..f785f53 100644
--- a/luci/templates/fence_instances.html
+++ b/luci/templates/fence_instances.html
@@ -835,6 +835,7 @@
 			</div>
 		</td></tr>
 	</table>
+	<input py:if="kw.get('nodename')" type="hidden" name="nodename" \
value="${kw['nodename']}" />  <input type="hidden" name="fence_type" \
value="fence_scsi" />  <input type="hidden" name="fence_instance" value="1" />
 	<input type="hidden" name="parent_fencedev"
@@ -850,7 +851,7 @@
 		py:attrs="cur_fence_dev_id and {'value': cur_fence_dev_id} or {}" />
 </div>
 
-<div py:def="fence_instance_container"
+<div py:def="fence_instance_container(nodename)"
 	id="fence_instance_container" class="hidden">
 ${fence_apc_instance(None, None, None)}
 ${fence_apc_snmp_instance(None, None, None)}
@@ -886,7 +887,7 @@ ${fence_rps10_instance(None, None, None)}
 ${fence_rsb_instance(None, None, None)}
 ${fence_xcat_instance(None, None, None)}
 ${fence_zvm_instance(None, None, None)}
-${fence_scsi_instance(None, None, None)}
+${fence_scsi_instance(None, None, None, nodename=nodename)}
 ${fence_unknown_instance(None, None, None)}
 </div>
 </html>
diff --git a/luci/templates/node.html b/luci/templates/node.html
index 599a717..33594cd 100644
--- a/luci/templates/node.html
+++ b/luci/templates/node.html
@@ -17,7 +17,10 @@
 ?>
 
 <body py:with="cluster_data = tmpl_context.cluster.get_model();
-               cluster_status = tmpl_context.cluster.get_status()">
+               cluster_status = tmpl_context.cluster.get_status();
+               nodename = (cluster_data.cluster_version &lt;= 3 and name) and name \
or None;"> +               <!--!  "nodename" parameter is spread to fence_scsi only \
under +                      given conditions  -->
 
   <script type="text/javascript" src="/js/add_nodes.js"></script>
   <script type="text/javascript" src="/js/node.js"></script>
@@ -25,7 +28,7 @@
 
   <xi:include href="fence_devices.html" />
   <xi:include href="fence_instances.html" />
-  ${fence_instance_container()}
+  ${fence_instance_container(nodename)}
   ${fence_device_container()}
 
   <div id="existing_fencedev" class="hidden" py:if="cluster_data">
@@ -72,14 +75,14 @@
             py:attrs="entity_name==name and {'class': 'chosen'} or (not i%2 and \
{'class': 'even'} or None)"  py:with="identifier = entity_name;
                      nodeobj = cluster_data.getNodeByName(entity_name);
-		     is_clustered = node_data['clustered'];
+                     is_clustered = node_data['clustered'];
                      nodedbobj = \
                db_helpers.get_cluster_node(tmpl_context.cluster_name, \
                entity_name);">
           <td class="checkbox"><input type="checkbox" name="${identifier}"/></td>
           <!--! Branch according to the status of the node. -->
-	  <?python
-	    if nodeobj == None:
-	      is_clustered = "Removing"
-	  ?>
+          <?python
+            if nodeobj == None:
+              is_clustered = "Removing"
+          ?>
           <py:choose test="is_clustered">
           <!--! 1) Node is active. -->
           <py:when test="'true'">
@@ -113,7 +116,7 @@
             <img src="${tg.url('/images/question.png')}" alt="Status of the node is \
unknown." />  </td>
           <td class="main_id">
-	    <a href="${tmpl_context.cluster_url + entity_name}">
+            <a href="${tmpl_context.cluster_url + entity_name}">
               <span class="entity_unknown">${entity_name}</span>
             </a>
           </td>
@@ -126,7 +129,7 @@
             <img src="${tg.url('/images/exclamation.png')}" alt="Node is being \
deleted." />  </td>
           <td class="main_id">
-	    <a href="${tmpl_context.cluster_url + entity_name}">
+            <a href="${tmpl_context.cluster_url + entity_name}">
               <span class="entity_fail">${entity_name}</span>
             </a>
           </td>
@@ -141,11 +144,10 @@
             </py:if>
           </td>
         </tr>
-        <tr py:for="i in nodes"
-          py:with="hostname = i.hostname">
-	  <py:if test="cluster_status.nodes.keys().count(i.hostname) == 0">
-	  <td class="checkbox"><input type="checkbox" name="${hostname}"/></td>
-	  <td class="icon">
+        <tr py:for="i in nodes" py:with="hostname = i.hostname">
+        <py:if test="cluster_status.nodes.keys().count(i.hostname) == 0">
+          <td class="checkbox"><input type="checkbox" name="${hostname}"/></td>
+          <td class="icon">
             <img src="${tg.url('/images/question.png')}" alt="Status of the node is \
unknown." />  </td>
           <td class="main_id">
@@ -156,7 +158,7 @@
           <td class="node_tlist_id"></td>
           <td class="node_tlist_votes"></td>
           <td class="node_tlist_status">${_('This node is currently being \
                added')}</td>
-	  </py:if>
+        </py:if>
         </tr>
         </py:if>
       </tbody>
@@ -276,136 +278,130 @@
       <?python
         from luci.widget_validators.validate_fence import getFenceInfo
         fence_info = getFenceInfo(cluster_data, name)
-	fenceinst_num = 0
+        fenceinst_num = 0
       ?>
       <div class="details_inner">
-       <form method="post" name="node_fence_form" \
                action="${tg.url('nodes_fence_cmd')}">
-	 <input type="hidden" name="method_to_remove" value=""/>
-	 <input type="hidden" name="fenceinst_to_remove" value=""/>
-	 <input type="hidden" name="fenceinst_to_remove_method" value=""/>
-	 <input type="hidden" name="moveup_method" value=""/>
-	 <input type="hidden" name="movedown_method" value=""/>
+        <form method="post" name="node_fence_form" \
action="${tg.url('nodes_fence_cmd')}"> +        <input type="hidden" \
name="method_to_remove" value=""/> +        <input type="hidden" \
name="fenceinst_to_remove" value=""/> +        <input type="hidden" \
name="fenceinst_to_remove_method" value=""/> +        <input type="hidden" \
name="moveup_method" value=""/> +        <input type="hidden" name="movedown_method" \
value=""/>  <table id="node_tfences" class="detailstable">
           <thead>
             <tr class="grid_row">
-	      <th width="5">Method</th>
-	      <th width="98%"></th>
-	      <th colspan="3"></th>
+          <th width="5">Method</th>
+          <th width="98%"></th>
+          <th colspan="3"></th>
             </tr>
           </thead>
           <tbody>
-	    <py:for each="order,(method,instances) in enumerate(fence_info)"
-	    py:with="cur_dev_id=method">
-	    <tr>
-	      <td colspan="2">${method.getName().replace(' ','&nbsp;')}</td>
-	      <td align="right">
-		<a py:if="order != 0" href="" \
onclick="document.node_fence_form.moveup_method.value = \
&quot;${method.getName()}&quot;;document.node_fence_form.submit();return \
                false;">Move&nbsp;Up</a>
-	      </td>
-	      <td align="right">
-		<a py:if="order != len(fence_info)-1" href="" \
onclick="document.node_fence_form.movedown_method.value = \
&quot;${method.getName()}&quot;;document.node_fence_form.submit();return \
                false;">Move&nbsp;Down</a>
-	      </td>
-	      <td align="right">
-		<a href="" onclick="document.node_fence_form.method_to_remove.value = \
&quot;${method.getName()}&quot;;document.node_fence_form.submit();return \
                false;">Remove</a>
-	      </td>
+        <py:for each="order,(method,instances) in enumerate(fence_info)"
+        py:with="cur_dev_id=method">
+        <tr>
+          <td colspan="2">${method.getName().replace(' ','&nbsp;')}</td>
+          <td align="right">
+        <a py:if="order != 0" href="" \
onclick="document.node_fence_form.moveup_method.value = \
&quot;${method.getName()}&quot;;document.node_fence_form.submit();return \
false;">Move&nbsp;Up</a> +          </td>
+          <td align="right">
+        <a py:if="order != len(fence_info)-1" href="" \
onclick="document.node_fence_form.movedown_method.value = \
&quot;${method.getName()}&quot;;document.node_fence_form.submit();return \
false;">Move&nbsp;Down</a> +          </td>
+          <td align="right">
+        <a href="" onclick="document.node_fence_form.method_to_remove.value = \
&quot;${method.getName()}&quot;;document.node_fence_form.submit();return \
false;">Remove</a> +          </td>
 
-	    </tr>
-	    <tr>
-	      <td></td>
-	      <td colspan="4">
-		<table class="fence_instances">
-		  <tr>
-		    <th class="fence_instances">Name</th>
-		    <th>Type/Values</th>
-		    <th></th>
-		  </tr>
-		  <py:for each="instancenum,(fin,fd,unfencing) in enumerate(instances)">
-			<?python
-				agent_type = fd.getAgentType()
-				agent_name = fd.getPrettyName()
-				agent_alias = fd.getName()
-				fenceinst_num += 1
-			?>
-			<?python
-				try:
-					inst_fn = eval(agent_type + '_instance')
-				except:
-					inst_fn = eval('fence_unknown_instance')
-				instance_id = "%s-%s" % (order, instancenum)
-			?>
-		  <tr><td>
-		      <div class="hidden">
-			<div id="edit_fencedev_dialog_${instance_id}">
-			  <form name="filler"/>
-			  <form name="edit_fence_device_${instance_id}" method="post" \
                action="${tg.url('nodes_fence_cmd?command=EditFence')}">
-			    <input type="hidden" name="node" value="${name}"/>
-			    <input type="hidden" name="instance_id" value="${instance_id}"/>
-			    <input type="hidden" name="fencedev" value="${agent_alias}"/>
+        </tr>
+        <tr>
+          <td></td>
+          <td colspan="4">
+        <table class="fence_instances">
+          <tr>
+            <th class="fence_instances">Name</th>
+            <th>Type/Values</th>
+            <th></th>
+          </tr>
+          <py:for each="instancenum,(fin,fd,unfencing) in enumerate(instances)">
+            <?python
+                agent_type = fd.getAgentType()
+                agent_name = fd.getPrettyName()
+                agent_alias = fd.getName()
+                fenceinst_num += 1
+                instance_id = "%s-%s" % (order, instancenum)
+            ?>
+          <tr><td>
+              <div class="hidden">
+            <div id="edit_fencedev_dialog_${instance_id}">
+              <form name="filler"/>
+              <form name="edit_fence_device_${instance_id}" method="post" \
action="${tg.url('nodes_fence_cmd?command=EditFence')}"> +                <input \
type="hidden" name="node" value="${name}"/> +                <input type="hidden" \
name="instance_id" value="${instance_id}"/> +                <input type="hidden" \
name="fencedev" value="${agent_alias}"/>  
-			    <div id="fence_instance_area">
-					<?python
-						try:
-							inst_fn = eval(agent_type + '_instance')
-						except:
-							inst_fn = eval('fence_unknown_instance')
-						inst_fn(fin, instance_id, None)
-					?>
-					${inst_fn(fin, cur_dev_id, '%s_%s' % (cur_dev_id, cur_dev_id), \
                unfencing=unfencing)}
-			    </div>
-			    <div class="row">
-			      <input type="Submit" value="Submit" class="button formsubmit blue" />
-			      <input type="button" class="button formsubmit silver" value="Cancel"
-			      onclick="$('#edit_fencedev_dialog_${instance_id}').dialog('close')" />
-			    </div>
-			  </form>
-			</div>
-		      </div>
-		    <script type="text/javascript">
-		      $('#edit_fencedev_dialog_${instance_id}').dialog({
-		        modal: true,
-			title: 'Edit Fence Instance',
-			width: '520px',
-			autoOpen: false,
-			draggable: false,
-			resizable: false,
-	              });
-		  </script>
-		  </td></tr>
-		  <tr>
-		    <td><a href="#" \
onclick="$('#edit_fencedev_dialog_${instance_id}').dialog('open')">${agent_alias}</a></td>
                
-		    <td>${agent_name}</td>
-		    <td align="right">
-		      <a href="" onclick="document.node_fence_form.fenceinst_to_remove_method.value \
= &quot;${method.getName()}&quot;;document.node_fence_form.fenceinst_to_remove.value \
                = &quot;${fenceinst_num}&quot;;document.node_fence_form.submit();return \
                false;">
-			<img src="/images/delete-grey.png"/>
-		      </a>
-		    </td>
-		  </tr>
-		  <tr py:for="key,val in fin.attr_hash.items()">
-		    <py:if test="key != 'obj' and key != 'name'">
-		    <td></td>
-		    <td>
-		      ${key} : ${val}
-		    </td>
-		    </py:if>
-		  </tr>
-		  <tr py:if="unfencing == True">
-		    <td></td>
-		    <td>unfencing enabled</td>
-		  </tr>
-		  </py:for>
-		  <tr>
-		    <td colspan="3">
-		      <input type="button" py:if="len(cluster_data.getFenceDevices()) > 0" \
value="Add a Fence Instance" class="button small silver" \
onclick="$(create_fence_device.methodname).attr('value','${method.getName()}');$('#create_fencedev_dialog').dialog('open')"/>
                
-		    </td>
-		  </tr>
-		</table>
-	      </td>
-	    </tr>
-	    </py:for>
+                <div id="fence_instance_area">
+                    <?python
+                        try:
+                            inst_fn = eval(agent_type + '_instance')
+                        except:
+                            inst_fn = eval('fence_unknown_instance')
+                        inst_fn(fin, instance_id, None, nodename=nodename)
+                    ?>
+                    ${inst_fn(fin, cur_dev_id, '%s_%s' % (cur_dev_id, cur_dev_id), \
unfencing=unfencing, nodename=nodename)} +                </div>
+                <div class="row">
+                  <input type="Submit" value="Submit" class="button formsubmit blue" \
/> +                  <input type="button" class="button formsubmit silver" \
value="Cancel" +                  \
onclick="$('#edit_fencedev_dialog_${instance_id}').dialog('close')" /> +              \
</div> +              </form>
+            </div>
+              </div>
+            <script type="text/javascript">
+              $('#edit_fencedev_dialog_${instance_id}').dialog({
+                modal: true,
+            title: 'Edit Fence Instance',
+            width: '520px',
+            autoOpen: false,
+            draggable: false,
+            resizable: false,
+                  });
+          </script>
+          </td></tr>
+          <tr>
+            <td><a href="#" \
onclick="$('#edit_fencedev_dialog_${instance_id}').dialog('open')">${agent_alias}</a></td>
 +            <td>${agent_name}</td>
+            <td align="right">
+              <a href="" \
onclick="document.node_fence_form.fenceinst_to_remove_method.value = \
&quot;${method.getName()}&quot;;document.node_fence_form.fenceinst_to_remove.value = \
&quot;${fenceinst_num}&quot;;document.node_fence_form.submit();return false;"> +      \
<img src="/images/delete-grey.png"/> +              </a>
+            </td>
+          </tr>
+          <tr py:for="key,val in fin.attr_hash.items()">
+            <py:if test="key != 'obj' and key != 'name'">
+            <td></td>
+            <td>
+              ${key} : ${val}
+            </td>
+            </py:if>
+          </tr>
+          <tr py:if="unfencing == True">
+            <td></td>
+            <td>unfencing enabled</td>
+          </tr>
+          </py:for>
+          <tr>
+            <td colspan="3">
+              <input type="button" py:if="len(cluster_data.getFenceDevices()) > 0" \
value="Add a Fence Instance" class="button small silver" \
onclick="$(create_fence_device.methodname).attr('value','${method.getName()}');$('#create_fencedev_dialog').dialog('open')"/>
 +            </td>
+          </tr>
+        </table>
+          </td>
+        </tr>
+        </py:for>
           </tbody>
         </table>
-	<div>
-	  <input type="button" value="Add a Fence Method" class="button small silver" \
                onclick="$('#create_fencemethod_dialog').dialog('open')"/>
-	</div>
+    <div>
+      <input type="button" value="Add a Fence Method" class="button small silver" \
onclick="$('#create_fencemethod_dialog').dialog('open')"/> +    </div>
         <input type="hidden" name="node" value="${name}"/>
        </form>
       </div>
@@ -451,29 +447,29 @@
   <div class="hidden">
     <div id="create_fencedev_dialog">
       <form name="create_fence_device" method="post" \
                action="${tg.url('nodes_fence_cmd?command=AddFence')}">
-	<input type="hidden" name="node" value="${name}"/>
-	<input type="hidden" name="methodname" value=""/>
-	${fence_device_select(cluster_data, 'fence_form_area')}
-	<div id="fence_form_area" />
-	  <div class="row">
-	    <input type="Submit" value="Submit" class="button formsubmit blue" />
-	    <input type="button" class="button formsubmit silver" value="Cancel"
-	    onclick="$('#create_fencedev_dialog').dialog('close')" />
-	  </div>
-	</form>
+    <input type="hidden" name="node" value="${name}"/>
+    <input type="hidden" name="methodname" value=""/>
+    ${fence_device_select(cluster_data, 'fence_form_area')}
+    <div id="fence_form_area" />
+      <div class="row">
+        <input type="Submit" value="Submit" class="button formsubmit blue" />
+        <input type="button" class="button formsubmit silver" value="Cancel"
+        onclick="$('#create_fencedev_dialog').dialog('close')" />
+      </div>
+    </form>
       </div>
     </div>
   <div class="hidden">
     <div id="create_fencemethod_dialog">
       <form name="create_fence_method" method="post" \
                action="${tg.url('nodes_fence_cmd?command=AddFenceMethod')}">
-	<input type="hidden" name="node" value="${name}"/>
-	Method Name:<input type="text" name="newmethodname" value="Method"/>
-	  <div class="row">
-	    <input type="Submit" value="Submit" class="button formsubmit blue" />
-	    <input type="button" class="button formsubmit silver" value="Cancel"
-	    onclick="$('#create_fencemethod_dialog').dialog('close')" />
-	  </div>
-	</form>
+    <input type="hidden" name="node" value="${name}"/>
+    Method Name:<input type="text" name="newmethodname" value="Method"/>
+      <div class="row">
+        <input type="Submit" value="Submit" class="button formsubmit blue" />
+        <input type="button" class="button formsubmit silver" value="Cancel"
+        onclick="$('#create_fencemethod_dialog').dialog('close')" />
+      </div>
+    </form>
       </div>
     </div>
 </body>
diff --git a/luci/widget_validators/validate_fence.py \
b/luci/widget_validators/validate_fence.py index f9339e1..3d9516f 100644
--- a/luci/widget_validators/validate_fence.py
+++ b/luci/widget_validators/validate_fence.py
@@ -238,7 +238,6 @@ def val_vmware_fd(fencedev, fence_name, **kw):
 
 def val_scsi_fd(fencedev, fence_name, **kw):
 	params = (
-		('nodename', True),
 		('devices', False),
 		('key', False),
 		('aptpl', False),
@@ -864,6 +863,14 @@ def val_intelmodular_fi(fenceinst, parent_name, **kw):
 	errors = config_fence_attr(params, fenceinst, parent_name, **kw)
 	return errors
 
+def val_scsi_fi(fenceinst, parent_name, **kw):
+	params = (
+		('nodename', False),
+	)
+
+	errors = config_fence_attr(params, fenceinst, parent_name, **kw)
+	return errors
+
 def val_noop_fi(fenceinst, parent_name, **kw):
 	return []
 
@@ -896,7 +903,7 @@ FI_VALIDATE = {
 	'fence_rsa':			val_noop_fi,
 	'fence_rsb':			val_noop_fi,
 	'fence_sanbox2':		val_sanbox2_fi,
-	'fence_scsi':			val_noop_fi,
+	'fence_scsi':			val_scsi_fi,
 	'fence_virsh':			val_virsh_fi,
 	'fence_virt':			val_virt_fi,
 	'fence_vixel':			val_vixel_fi,


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic