[Cluster-devel] conga/luci/cluster form-macros resource-form-m ...
rmccabe at sourceware.org
rmccabe at sourceware.org
Fri Sep 22 18:22:00 UTC 2006
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-09-22 18:21:59
Modified files:
luci/cluster : form-macros resource-form-macros
resource_form_handlers.js
Log message:
- resources support
- improved user interaction in places
- better error handling in places
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.60&r2=1.61
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.8&r2=1.9
--- conga/luci/cluster/form-macros 2006/09/14 21:24:24 1.60
+++ conga/luci/cluster/form-macros 2006/09/22 18:21:59 1.61
@@ -31,7 +31,7 @@
tal:define="ragent python: here.getRicciAgent(clu);
global stat python: here.getClusterStatus(ragent);
global cstatus python: here.getClustersInfo(stat,request);
- global cluster_status python: 'cluster ' + (cstatus['running'] == 'true' and 'running' or 'stopped');"
+ global cluster_status python: 'cluster ' + (('running' in cstatus and cstatus['running'] == 'true') and 'running' or 'stopped');"
/>
<table class="cluster" width="100%">
@@ -39,16 +39,16 @@
<td class="cluster cluster_name">
<strong class="cluster cluster_name">Cluster Name</strong>:
<a href=""
- tal:attributes="href cstatus/clucfg;
+ tal:attributes="href cstatus/clucfg | nothing;
class python: 'cluster ' + cluster_status;"
- tal:content="cstatus/clusteralias" />
+ tal:content="cstatus/clusteralias | string: [unknown]" />
</td>
<td class="cluster cluster_action">
<form method="post" onSubmit="return dropdown(this.gourl)">
<select name="gourl" id="cluster_action" class="cluster">
- <option tal:condition="python: cstatus['running'] != 'true'" value="" class="cluster running">Start this cluster</option>
- <option tal:condition="python: cstatus['running'] == 'true'" value="" class="cluster stopped">Stop this cluster</option>
+ <option tal:condition="python: 'running' in cstatus and cstatus['running'] != 'true'" value="" class="cluster running">Start this cluster</option>
+ <option tal:condition="python: 'running' in cstatus and cstatus['running'] == 'true'" value="" class="cluster stopped">Stop this cluster</option>
<option value="" class="cluster">Restart this cluster</option>
</select>
<input class="cluster" type="submit" value="Go" />
@@ -58,7 +58,9 @@
<tr class="cluster info_middle">
<td colspan="2" class="cluster cluster_quorum">
- <ul class="cluster_quorum">
+ <ul class="cluster_quorum"
+ tal:condition="exists: cstatus/status">
+
<li><strong class="cluster">Status</strong>: <span tal:replace="cstatus/status"/></li>
<li><strong class="cluster">Total Cluster Votes</strong>: <span tal:replace="cstatus/votes"/></li>
<li><strong class="cluster">Minimum Required Quorum</strong>: <span tal:replace="cstatus/minquorum"/></li>
@@ -67,7 +69,9 @@
</tr>
<tr class="cluster info_bottom">
- <td class="cluster cluster_nodes">
+ <td class="cluster cluster_nodes"
+ tal:condition="exists: cstatus/currentnodes">
+
<strong class="cluster">Nodes</strong>
<ul class="cluster">
<tal:block tal:repeat="nd cstatus/currentnodes">
@@ -86,11 +90,13 @@
<td class="cluster service cluster_services">
<strong class="cluster service">Services</strong>
<ul class="cluster service">
- <tal:block tal:condition="python: len(cstatus['currentservices']) < 1">
+ <tal:block tal:condition="python: not 'currentservices' in cstatus or len(cstatus['currentservices']) < 1">
<li>No Services Defined</li>
</tal:block>
- <tal:block tal:repeat="svc cstatus/currentservices">
+ <tal:block
+ tal:condition="exists: cstatus/currentservices"
+ tal:repeat="svc cstatus/currentservices">
<tal:block
tal:define="global svcclass python: svc['srunning'] == 'true' and 'running' or 'stopped'" />
@@ -161,28 +167,40 @@
<tbody class="systemsTable">
<tr class="systemsTable">
<td class="systemsTable">
- <input class="hbInputSys" type="text" id="__SYSTEM0:Addr" name="__SYSTEM0:Addr" />
+ <input class="hbInputSys" type="text"
+ id="__SYSTEM0:Addr" name="__SYSTEM0:Addr" />
</td>
<td class="systemsTable">
- <input type="password" id="__SYSTEM0:Passwd" name="__SYSTEM0:Passwd" class="hbInputPass" onChange="pwd0Change(adminform);" />
+ <input type="password"
+ id="__SYSTEM0:Passwd" name="__SYSTEM0:Passwd"
+ class="hbInputPass" autocomplete="off"
+ onChange="pwd0Change(adminform);" />
</td>
</tr>
<tr class="systemsTable">
<td class="systemsTable">
- <input class="hbInputSys" type="text" id="__SYSTEM1:Addr" name="__SYSTEM1:Addr" />
+ <input class="hbInputSys" type="text"
+ id="__SYSTEM1:Addr" name="__SYSTEM1:Addr" />
</td>
<td class="systemsTable">
- <input type="password" id="__SYSTEM1:Passwd" name="__SYSTEM1:Passwd" class="hbInputPass" onChange="pwd0Change(adminform);" />
+ <input type="password"
+ id="__SYSTEM1:Passwd" name="__SYSTEM1:Passwd"
+ class="hbInputPass" autocomplete="off"
+ onChange="pwd0Change(adminform);" />
</td>
</tr>
<tr class="systemsTable">
<td class="systemsTable">
- <input class="hbInputSys" type="text" id="__SYSTEM2:Addr" name="__SYSTEM2:Addr" />
+ <input class="hbInputSys" type="text"
+ id="__SYSTEM2:Addr" name="__SYSTEM2:Addr" />
</td>
<td class="systemsTable">
- <input type="password" id="__SYSTEM2:Passwd" name="__SYSTEM2:Passwd" class="hbInputPass" onChange="pwd0Change(adminform);" />
+ <input type="password"
+ id="__SYSTEM2:Passwd" name="__SYSTEM2:Passwd"
+ class="hbInputPass" autocomplete="off"
+ onChange="pwd0Change(adminform);" />
</td>
</tr>
</tbody>
@@ -975,10 +993,14 @@
<tbody class="systemsTable">
<tr class="systemsTable">
<td class="systemsTable">
- <input class="hbInputSys" type="text" id="__SYSTEM0:Addr" name="__SYSTEM0:Addr" />
+ <input class="hbInputSys" type="text"
+ id="__SYSTEM0:Addr" name="__SYSTEM0:Addr" />
</td>
<td class="systemsTable">
- <input type="password" id="__SYSTEM0:Passwd" name="__SYSTEM0:Passwd" class="hbInputPass" onChange="pwd0Change(adminform);" />
+ <input type="password"
+ id="__SYSTEM0:Passwd" name="__SYSTEM0:Passwd"
+ class="hbInputPass" autocomplete="off"
+ onChange="pwd0Change(adminform);" />
</td>
</tr>
</tbody>
@@ -1093,12 +1115,16 @@
</script>
<tal:block tal:define="
global ricci_agent python: here.getRicciAgentForCluster(request);
+ global global_resources python: here.getResourcesInfo(modelb, request);
global sstat python: here.getClusterStatus(ricci_agent);
global sinfo python: here.getServiceInfo(sstat, modelb,request);
global running sinfo/running | nothing;" />
<tal:block tal:replace="structure python: '<script type='+chr(0x22)+'text/javascript'+chr(0x22)+'>'" />
var uuid_list = <tal:block tal:replace="sinfo/uuid_list" />;
+ var global_resources = <tal:block tal:replace="python: map(lambda x: str(x['name']), global_resources) or 'null'" />;
+ var active_resources = <tal:block tal:replace="python: map(lambda x: str(x['name']), sinfo['resource_list']) or 'null'" />;
+ var resource_names = <tal:block tal:replace="python: (map(lambda x: str(x['name']), global_resources) + map(lambda x: str(x['name']), sinfo['resource_list'])) or 'null'" />;
<tal:block tal:replace="structure string: </script>" />
<table class="cluster service" width="100%">
@@ -1147,7 +1173,7 @@
<br/>
<div id="resskel" class="invisible">
- <tal:block metal:use-macro="here/resource-form-macros/macros/resource-swap-form" />
+ <tal:block metal:use-macro="here/resource-form-macros/macros/service-compose-macro" />
</div>
<h2 onclick="forms_to_xml()">Service Composition</h2>
@@ -1160,12 +1186,12 @@
id python: res['uuid']">
<tal:block
- tal:condition="python: res['max_depth'] > 0"
+ tal:condition="python: 'max_depth' in res and res['max_depth'] > 0"
tal:replace="structure python: '<div class=nothing>'" />
<tal:block tal:define="
global type res/type;
- global ref res/ref_object | nothing" />
+ global resourceIsRef res/ref_object | nothing" />
<span tal:omit-tag="" tal:condition="python: type == 'IP Address: '">
<tal:block metal:use-macro="here/resource-form-macros/macros/ip_macro" />
@@ -1200,12 +1226,54 @@
</span>
<tal:block
+ tal:condition="python: 'indent_ctr' in res and 'max_depth' in res"
tal:replace="structure python: '</div>' * (res['indent_ctr'] - res['max_depth'])" />
</div>
</div>
<form name="master">
<input type="hidden" name="form_xml" />
</form>
+
+ <div class="invisible" id="global_resources_block">
+ <tal:block tal:repeat="gr global_resources">
+ <tal:block tal:define="
+ global res gr;
+ global type res/type;
+ global resourceIsRef python: True" />
+
+ <span tal:omit-tag="" tal:condition="python: type == 'IP Address: '">
+ <tal:block metal:use-macro="here/resource-form-macros/macros/ip_macro" />
+ </span>
+
+ <span tal:omit-tag="" tal:condition="python: type == 'fs'">
+ <tal:block metal:use-macro="here/resource-form-macros/macros/fs_macro" />
+ </span>
+
+ <span tal:omit-tag="" tal:condition="python: type == 'gfs'">
+ <tal:block metal:use-macro="here/resource-form-macros/macros/gfs_macro" />
+ </span>
+
+ <span tal:omit-tag="" tal:condition="python: type == 'nfsm'">
+ <tal:block metal:use-macro="here/resource-form-macros/macros/nfsm_macro" />
+ </span>
+
+ <span tal:omit-tag="" tal:condition="python: type == 'nfsx'">
+ <tal:block metal:use-macro="here/resource-form-macros/macros/nfsx_macro" />
+ </span>
+
+ <span tal:omit-tag="" tal:condition="python: type == 'nfsc'">
+ <tal:block metal:use-macro="here/resource-form-macros/macros/nfsc_macro" />
+ </span>
+
+ <span tal:omit-tag="" tal:condition="python: type == 'smb'">
+ <tal:block metal:use-macro="here/resource-form-macros/macros/smb_macro" />
+ </span>
+
+ <span tal:omit-tag="" tal:condition="python: type == 'Script: '">
+ <tal:block metal:use-macro="here/resource-form-macros/macros/scr_macro" />
+ </span>
+ </tal:block>
+ </div>
</div>
<div metal:define-macro="service-form">
--- conga/luci/cluster/resource-form-macros 2006/09/19 17:50:28 1.12
+++ conga/luci/cluster/resource-form-macros 2006/09/22 18:21:59 1.13
@@ -8,7 +8,8 @@
<p class="hbSubmit">
<input class="hbSubmit" type="button"
onClick="validate_form(this.form);"
- tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
+ value="Submit"
+ tal:condition="not: sinfo" />
<tal:block tal:condition="sinfo">
<input class="hbSubmit" type="button" value="Add a child"
@@ -23,7 +24,7 @@
<tal:block tal:condition="exists:res">
<tal:block tal:define="
- global expclass python: ((res['max_depth'] == 0 and 'invisible ' or '') + 'expander')" />
+ global expclass python: (((not 'max_depth' in res or res['max_depth'] == 0) and 'invisible ' or '') + 'expander')" />
</tal:block>
<p tal:attributes="class expclass">
@@ -93,7 +94,7 @@
</div>
<div metal:define-macro="resource-swap-form">
- <p class="reshdr">
+ <p>
<strong class="reshdr">Select a Resource Type</strong>
</p>
@@ -101,7 +102,7 @@
<form>
<select onChange="swap_div_elem(this.form.parentNode,
this.options[this.selectedIndex].value);">
- <option name="blank" value="blank" checked>Select a Resource</option>
+ <option name="blank" value="blank" checked>Select a resource type</option>
<option name="IP" value="IP">IP address</option>
<option name="FS" value="FS">File system</option>
<option name="GFS" value="GFS">GFS file system</option>
@@ -127,6 +128,61 @@
</div>
</div>
+<div metal:define-macro="service-compose-macro">
+ <p class="reshdr">
+ <strong class="reshdr">Add a new local resource</strong>
+ <form>
+ <select onChange="swap_div_elem(this.form.parentNode,
+ this.options[this.selectedIndex].value);">
+ <option checked="checked">Select a resource type</option>
+ <option name="IP" value="IP">IP address</option>
+ <option name="FS" value="FS">File system</option>
+ <option name="GFS" value="GFS">GFS file system</option>
+ <option name="NFSM" value="NFSM">NFS mount</option>
+ <option name="NFSC" value="NFSC">NFS client</option>
+ <option name="NFSX" value="NFSX">NFS export</option>
+ <option name="SCR" value="SCR">Script</option>
+ <option name="SMB" value="SMB">Samba</option>
+ </select>
+ </form>
+ </p>
+
+ <p style="margin-left: +5em;margin-top:1em;"><strong>or</strong></p>
+ <p class="reshdr">
+ <strong class="reshdr">Use an existing global resource</strong>
+ <br/>
+ <form>
+ <input type="hidden" name="parent_uuid" value="" />
+ <input type="hidden" name="tree_level" value="" />
+ <select name="gres_chooser"
+ onChange="swap_in_global_res('global_resources_block',
+ this.options[this.selectedIndex].value,
+ this.form.parentNode.parentNode, this.form);">
+ <option checked="checked">Select a resource name</option>
+ <tal:block
+ tal:repeat="gres global_resources">
+ <option
+ tal:condition="python: 'name' in gres and 'type' in gres and gres['name'] and gres['type']"
+ tal:attributes="value gres/name"
+ tal:content="python: gres['name'] + ' (' + gres['type'].split(':')[0] + ')'" />
+ </tal:block>
+ </select>
+ </form>
+ </p>
+
+ <div name="invisible" class="invisible">
+ <div name=""> </div>
+ <div metal:use-macro="here/resource-form-macros/macros/ip_macro" />
+ <div metal:use-macro="here/resource-form-macros/macros/fs_macro" />
+ <div metal:use-macro="here/resource-form-macros/macros/gfs_macro" />
+ <div metal:use-macro="here/resource-form-macros/macros/nfsm_macro" />
+ <div metal:use-macro="here/resource-form-macros/macros/nfsx_macro" />
+ <div metal:use-macro="here/resource-form-macros/macros/nfsc_macro" />
+ <div metal:use-macro="here/resource-form-macros/macros/smb_macro" />
+ <div metal:use-macro="here/resource-form-macros/macros/scr_macro" />
+ </div>
+</div>
+
<div metal:define-macro="resourceadd-form">
<script type="text/javascript"
src="/luci/cluster/resource_form_handlers.js">
@@ -234,10 +290,11 @@
</tal:block>
</div>
-<div class="rescfg" name="IP" metal:define-macro="ip_macro">
+<div class="rescfg" name="IP" tal:attributes="id res/name | nothing" metal:define-macro="ip_macro">
<tal:block tal:condition="python: ptype == '33' or ptype == '24'"
tal:define="
global edit python: True;
+ global editDisabled resourceIsRef | nothing;
global resName res/name | nothing;
global ip_address python: resName;
global monitor_link res/attrs/monitor_link | nothing;
@@ -276,8 +333,7 @@
tal:attributes="value cluname | nothing" />
<input name="oldname" type="hidden"
- tal:attributes="value res/name | nothing"
- tal:condition="python: edit == True" />
+ tal:attributes="value res/name | nothing" />
<input name="edit" type="hidden" value="1"
tal:condition="python: edit == True" />
@@ -289,7 +345,9 @@
<td class="systemsTable">IP address</td>
<td class="systemsTable">
<input size="15" name="ip_address" type="text" maxlength="15"
- tal:attributes="value ip_address | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value ip_address | nothing" />
</td>
</tr>
<tr class="systemsTable">
@@ -297,6 +355,7 @@
<td class="systemsTable">
<input type="checkbox" name="monitorLink"
tal:attributes="
+ disabled python: editDisabled;
checked python: monitor_link == '1' and 'checked'" />
</td>
</tr>
@@ -306,10 +365,11 @@
</form>
</div>
-<div class="rescfg" name="FS" metal:define-macro="fs_macro">
+<div class="rescfg" name="FS" tal:attributes="id res/name | nothing" metal:define-macro="fs_macro">
<tal:block tal:condition="python: ptype == '33' or ptype == '24'"
tal:define="
global edit python: True;
+ global editDisabled resourceIsRef | nothing;
global resName res/name | nothing;
global mountPoint res/attrs/mountpoint | nothing;
global device res/attrs/device | nothing;
@@ -356,7 +416,6 @@
tal:attributes="value cluname | nothing" />
<input name="oldname" type="hidden"
- tal:condition="python: edit == True"
tal:attributes="value res/name | nothing" />
<input name="edit" type="hidden" value="1"
@@ -368,9 +427,10 @@
<tr class="systemsTable">
<td class="systemsTable">Name</td>
<td class="systemsTable">
- <input type="text" size="20"
- name="resourceName"
- tal:attributes="value resName | nothing"/>
+ <input type="text" size="20" name="resourceName"
+ tal:attributes="
+ disabled python: editDisabled;
+ value resName | nothing"/>
</td>
</tr>
@@ -400,7 +460,9 @@
<td class="systemsTable">Device</td>
<td class="systemsTable">
<input type="text" size="20" name="device"
- tal:attributes="value device | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value device | nothing" />
</td>
</tr>
@@ -408,7 +470,9 @@
<td class="systemsTable">Options</td>
<td class="systemsTable">
<input type="text" size="20" name="options"
- tal:attributes="value opt | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value opt | nothing" />
</td>
</tr>
@@ -416,7 +480,9 @@
<td class="systemsTable">File system ID</td>
<td class="systemsTable">
<input type="text" size="20" name="fsid"
- tal:attributes="value fsid | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value fsid | nothing" />
</td>
</tr>
@@ -424,7 +490,9 @@
<td class="systemsTable">Force unmount</td>
<td class="systemsTable">
<input type="checkbox" name="forceunmount"
- tal:attributes="checked python: force_unmount == '1' and 'checked'" />
+ tal:attributes="
+ disabled python: editDisabled;
+ checked python: force_unmount == '1' and 'checked'" />
</td>
</tr>
@@ -433,6 +501,7 @@
<td class="systemsTable">
<input type="checkbox" name="selffence"
tal:attributes="
+ disabled python: editDisabled;
checked python: reboot_fail == '1' and 'checked'" />
</td>
</tr>
@@ -442,6 +511,7 @@
<td class="systemsTable">
<input type="checkbox" name="checkfs"
tal:attributes="
+ disabled python: editDisabled;
checked python: fscheck == '1' and 'checked'" />
</td>
</tr>
@@ -451,10 +521,11 @@
</form>
</div>
-<div class="rescfg" name="GFS" metal:define-macro="gfs_macro">
+<div class="rescfg" name="GFS" tal:attributes="id res/name | nothing" metal:define-macro="gfs_macro">
<tal:block tal:condition="python: ptype == '33' or ptype =='24'"
tal:define="
global edit python: True;
+ global editDisabled resourceIsRef | nothing;
global resName res/name | nothing;
global mountPoint res/attrs/mountpoint | nothing;
global device res/attrs/device | nothing;
@@ -496,7 +567,6 @@
tal:attributes="value cluname | nothing" />
<input name="oldname" type="hidden"
- tal:condition="python: edit == True"
tal:attributes="value res/name | nothing" />
<input name="edit" type="hidden" value="1"
@@ -508,9 +578,10 @@
<tr class="systemsTable">
<td class="systemsTable">Name</td>
<td class="systemsTable">
- <input type="text" size="20"
- name="resourceName"
- tal:attributes="value resName | nothing" />
+ <input type="text" size="20" name="resourceName"
+ tal:attributes="
+ disabled python: editDisabled;
+ value resName | nothing" />
</td>
</tr>
@@ -518,7 +589,9 @@
<td class="systemsTable">Mount point</td>
<td class="systemsTable">
<input type="text" size="20" name="mountpoint"
- tal:attributes="value mountpoint | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value mountpoint | nothing" />
</td>
</tr>
@@ -526,7 +599,9 @@
<td class="systemsTable">Device</td>
<td class="systemsTable">
<input type="text" size="20" name="device"
- tal:attributes="value device | nothing"/>
+ tal:attributes="
+ disabled python: editDisabled;
+ value device | nothing" />
</td>
</tr>
@@ -534,7 +609,9 @@
<td class="systemsTable">Options</td>
<td class="systemsTable">
<input type="text" size="20" name="options"
- tal:attributes="value opt | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value opt | nothing" />
</td>
</tr>
@@ -542,7 +619,9 @@
<td class="systemsTable">File system ID</td>
<td class="systemsTable">
<input type="text" size="20" name="fsid"
- tal:attributes="value fsid | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value fsid | nothing" />
</td>
</tr>
@@ -551,6 +630,7 @@
<td class="systemsTable">
<input type="checkbox" name="forceunmount"
tal:attributes="
+ disabled python: editDisabled;
checked python: force_unmount == '1' and 'checked'" />
</td>
</tr>
@@ -560,10 +640,11 @@
</form>
</div>
-<div class="rescfg" name="NFSM" metal:define-macro="nfsm_macro">
+<div class="rescfg" name="NFSM" tal:attributes="id res/name | nothing" metal:define-macro="nfsm_macro">
<tal:block tal:condition="python: ptype == '33' or ptype =='24'"
tal:define="
global edit python: True;
+ global editDisabled resourceIsRef | nothing;
global resName res/name | nothing;
global mountpoint res/attrs/mountpoint | nothing;
global opt res/attrs/options | nothing;
@@ -605,7 +686,6 @@
tal:attributes="value cluname | nothing" />
<input name="oldname" type="hidden"
- tal:condition="python: edit == True"
tal:attributes="value res/name | nothing" />
<input name="edit" type="hidden" value="1"
@@ -617,9 +697,10 @@
<tr class="systemsTable">
<td class="systemsTable">Name</td>
<td class="systemsTable">
- <input type="text" size="20"
- name="resourceName"
- tal:attributes="value resName | nothing" />
+ <input type="text" size="20" name="resourceName"
+ tal:attributes="
+ disabled python: editDisabled;
+ value resName | nothing" />
</td>
</tr>
@@ -627,7 +708,9 @@
<td class="systemsTable">Mount point</td>
<td class="systemsTable">
<input type="text" size="20" name="mountpoint"
- tal:attributes="value mountpoint | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value mountpoint | nothing" />
</td>
</tr>
@@ -635,7 +718,9 @@
<td class="systemsTable">Host</td>
<td class="systemsTable">
<input type="text" size="20" name="host"
- tal:attributes="value hostname | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value hostname | nothing" />
</td>
</tr>
@@ -643,7 +728,9 @@
<td class="systemsTable">Export path</td>
<td class="systemsTable">
<input type="text" size="20" name="exportpath"
- tal:attributes="value expath | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value expath | nothing" />
</td>
</tr>
@@ -651,11 +738,15 @@
<td class="systemsTable">NFS version</td>
<td class="systemsTable">
<input type="radio" name="nfstype" value="nfs"
- tal:attributes="checked python: (edit == nothing or nfstype == 'nfs') and 'checked'" />
+ tal:attributes="
+ disabled python: editDisabled;
+ checked python: (edit == nothing or nfstype == 'nfs') and 'checked'" />
NFS (version 3)
<br/>
<input type="radio" name="nfstype" value="nfs4"
- tal:attributes="checked python: (edit == True and nfstype == 'nfs4') and 'checked'">
+ tal:attributes="
+ disabled python: editDisabled;
+ checked python: (edit == True and nfstype == 'nfs4') and 'checked'">
NFS4
</td>
</tr>
@@ -664,7 +755,9 @@
<td class="systemsTable">Options</td>
<td class="systemsTable">
<input type="text" size="20" name="options"
- tal:attributes="value opt | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value opt | nothing" />
</td>
</tr>
@@ -673,6 +766,7 @@
<td class="systemsTable">
<input type="checkbox" name="forceunmount"
tal:attributes="
+ disabled python: editDisabled;
checked python: force_unmount == '1' and 'checked'" />
</td>
</tr>
@@ -682,10 +776,11 @@
</form>
</div>
-<div class="rescfg" name="NFSC" metal:define-macro="nfsc_macro">
+<div class="rescfg" name="NFSC" tal:attributes="id res/name | nothing" metal:define-macro="nfsc_macro">
<tal:block tal:condition="python: ptype == '33' or ptype == '24'"
tal:define="
global edit python: True;
+ global editDisabled resourceIsRef | nothing;
global resName res/name | nothing;
global target res/attrs/target | nothing;
global opt res/attrs/options | nothing;
@@ -723,7 +818,6 @@
tal:attributes="value cluname | nothing" />
<input name="oldname" type="hidden"
- tal:condition="python: edit == True"
tal:attributes="value res/name | nothing" />
<input name="edit" type="hidden" value="1"
@@ -735,9 +829,10 @@
<tr class="systemsTable">
<td class="systemsTable">Name</td>
<td class="systemsTable">
- <input type="text" size="20"
- name="resourceName"
- tal:attributes="value resName | nothing" />
+ <input type="text" size="20" name="resourceName"
+ tal:attributes="
+ disabled python: editDisabled;
+ value resName | nothing" />
</td>
</tr>
@@ -745,7 +840,9 @@
<td class="systemsTable">Target</td>
<td class="systemsTable">
<input type="text" size="20" name="target"
- tal:attributes="value target | nothing"/>
+ tal:attributes="
+ disabled python: editDisabled;
+ value target | nothing"/>
</td>
</tr>
@@ -753,7 +850,9 @@
<td class="systemsTable">Options</td>
<td class="systemsTable">
<input type="text" size="20" name="options"
- tal:attributes="value opt | nothing"/>
+ tal:attributes="
+ disabled python: editDisabled;
+ value opt | nothing"/>
</td>
</tr>
</table>
@@ -762,10 +861,11 @@
</form>
</div>
-<div class="rescfg" name="NFSX" metal:define-macro="nfsx_macro">
+<div class="rescfg" name="NFSX" tal:attributes="id res/name | nothing" metal:define-macro="nfsx_macro">
<tal:block tal:condition="python: ptype == '33' or ptype == '24'"
tal:define="
global edit python: True;
+ global editDisabled resourceIsRef | nothing;
global resName res/name | nothing;
global cluname request/clustername;
tmp_URL context/cluster/index_html/absolute_url;
@@ -799,7 +899,6 @@
tal:attributes="value cluname | nothing" />
<input name="oldname" type="hidden"
- tal:condition="python: edit == True"
tal:attributes="value res/name | nothing" />
<input name="edit" type="hidden" value="1"
@@ -811,9 +910,10 @@
<tr class="systemsTable">
<td class="systemsTable">Name</td>
<td class="systemsTable">
- <input type="text" size="20"
- name="resourceName"
- tal:attributes="value resName | nothing" />
+ <input type="text" size="20" name="resourceName"
+ tal:attributes="
+ disabled python: editDisabled;
+ value resName | nothing" />
</td>
</tr>
</table>
@@ -822,10 +922,11 @@
</form>
</div>
-<div class="rescfg" name="SCR" metal:define-macro="scr_macro">
+<div class="rescfg" name="SCR" tal:attributes="id res/name | nothing" metal:define-macro="scr_macro">
<tal:block tal:condition="python: ptype == '33' or ptype == '24'"
tal:define="
global edit string:true;
+ global editDisabled resourceIsRef | nothing;
global resName res/name | nothing;
global filename res/attrs/file | nothing;
global cluname request/clustername;
@@ -860,7 +961,6 @@
tal:attributes="value cluname | nothing" />
<input name="oldname" type="hidden"
- tal:condition="python: edit == 'true'"
tal:attributes="value res/name | nothing" />
<input name="edit" type="hidden" value="1"
@@ -872,9 +972,10 @@
<tr class="systemsTable">
<td class="systemsTable">Name</td>
<td class="systemsTable">
- <input type="text" size="20"
- name="resourceName"
- tal:attributes="value resName | nothing" />
+ <input type="text" size="20" name="resourceName"
+ tal:attributes="
+ disabled python: editDisabled;
+ value resName | nothing" />
</td>
</tr>
@@ -882,7 +983,9 @@
<td class="systemsTable">Full path to script file</td>
<td class="systemsTable">
<input type="text" size="20" name="file"
- tal:attributes="value filename | nothing" />
+ tal:attributes="
+ disabled python: editDisabled;
+ value filename | nothing" />
</td>
</tr>
</table>
@@ -891,10 +994,11 @@
</form>
</div>
-<div class="rescfg" name="SMB" metal:define-macro="smb_macro">
+<div class="rescfg" name="SMB" tal:attributes="id res/name | nothing" metal:define-macro="smb_macro">
<tal:block tal:condition="python: ptype == '33' or ptype == '24'"
tal:define="
global edit python: True;
+ global editDisabled resourceIsRef | nothing;
global resName res/name | nothing;
global workgroup res/attrs/workgroup | nothing;
global cluname request/clustername;
@@ -908,10 +1012,7 @@
tmp_URL context/cluster/index_html/absolute_url;
global processURL python: tmp_URL+'?pagetype=35&clustername='+cluname" />
- <p class="reshdr"
- tal:condition="python: edit != 'true'">
- Samba Server Configuration
- </p>
+ <p class="reshdr">Samba Server Configuration</p>
<form method="post"
tal:attributes="
@@ -933,7 +1034,6 @@
tal:attributes="value cluname | nothing" />
<input name="oldname" type="hidden"
- tal:condition="python: edit == True"
tal:attributes="value res/name | nothing" />
<input name="edit" type="hidden" value="1"
@@ -945,9 +1045,10 @@
<tr class="systemsTable">
<td class="systemsTable">Name</td>
<td class="systemsTable">
- <input type="text" size="20"
- name="resourceName"
- tal:attributes="value resName | nothing" />
+ <input type="text" size="20" name="resourceName"
+ tal:attributes="
+ disabled python: editDisabled;
+ value resName | nothing" />
</td>
</tr>
@@ -955,7 +1056,9 @@
<td class="systemsTable">Workgroup</td>
<td class="systemsTable">
<input type="text" size="20" name="workgroup"
- tal:attributes="value workgroup | nothing"/>
+ tal:attributes="
+ disabled python: editDisabled;
+ value workgroup | nothing" />
</td>
</tr>
</table>
--- conga/luci/cluster/resource_form_handlers.js 2006/09/14 21:24:24 1.8
+++ conga/luci/cluster/resource_form_handlers.js 2006/09/22 18:21:59 1.9
@@ -1,3 +1,24 @@
+function swap_in_global_res(container_id, res_id, replace, form) {
+ var container = document.getElementById(container_id);
+ if (!container)
+ return (-1);
+ var res = document.getElementById(res_id);
+ if (!res)
+ return (-1);
+ if (!replace)
+ return (-1);
+ var new_uuid = update_resource_form_uuid(res, form.parent_uuid.value, form.tree_level.value);
+ res.id = new_uuid;
+ if (form.gres_chooser && form.gres_chooser.options) {
+ var o = form.gres_chooser.options;
+ for (var i = 0 ; i < o.length ; i++) {
+ if (o[i].value == res_id)
+ o[i] = null;
+ }
+ }
+ return (replace.parentNode.replaceChild(res, replace));
+}
+
function collapse_div(image) {
var span = null;
var pdiv = image.parentNode;
@@ -175,6 +196,7 @@
}
function delete_resource(form) {
+ /* XXX - remove names from used list, replace global resources */
if (!confirm('Are you sure you want to delete this resource?'))
return (-1);
var div = document.getElementById(form.uuid.value);
@@ -189,6 +211,38 @@
}
}
+function update_resource_form_uuid(node, parent_uuid, indent_level) {
+ var forms = node.getElementsByTagName('form');
+ for (var i = 0 ; i < forms.length ; i++)
+ forms.name = parent_uuid;
+ var ielem = node.getElementsByTagName('input');
+ if (!ielem)
+ return (null);
+ var new_uuid = uuid_list.pop();
+ var used_new_uuid = 0;
+ for (var i = 0 ; i < ielem.length ; i++) {
+ if (ielem[i].getAttribute('name') == 'tree_level')
+ ielem[i].value = indent_level;
+ else if (ielem[i].getAttribute('name') == 'parent_uuid')
+ ielem[i].value = parent_uuid;
+ else if (ielem[i].getAttribute('name') == 'uuid') {
+ if (!new_uuid) {
+ alert('You have too many pending children. Update first.');
+ return (null);
+ }
+ ielem[i].value = new_uuid;
+ ++used_new_uuid;
+ }
+ }
+
+ if (!used_new_uuid) {
+ uuid_list.push(new_uuid);
+ return (null);
+ }
+
+ return (new_uuid);
+}
+
function add_child_resource(form) {
if (!form || !form.tree_level || !form.parent_uuid || !form.uuid ||
!is_valid_int(form.tree_level.value, 0, null))
@@ -221,29 +275,10 @@
var node = sdiv.cloneNode(1);
node.id = null;
node.className = null;
- ielem = node.getElementsByTagName('input');
- if (!ielem) {
- return (-1);
- }
- forms = node.getElementsByTagName('form');
- for (var i = 0 ; i < forms.length ; i++)
- forms.name = form.uuid.value;
-
- var new_uuid = uuid_list.pop();
- for (var i = 0 ; i < ielem.length ; i++) {
- if (ielem[i].getAttribute('name') == 'tree_level')
- ielem[i].value = ilevel;
- else if (ielem[i].getAttribute('name') == 'parent_uuid')
- ielem[i].value = form.uuid.value;
- else if (ielem[i].getAttribute('name') == 'uuid') {
- if (!new_uuid) {
- alert('You have too many pending children. Update first.');
- return (-1);
- }
- ielem[i].value = new_uuid;
- }
- }
+ var new_uuid = update_resource_form_uuid(node, form.uuid.value, ilevel);
+ if (!new_uuid)
+ return (-1);
if (!child_div) {
var pelem = pdiv.getElementsByTagName('p');
More information about the Cluster-devel
mailing list