* [Cluster-devel] conga/luci cluster/form-macros homebase/homeba ...
@ 2006-08-17 16:22 rmccabe
0 siblings, 0 replies; 4+ messages in thread
From: rmccabe @ 2006-08-17 16:22 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-08-17 16:22:41
Modified files:
luci/cluster : form-macros
luci/homebase : homebase_common.js
Added files:
luci/cluster : validate_config_fence.js
validate_config_multicast.js
validate_config_qdisk.js
Removed files:
luci/cluster : validate_qdisk.js
Log message:
more javascript form validation
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_fence.js.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_multicast.js.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_qdisk.js.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_qdisk.js.diff?cvsroot=cluster&r1=1.2&r2=NONE
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.4&r2=1.5
/cvs/cluster/conga/luci/cluster/validate_config_fence.js,v --> standard output
revision 1.1
--- conga/luci/cluster/validate_config_fence.js
+++ - 2006-08-17 16:22:42.036280000 +0000
@@ -0,0 +1,23 @@
+function validate_form(form) {
+ var errors = new Array();
+
+ if (!form)
+ return (-1);
+
+ if (!form.post_fail_delay || str_is_blank(form.post_fail_delay.value))
+ errors.push('No post fail delay value was given.');
+ else if (!is_valid_int(form.post_fail_delay.value, 0, null))
+ errors.push('The post fail delay must be a non-negative integer value.');
+
+ if (!form.post_join_delay || str_is_blank(form.post_join_delay.value))
+ errors.push('No post join delay value was given.');
+ else if (!is_valid_int(form.post_join_delay.value, 0, null))
+ errors.push('The post join delay must be a non-negative integer value.');
+
+ if (error_dialog(errors))
+ return (-1);
+
+ if (confirm('Update cluster fence daemon properties?'))
+ form.submit();
+ return (0);
+}
/cvs/cluster/conga/luci/cluster/validate_config_multicast.js,v --> standard output
revision 1.1
--- conga/luci/cluster/validate_config_multicast.js
+++ - 2006-08-17 16:22:42.136456000 +0000
@@ -0,0 +1,56 @@
+var prev_mcast_str = '';
+
+function disable_mcast(addrId) {
+ addrObj = document.getElementById(addrId);
+ if (!addrObj || addrObj.disabled)
+ return;
+ addrObj.disabled = true;
+ prev_mcast_str = addrObj.value;
+ addrObj.value = '';
+}
+
+function enable_mcast(addrId) {
+ addrObj = document.getElementById(addrId);
+ if (!addrObj || !addrObj.disabled)
+ return;
+ addrObj.disabled = false;
+ addrObj.value = prev_mcast_str;
+}
+
+function validate_form(form) {
+ var errors = new Array();
+
+ if (!form.mcast) {
+ errors.push('You did not specify how the multicast address should be chosen.');
+ error_dialog(errors);
+ return (-1);
+ }
+
+ var mcast;
+ if (form.mcast.length > 0 && form.mcast[0].checked)
+ mcast = 0;
+ else if (form.mcast.length > 1 && form.mcast[1].checked)
+ mcast = 1;
+ else
+ errors.push('An invalid value was given while specifying how the multicast address should be chosen.');
+
+ if (error_dialog(errors))
+ return (-1);
+
+ if (mcast) {
+ if (!form.mcast_address || str_is_blank(form.mcast_address.value))
+ errors.push('No multicast address was given.');
+ else {
+ var err = isValidHost(form.mcast_address.value);
+ if (err)
+ errors.push(err);
+ }
+ }
+
+ if (error_dialog(errors))
+ return (-1);
+
+ if (confirm('Update cluster multicast properties?'))
+ form.submit();
+ return (0);
+}
/cvs/cluster/conga/luci/cluster/validate_config_qdisk.js,v --> standard output
revision 1.1
--- conga/luci/cluster/validate_config_qdisk.js
+++ - 2006-08-17 16:22:42.317675000 +0000
@@ -0,0 +1,246 @@
+function check_heuristic(hnum, form) {
+ var errors = new Array();
+
+ if (hnum < 0)
+ errors.push('An invalid heuristic number was given: ' + hnum);
+ else if (hnum > 9)
+ errors.push('A maximum of 10 heuristics is allowed.');
+
+ if (errors.length > 0)
+ return (errors);
+
+ hstr = 'heuristic' + hnum + ':';
+
+ hname = document.getElementById(hstr + 'hname');
+ if (!hname || str_is_blank(hname.value))
+ errors.push('No name was given for heuristic ' + (hnum + 1));
+ else
+ hname = hname.value;
+
+ hpath = document.getElementById(hstr + 'hpath');
+ if (!hpath || str_is_blank(hpath.value))
+ errors.push('No path was given for heuristic ' + (hnum + 1));
+ else
+ hpath = hpath.value;
+
+ hint = document.getElementById(hstr + 'hinterval');
+ if (!hint || str_is_blank(hint.value))
+ errors.push('No interval was given for heuristic ' + (hnum + 1));
+ else
+ hint = hint.value;
+
+ hscore = document.getElementById(hstr + 'hscore');
+ if (!hscore || str_is_blank(hscore.value))
+ errors.push('No score was given for heuristic ' + (hnum + 1));
+ else
+ hscore = hscore.value;
+
+ if (errors.length == 4) {
+ /* The entry is blank -- ignore it. */
+ return (null);
+ }
+
+ /* TODO: hname, hpath */
+ if (hint && !is_valid_int(hint, 1, null))
+ errors.push('Heuristic interval values must be integers greater than 0.');
+
+ if (hscore && !is_valid_int(hscore, null, null))
+ errors.push('Heuristic score values must be integers.');
+
+ if (errors.length > 0)
+ return (errors);
+
+ return (null);
+}
+
+function validate_form(form) {
+ var errors = new Array();
+ if (!form || !form.quorumd) {
+ errors.push('You did not specify whether or not to use a quorum partition.');
+ return (error_dialog(errors));
+ }
+
+ if (form.quorumd[0].checked)
+ qpart = 0
+ else if (form.quorumd[1].checked)
+ qpart = 1;
+ else {
+ errors.push('You submitted an invalid value while specifying whether or not to use a quorum partition: ' + qpart + '.');
+ return (error_dialog(errors));
+ }
+
+ if (qpart) {
+ if (!form.interval || str_is_blank(form.interval.value))
+ errors.push('No interval setting was given.');
+ else {
+ if (!is_valid_int(form.interval.value, 1, null))
+ errors.push('Interval values must be integers greater than 0.');
+ }
+
+ if (!form.votes || str_is_blank(form.votes.value))
+ errors.push('No votes setting was given.');
+ else {
+ if (!is_valid_int(form.votes.value, null, null))
+ errors.push('Votes values must be integers.');
+ }
+
+ if (!form.tko || str_is_blank(form.tko.value))
+ errors.push('No TKO setting was given.');
+ else {
+ if (!is_valid_int(form.tko.value, null, null))
+ errors.push('TKO values must be integers.');
+ }
+
+ if (!form.min_score || str_is_blank(form.min_score.value))
+ errors.push('No minimum score setting was given.');
+ else {
+ if (!is_valid_int(form.min_score.value, null, null))
+ errors.push('Minimum score values must be integers.');
+ }
+
+ if (!form.device || str_is_blank(form.device.value))
+ errors.push('No device setting was given.');
+ else {
+ /* TODO: check this */
+ device = form.device.value;
+ }
+
+ if (!form.label || str_is_blank(form.label.value))
+ errors.push('No label setting was given.');
+ else {
+ /* TODO: check this */
+ label = form.device.label;
+ }
+
+ hnum = document.getElementById('num_heuristics');
+ if (hnum) {
+ hnum = Number(hnum.value);
+ if (hnum == 0)
+ hnum++;
+ for (var i = 0 ; i < hnum ; i++) {
+ var err = check_heuristic(i, form);
+ if (err)
+ errors = errors.concat(err);
+ }
+ }
+
+ if (error_dialog(errors))
+ return (-1);
+ }
+
+ if (confirm('Update quorum partition properties?'))
+ form.submit()
+}
+
+var oldInput = null;
+
+function addHeuristic(parent_name) {
+ parent = document.getElementById(parent_name);
+ if (!parent)
+ return;
+ hnum = document.getElementById('num_heuristics');
+ if (!hnum)
+ return;
+
+ var cur_hnum = Number(hnum.value) + 1;
+ if (cur_hnum >= 10) {
+ alert('There is a maximum of 10 heuristics.');
+ return;
+ }
+ hstr = 'heuristic' + cur_hnum + ':';
+
+ name_td = document.createElement('td');
+ name_td.className = 'systemsTable';
+ name_input = document.createElement('input');
+ name_input.className = 'qdname qdisk';
+ name_input.setAttribute('name', hstr + 'hname');
+ name_input.setAttribute('id', hstr + 'hname');
+ name_input.setAttribute('type', 'text');
+ name_td.appendChild(name_input);
+
+ path_td = document.createElement('td');
+ path_td.className = 'systemsTable';
+ path_input = document.createElement('input');
+ path_input.className = 'qdpath qdisk';
+ path_input.setAttribute('name', hstr + 'hprog');
+ path_input.setAttribute('id', hstr + 'hprog');
+ path_input.setAttribute('type', 'text');
+ path_td.appendChild(path_input);
+
+ interval_td = document.createElement('td');
+ interval_td.className = 'systemsTable';
+ interval_input = document.createElement('input');
+ interval_input.className = 'qdint qdisk';
+ interval_input.setAttribute('name', hstr + 'hinterval');
+ interval_input.setAttribute('id', hstr + 'hinterval');
+ interval_input.setAttribute('type', 'text');
+ interval_td.appendChild(interval_input);
+
+ score_td = document.createElement('td');
+ score_td.className = 'systemsTable';
+ score_input = document.createElement('input');
+ score_input.className = 'qdscore qdisk';
+ score_input.setAttribute('name', hstr + 'hscore');
+ score_input.setAttribute('id', hstr + 'hscore');
+ score_input.setAttribute('type', 'input');
+ score_td.appendChild(score_input);
+
+ tr = document.createElement('tr');
+ tr.className = 'systemsTable';
+ tr.appendChild(name_td);
+ tr.appendChild(path_td);
+ tr.appendChild(interval_td);
+ tr.appendChild(score_td);
+ parent.appendChild(tr);
+ hnum.value++;
+}
+
+function disableChildrenInput(parent_name) {
+ parent = document.getElementById(parent_name);
+ if (!parent)
+ return;
+
+ inputElem = parent.getElementsByTagName('input');
+ if (!inputElem || inputElem.length < 1) {
+ oldInput = null;
+ return;
+ }
+ if (inputElem[0].disabled)
+ return;
+ oldInput = new Array(inputElem.length);
+ for (var i = 0 ; i < inputElem.length ; i++) {
+ e = inputElem[i];
+
+ e.disabled = true;
+ if (e.type == 'button')
+ continue;
+ oldInput[e.name] = e.value;
+ e.value = '';
+ }
+}
+
+function enableChildrenInput(parent_name) {
+ parent = document.getElementById(parent_name);
+ if (!parent)
+ return;
+
+ inputElem = parent.getElementsByTagName('input');
+ if (!inputElem || inputElem.length < 1) {
+ return;
+ }
+
+ if (!inputElem[0].disabled)
+ return;
+
+ for (var i = 0 ; i < inputElem.length ; i++) {
+ e = inputElem[i];
+ e.disabled = false;
+ if (e.type == 'button')
+ continue;
+ if (oldInput && oldInput[e.name])
+ e.value = oldInput[e.name];
+ else
+ e.value = '';
+ }
+ oldInput = null;
+}
--- conga/luci/cluster/form-macros 2006/08/16 23:40:03 1.49
+++ conga/luci/cluster/form-macros 2006/08/17 16:22:41 1.50
@@ -361,6 +361,8 @@
<div id="configTabContent" tal:condition="python: configTabNum == 2">
<form name="fencedaemon" action="" method="get" tal:attributes="action clusterinfo/fencedaemon_url">
+ <script type="text/javascript" src="/luci/homebase/homebase_common.js"></script>
+ <script type="text/javascript" src="/luci/cluster/validate_config_fence.js"></script>
<table id="systemsTable" class="systemsTable" border="0" cellspacing="0">
<thead class="systemsTable">
<tr class="systemsTable"><td class="systemsTable" colspan="1">
@@ -389,7 +391,7 @@
<tr class="systemsTable">
<td class="systemsTable" colspan="2">
<div class="systemsTableEnd">
- <input type="submit" value="Apply"/>
+ <input type="button" value="Apply" onClick="validate_form(this.form);" />
</div>
</td>
</tr>
@@ -399,28 +401,10 @@
</div>
<div id="configTabContent" tal:condition="python: configTabNum == 3">
- <script type="text/javascript">
- var prev_mcast_str = '';
+ <script type="text/javascript" src="/luci/homebase/homebase_common.js"></script>
+ <script type="text/javascript" src="/luci/cluster/validate_config_multicast.js"></script>
- function disable_mcast(addrId) {
- addrObj = document.getElementById(addrId);
- if (!addrObj || addrObj.disabled)
- return;
- addrObj.disabled = true;
- prev_mcast_str = addrObj.value;
- addrObj.value = '';
- }
-
- function enable_mcast(addrId) {
- addrObj = document.getElementById(addrId);
- if (!addrObj || !addrObj.disabled)
- return;
- addrObj.disabled = false;
- addrObj.value = prev_mcast_str;
- }
- </script>
-
- <form name="multicast" action="" method="get" tal:attributes="action clusterinfo/multicast_url">
+ <form name="multicast" action="" method="post">
<table id="systemsTable" class="systemsTable" border="0" cellspacing="0">
<thead class="systemsTable">
<tr class="systemsTable"><td class="systemsTable" colspan="1">
@@ -466,7 +450,7 @@
<tfoot class="systemsTable">
<tr class="systemsTable"><td class="systemsTable" colspan="2">
<div class="systemsTableEnd">
- <input type="submit" value="Apply"/>
+ <input type="button" value="Apply" onClick="validate_form(this.form);"/>
</div>
</td></tr>
</tfoot>
@@ -476,7 +460,7 @@
<div id="configTabContent" tal:condition="python: configTabNum == 4">
<script type="text/javascript" src="/luci/homebase/homebase_common.js"></script>
- <script type="text/javascript" src="/luci/cluster/validate_qdisk.js"></script>
+ <script type="text/javascript" src="/luci/cluster/validate_config_qdisk.js"></script>
<form name="quorum_partition" action="" method="post">
<input type="hidden" name="pagetype"
tal:attributes="value request/pagetype | request/form/pagetype"
--- conga/luci/homebase/homebase_common.js 2006/08/16 22:59:09 1.4
+++ conga/luci/homebase/homebase_common.js 2006/08/17 16:22:41 1.5
@@ -1,8 +1,8 @@
function is_valid_int(str, min, max) {
- if (str.match(/[^0-9 ]/))
+ if (str.match(/[^0-9 -]/))
return (0);
var val = parseInt(str, 10);
- if (!val || isNaN(val))
+ if (isNaN(val))
return (0);
if (min != null && val < min)
return (0);
^ permalink raw reply [flat|nested] 4+ messages in thread* [Cluster-devel] conga/luci cluster/form-macros homebase/homeba ...
@ 2007-07-12 22:35 rmccabe
0 siblings, 0 replies; 4+ messages in thread
From: rmccabe @ 2007-07-12 22:35 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-07-12 22:35:40
Modified files:
luci/cluster : form-macros
luci/homebase : homebase_common.js
luci/plone-custom: conga.js
luci/site/luci/Extensions: LuciClusterInfo.py LuciDB.py
PropsObject.py RicciQueries.py
cluster_adapters.py
ricci_communicator.py
Log message:
Most of the fix for 247521: Luci returns mis-leading errors if cluster.conf has a syntax error
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.203&r2=1.204
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/plone-custom/conga.js.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciDB.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/RicciQueries.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.260&r2=1.261
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.28&r2=1.29
--- conga/luci/cluster/form-macros 2007/07/12 15:44:43 1.203
+++ conga/luci/cluster/form-macros 2007/07/12 22:35:39 1.204
@@ -122,14 +122,20 @@
</td>
</tr>
- <tr class="cluster">
- <td tal:condition="exists: cstatus/error" class="cluster">
+ <tr class="cluster" tal:condition="exists:cstatus/error">
+ <td class="cluster">
<span class="errmsgs">
An error occurred while attempting to get status information for this cluster. The information shown may be stale or inaccurate.
</span>
</td>
</tr>
+ <tr class="cluster" tal:condition="exists:cstatus/errmsg">
+ <td class="cluster">
+ <span class="errmsgs" tal:content="cstatus/errmsg" />
+ </td>
+ </tr>
+
<tr class="cluster info_middle">
<td colspan="2" class="cluster cluster_quorum">
<ul class="cluster_quorum"
--- conga/luci/homebase/homebase_common.js 2007/07/12 15:44:43 1.19
+++ conga/luci/homebase/homebase_common.js 2007/07/12 22:35:39 1.20
@@ -108,14 +108,6 @@
}
}
-function hide_element(id) {
- var elem = document.getElementById(id);
- if (elem) {
- elem.style.visibility = 'hidden';
- elem.style.display = 'none';
- }
-}
-
function isValidHost(str) {
var i = str.split('.');
--- conga/luci/plone-custom/conga.js 2007/06/25 16:11:30 1.5
+++ conga/luci/plone-custom/conga.js 2007/07/12 22:35:39 1.6
@@ -11,6 +11,14 @@
return str.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace('\'', ''');
}
+function hide_element(id) {
+ var elem = document.getElementById(id);
+ if (elem) {
+ elem.style.visibility = 'hidden';
+ elem.style.display = 'none';
+ }
+}
+
function popup_window(url, width_percent, height_percent) {
var width = window.innerWidth * (width_percent / 100);
var height = window.innerHeight * (height_percent / 100);
--- conga/luci/site/luci/Extensions/LuciClusterInfo.py 2007/07/12 15:44:43 1.6
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py 2007/07/12 22:35:40 1.7
@@ -123,36 +123,38 @@
return results
def getClusterStatus(self, request, rc, cluname=None):
-
try:
- doc = rq.getClusterStatusBatch(rc)
- if not doc:
- raise Exception, 'doc is None'
+ doc = rq.getClusterStatusBatch(rc) or None
except Exception, e:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('GCS0: error: %r %s' % (e, str(e)))
+ luci_log.debug_verbose('GCS0: error: %r: %r %s' \
+ % (cluname, e, str(e)))
doc = None
- if doc is None and not cluname:
- try:
- model = request.SESSION.get('model')
- cinfo = getClusterStatusModel(model)
- if not cinfo or len(cinfo) < 1:
- raise Exception, 'cinfo is None'
- return cinfo
- except Exception, e:
- if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('GCS1: %r %s' % (e, str(e)))
- doc = None
+ if doc is None:
+ model = LuciExtractCluModel(self, request, cluname)
+ if model is not None:
+ try:
+ cinfo = getClusterStatusModel(model)
+ if not cinfo or len(cinfo) < 1:
+ raise Exception, 'cinfo is None'
+ return cinfo
+ except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GCS1: %r: %r %s' \
+ % (cluname, e, str(e)))
- if not doc:
+ if doc is None:
try:
from LuciDB import getClusterStatusDB
- fvars = GetReqVars(request, [ 'clustername' ])
+ if cluname:
+ clustername = cluname
+ else:
+ fvars = GetReqVars(request, [ 'clustername' ])
- clustername = fvars['clustername']
- if clustername is None:
- raise Exception, 'unable to determine cluster name'
+ clustername = fvars['clustername']
+ if clustername is None:
+ raise Exception, 'unable to determine cluster name'
cinfo = getClusterStatusDB(self, clustername)
if not cinfo or len(cinfo) < 1:
@@ -160,7 +162,8 @@
return cinfo
except Exception, e:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('GCS1a: unable to get cluster info from DB: %r %s' % (e, str(e)))
+ luci_log.debug_verbose('GCS2: cluster %r info from DB: %r %s' \
+ % (cluname, e, str(e)))
return []
results = list()
@@ -699,11 +702,13 @@
def getClustersInfo(self, status, req):
clu_map = {}
+
+ fvars = GetReqVars(req, [ 'URL' ])
+ baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+
nodelist = list()
svclist = list()
clulist = list()
- baseurl = req['URL']
-
for item in status:
if item['type'] == 'node':
nodelist.append(item)
@@ -713,11 +718,14 @@
clulist.append(item)
else:
continue
+
if len(clulist) < 1:
return {}
clu = clulist[0]
- if 'error' in clu:
- clu_map['error'] = True
+ if clu.has_key('error'):
+ clu_map['error'] = clu['error']
+ if clu.has_key('errmsg'):
+ clu_map['errmsg'] = clu['errmsg']
clustername = clu['name']
if not clu['alias']:
clu_map['clusteralias'] = clu['alias']
@@ -788,7 +796,8 @@
def getNodeInfo(self, model, status, request):
infohash = {}
item = None
- baseurl = request['URL']
+ fvars = GetReqVars(request, [ 'URL', 'clustername', 'nodename' ])
+ baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
nodestate = NODE_ACTIVE
svclist = list()
@@ -796,13 +805,12 @@
if thing['type'] == 'service':
svclist.append(thing)
- # Get cluster name and node name from request
- try:
- clustername = request['clustername']
- nodename = request['nodename']
- except Exception, e:
+ clustername = fvars['clustername']
+ nodename = fvars['nodename']
+ if clustername is None or nodename is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('getNodeInfo0: %r %s' % (e, str(e)))
+ luci_log.debug_verbose('getNodeInfo0: %r %r' \
+ % (clustername, nodename))
return {}
# extract correct node line from cluster status
@@ -900,7 +908,7 @@
try:
rc = RicciCommunicator(nodename_resolved)
if not rc:
- raise Exception, 'rc is none'
+ raise Exception, 'connection failed'
except Exception, e:
rc = None
infohash['ricci_error'] = True
@@ -930,6 +938,10 @@
nodelist = list()
svclist = list()
+ fvars = GetReqVars(req, [ 'URL', 'clustername' ])
+ baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+ clustername = fvars['clustername']
+
#Sort into lists...
for item in status:
if item['type'] == 'node':
@@ -939,24 +951,14 @@
else:
continue
- try:
- clustername = req['clustername']
- if not clustername:
- raise KeyError, 'clustername is blank'
- except:
+ if clustername is None:
try:
- clustername = req.form['clustername']
- raise KeyError, 'clustername is blank'
- except:
- try:
- clustername = req.form['clustername']
- except:
- try:
- clustername = model.getClusterName()
- except:
- if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('GNI0: unable to determine cluster name')
- return {}
+ clustername = model.getClusterName().strip()
+ except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GNI0: no cluster name: %r %s' \
+ % (e, str(e)))
+ return {}
for item in nodelist:
nl_map = {}
@@ -968,11 +970,6 @@
except:
nl_map['gulm_lockserver'] = False
- try:
- baseurl = req['URL']
- except:
- baseurl = '/luci/cluster/index_html'
-
cfgurl = '%s?pagetype=%s&clustername=%s&nodename=%s' \
% (baseurl, NODE, clustername, name)
nl_map['configurl'] = cfgurl
@@ -1058,9 +1055,11 @@
luci_log.debug_verbose('getFence0: model is None')
return {}
- fence_map = {}
- fencename = request['fencename']
+ fvars = GetReqVars(request, [ 'URL', 'fencename' ])
+ baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+ fencename = fvars['fencename']
+ fence_map = {}
nodes = model.getNodes()
fencedevs = model.getFenceDevices()
clustername = model.getClusterName()
@@ -1090,7 +1089,6 @@
found_duplicate = True
if found_duplicate is True:
continue
- baseurl = request['URL']
node_hash = {}
cur_nodename = node.getName().strip()
node_hash['nodename'] = cur_nodename
@@ -1398,8 +1396,10 @@
fences_map['fencedevs'] = list()
return fences_map
- clustername = request['clustername']
- baseurl = request['URL']
+ fvars = GetReqVars(request, [ 'clustername', 'URL' ])
+ baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+ clustername = fvars['clustername'] or model.getClusterName()
+
fencedevs = list() #This is for the fencedev list page
#Get list of fence devices
@@ -1556,6 +1556,37 @@
luci_log.debug_verbose('GMFC1: unable to get model builder for %s: %r %s' % (clustername, e, str(e)))
return None
+def LuciExtractCluModel(self, request, cluster_name=None):
+ model = None
+ try:
+ model = request.SESSION.get('model')
+ model.getClusterName()
+ return model
+ except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('LECM0: %r: %r %s' \
+ % (cluster_name, e, str(e)))
+ model = None
+
+ if not cluster_name:
+ fvar = GetReqVars(request, [ 'clustername' ])
+ cluster_name = fvar['clustername']
+
+ if cluster_name is None:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('LECM1: no cluster name')
+ return None
+
+ try:
+ model = getModelForCluster(self, cluster_name)
+ model.getClusterName()
+ return model
+ except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('LECM2: no model for %s: %r %s' \
+ % (cluster_name, e, str(e)))
+ return None
+
def getClusterOS(self, rc):
from HelperFunctions import resolveOSType
--- conga/luci/site/luci/Extensions/LuciDB.py 2007/06/28 16:02:50 1.4
+++ conga/luci/site/luci/Extensions/LuciDB.py 2007/07/12 22:35:40 1.5
@@ -931,7 +931,7 @@
luci_log.debug_verbose('GCF0: cluster %s [%s] folder missing: %r %s -- returning empty map' % (cluname, path, e, str(e)))
return None
-def getClusterStatusDB(self, clustername):
+def getClusterStatusDB(self, clustername, errmsg=None):
results = list()
vals = {}
@@ -942,12 +942,14 @@
vals['quorate'] = '[unknown]'
vals['votes'] = '[unknown]'
vals['minQuorum'] = '[unknown]'
+ if errmsg:
+ vals['errmsg'] = errmsg
results.append(vals)
nodelist = getClusterDBNodes(self, clustername)
if len(nodelist) < 1:
- if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('GCSDB0a: removing cluster %s because it has no nodes' % clustername)
+ luci_log.info('Removing cluster %s because it has no nodes' \
+ % clustername)
try:
clusters_dir = self.restrictedTraverse(CLUSTER_FOLDER_PATH)
clusters_dir.manage_delObjects([clustername])
@@ -960,7 +962,7 @@
for node in nodelist:
node_val = {}
node_val['type'] = 'node'
- node_val['name'] = node
+ node_val['name'] = node[0]
node_val['clustered'] = '[unknown]'
node_val['online'] = '[unknown]'
node_val['error'] = True
--- conga/luci/site/luci/Extensions/PropsObject.py 2007/07/12 15:44:43 1.5
+++ conga/luci/site/luci/Extensions/PropsObject.py 2007/07/12 22:35:40 1.6
@@ -7,7 +7,7 @@
from Variable import parse_variable
from ricci_defines import PROPS_TAG
-from xml.dom.Node import ELEMENT_NODE
+import xml.dom
class PropsObject:
@@ -35,7 +35,7 @@
def import_xml(self, parent_node):
props = None
for node in parent_node.childNodes:
- if node.nodeType == ELEMENT_NODE:
+ if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == PROPS_TAG:
props = node
if props is None:
--- conga/luci/site/luci/Extensions/RicciQueries.py 2007/06/27 08:14:13 1.3
+++ conga/luci/site/luci/Extensions/RicciQueries.py 2007/07/12 22:35:40 1.4
@@ -289,6 +289,9 @@
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="status"/></request></module>'
ricci_xml = rc.batch_run(batch_str, async=False)
+ if not ricci_xml:
+ return None
+
try:
cluster_tags = ricci_xml.getElementsByTagName('cluster')
except Exception, e:
@@ -300,10 +303,12 @@
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('GCSB1: %d entries - expecting 1' \
% len(cluster_tags))
+ return None
elif len(cluster_tags) > 1:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('GCSB2: %d entries, expecting 1 use first' \
% len(cluster_tags))
+
try:
cluster_node = cluster_tags[0]
if not cluster_node:
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/07/03 17:05:59 1.260
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/07/12 22:35:40 1.261
@@ -25,9 +25,11 @@
from LuciSyslog import get_logger
from ResourceHandler import create_resource
from homebase_adapters import parseHostForm
-from LuciClusterInfo import getClusterInfo, getModelBuilder, getModelForCluster
from LuciClusterActions import propagateClusterConfAsync
+from LuciClusterInfo import getClusterInfo, \
+ getModelBuilder, LuciExtractCluModel
+
from conga_constants import BATCH_ID, CLUNODE_CREATE_ERRORS, \
CLUSTER_ADD, CLUSTER_CONFIG, CLUSTER_DAEMON, CLUSTER_DELETE, \
CLUSTER_FOLDER_PATH, CLUSTER_RESTART, CLUSTER_START, CLUSTER_STOP, \
@@ -545,8 +547,7 @@
try:
model = getModelBuilder(None, cluster_ricci, cluster_ricci.dom0())
if not model:
- errors.append('Unable to build the cluster model for %s' \
- % clustername)
+ errors.append('Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername)
raise Exception, 'unable to get model for %s' % clustername
nodesptr = model.getClusterNodesPtr()
@@ -560,8 +561,7 @@
% (node_name, clustername))
except Exception, e:
incomplete = True
- errors.append('Unable to build the cluster model for %s' \
- % clustername)
+ errors.append('Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('VACN11: %r %s' % (e, str(e)))
@@ -629,7 +629,7 @@
raise Exception, 'batch or result is None'
except Exception, e:
incomplete = True
- errors.append('Unable to save the new cluster model')
+ errors.append('Unable to generate the new cluster configuration')
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('VACN14: %s' % e)
@@ -728,7 +728,7 @@
if model is None:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('vSA1: no model')
- return (False, {'errors': ['No cluster model was found']})
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
try:
doc = minidom.parseString(form_xml)
@@ -921,12 +921,11 @@
luci_log.debug_verbose('VRA0: type is blank')
return (False, {'errors': ['No resource type was given']})
- try:
- model = request.SESSION.get('model')
- except Exception, e:
+ model = LuciExtractCluModel(self, request)
+ if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VRA1: no model: %r %s' % (e, str(e)))
- return None
+ luci_log.debug_verbose('VRA1: no model')
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration. The configuration XML may contain errors' ]})
errors = list()
try:
@@ -1397,8 +1396,8 @@
model = LuciExtractCluModel(self, request, clustername)
if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VCC0: no model, no cluster name')
- return (False, {'errors': ['No cluster model was found']})
+ luci_log.debug_verbose('VCC0: no model')
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
if clustername is None:
clustername = model.getClusterName()
@@ -1437,37 +1436,6 @@
request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \
% (baseurl, CLUSTER_CONFIG, clustername))
-def LuciExtractCluModel(self, request, cluster_name=None):
- model = None
- try:
- model = request.SESSION.get('model')
- model.getClusterName()
- return model
- except Exception, e:
- if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('LECM0: %s: %r %s' \
- % (cluster_name, e, str(e)))
- model = None
-
- if not cluster_name:
- fvar = GetReqVars(request, [ 'clustername' ])
- cluster_name = fvar['clustername']
- if cluster_name is None:
- if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('LECM1: no cluster name')
-
- if cluster_name is None:
- return None
-
- try:
- model = getModelForCluster(self, cluster_name)
- model.getClusterName()
- return model
- except Exception, e:
- if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('LECM2: no model: %r %s' % (e, str(e)))
- return None
-
def validateFenceAdd(self, request):
errors = list()
fvar = GetReqVars(request, [ 'clustername', 'URL' ])
@@ -1476,10 +1444,10 @@
clustername = fvar['clustername']
model = LuciExtractCluModel(self, request, clustername)
- if not model:
+ if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VFE0: no model')
- return (False, { 'errors': [ 'No cluster model was found' ] })
+ luci_log.debug_verbose('VFA0: no model')
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ] })
ret_code, ret_obj = validateNewFenceDevice(request.form, model)
if ret_code != FD_VAL_SUCCESS:
@@ -1502,14 +1470,14 @@
clustername = fvar['clustername']
if clustername is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VFE: No cluster name')
+ luci_log.debug_verbose('VFE0: No cluster name')
return (False, {'errors': ['No cluster name was given']})
model = LuciExtractCluModel(self, request, clustername)
if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VFE: unable to get model from session')
- return (False, {'errors': ['No cluster model was found']})
+ luci_log.debug_verbose('VFE1: no model')
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ] })
# This is a fence edit situation, so the model should already have an
# entry for this fence device.
@@ -1569,9 +1537,8 @@
model = LuciExtractCluModel(self, request, clustername)
if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('vNFC6: unable to get model for cluster %s' \
- % clustername)
- return (False, {'errors': ['No cluster model was found']})
+ luci_log.debug_verbose('vNFC6: no model for %s' % clustername)
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ] })
try:
doc = minidom.parseString(fvar['fence_xml'])
@@ -1798,20 +1765,20 @@
nodename = fvar['nodename']
if nodename is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VFE: no node name')
+ luci_log.debug_verbose('DFD0: no node name')
return (False, {'errors': ['No node name was given']})
clustername = fvar['clustername']
if clustername is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VFE: no cluster name')
+ luci_log.debug_verbose('DFD1: no cluster name')
return (False, {'errors': ['No cluster name was given']})
model = LuciExtractCluModel(self, request, clustername)
if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VFE: model, no cluster name')
- return (False, {'errors': ['No cluster model was found']})
+ luci_log.debug_verbose('DFD2: no model')
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ] })
fencedev_name = fvar['orig_name']
if fencedev_name is None:
@@ -1826,7 +1793,7 @@
if fdev_to_delete is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VFD: Could not find fence device "%s" in model' % fencedev_name)
+ luci_log.debug_verbose('DFD3: Could not find fence device "%s" in model' % fencedev_name)
return (False, {'errors': ['Could not find fence device "%s" in model' % fencedev_name ]})
fdev_ptr = model.getFenceDevicePtr()
@@ -1840,7 +1807,7 @@
model.removeFenceInstancesForFenceDevice(fencedev_name)
except Exception, e:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('VFD: error removing %s: %r %s' \
+ luci_log.debug_verbose('DFD4: error removing %s: %r %s' \
% (fencedev_name, e, str(e)))
ret = propagateClusterConfAsync(self, model, None, CLUSTER_CONFIG,
@@ -1940,15 +1907,15 @@
if clustername is None:
errors.append('Unable to determine this cluster\'s name')
- name = fvar['name']
- if name is None:
- errors.append('No name was given for this failover domain')
-
model = LuciExtractCluModel(self, request, clustername)
if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('validateFdom0: no model: %r %s')
- return (False, {'errors': [ 'Unable to retrieve cluster information' ]})
+ luci_log.debug_verbose('validateFdom0: no model')
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
+
+ name = fvar['name']
+ if name is None:
+ errors.append('No name was given for this failover domain')
prioritized = False
try:
@@ -2051,19 +2018,19 @@
model = LuciExtractCluModel(self, request, clustername)
if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('validateVM0: no model')
- return (False, {'errors': [ 'Unable to retrieve cluster information' ]})
+ luci_log.debug_verbose('validateVM1: no model')
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
vm_name = fvar['vmname']
if vm_name is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('validateVM0: no vm name')
+ luci_log.debug_verbose('validateVM2: no vm name')
errors.append('No virtual machine name was given')
vm_path = fvar['vmpath']
if vm_path is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('validateVM1: no vm path')
+ luci_log.debug_verbose('validateVM3: no vm path')
errors.append('No path to the virtual machine configuration directory was given')
autostart = 1
@@ -2205,7 +2172,7 @@
if getClusterInfo(self, None, req) == {}:
msg_list.append('invalid cluster')
else:
- model = req.SESSION.get('model')
+ model = LuciExtractCluModel(self, req, clustername)
cc = model.exportModelAsString()
return { 'msg': ''.join(msg_list), 'cluster_conf': cc }
@@ -2283,20 +2250,12 @@
if not model:
cluname = fvar['clustername']
- if cluname is None:
+ model = LuciExtractCluModel(self, request, cluname)
+ if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug('CTP1: no cluster name')
- return 'No cluster name was given'
-
- try:
- model = getModelForCluster(self, cluname)
- if not model:
- raise Exception, 'No cluster model'
- except Exception, e:
- if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('CTP2: GMFC failed for %s: %r %s' \
- % (e, str(e), cluname))
- return 'Unable to get the model object for %s' % cluname
+ luci_log.debug_verbose('CTP2: No cluster model for %s' \
+ % cluname)
+ return 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors.' % cluname
redirect_page = NODES
if task == CLUSTER_STOP:
@@ -2312,7 +2271,7 @@
from LuciClusterActions import ClusterDelete
ret = ClusterDelete(self, model)
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('CTP3: ret is %s' % str(e))
+ luci_log.debug_verbose('CTP3: ret is %r' % ret)
if ret is not None:
redirect_page = ret
else:
@@ -2869,20 +2828,19 @@
fvars = GetReqVars(req,
[ 'clustername', 'servicename', 'nodename', 'URL' ])
baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+ clustername = fvars['clustername']
- try:
- model = LuciExtractCluModel(self, req,
- cluster_name=fvars['clustername'])
- except Exception, e:
+ model = LuciExtractCluModel(self, req, clustername)
+ if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('serviceDelete0: %r %s' % (e, str(e)))
- return (False, { 'errors': [ 'No resource name was given' ]})
+ luci_log.debug_verbose('serviceDelete0: no model')
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
ret = DeleteCluSvc(self, rc, fvars, model)
if ret is None:
response = req.RESPONSE
response.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \
- % (baseurl, SERVICES, fvars['clustername']))
+ % (baseurl, SERVICES, clustername))
else:
return ret
@@ -2907,21 +2865,19 @@
fvars = GetReqVars(req,
[ 'clustername', 'resourcename', 'nodename', 'URL' ])
baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+ clustername = fvars['clustername']
- try:
- model = LuciExtractCluModel(self, req, fvars['clustername'])
- if not model:
- raise Exception, 'no model'
- except Exception, e:
+ model = LuciExtractCluModel(self, req, clustername)
+ if model is None:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('resourceDelete0: %r %s' % (e, str(e)))
- return (False, { 'errors': [ 'No resource name was given' ] })
+ luci_log.debug_verbose('resourceDelete0: no model')
+ return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]})
ret = DeleteResource(self, rc, model, fvars['resourcename'])
if ret is None:
response = req.RESPONSE
response.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \
- % (baseurl, RESOURCES, fvars['clustername']))
+ % (baseurl, RESOURCES, clustername))
else:
return ret
--- conga/luci/site/luci/Extensions/ricci_communicator.py 2007/07/03 16:56:39 1.28
+++ conga/luci/site/luci/Extensions/ricci_communicator.py 2007/07/12 22:35:40 1.29
@@ -5,8 +5,7 @@
# GNU General Public License as published by the
# Free Software Foundation.
-from xml.dom import minidom
-from xml.dom.Node import ELEMENT_NODE
+from xml.dom import minidom, Node
from conga_ssl import SSLSocket
from LuciSyslog import get_logger
from conga_constants import LUCI_DEBUG_MODE, LUCI_DEBUG_NET
@@ -242,7 +241,7 @@
batch_node = None
for node in doc.firstChild.childNodes:
- if node.nodeType == ELEMENT_NODE:
+ if node.nodeType == Node.ELEMENT_NODE:
if node.nodeName == 'batch':
batch_node = node#.cloneNode(True)
if batch_node is None:
@@ -361,7 +360,7 @@
batch_node = None
for node in doc.firstChild.childNodes:
- if node.nodeType == ELEMENT_NODE:
+ if node.nodeType == Node.ELEMENT_NODE:
if node.nodeName == 'batch':
batch_node = node#.cloneNode(True)
if batch_node is None:
@@ -500,7 +499,7 @@
total = 0
last = 0
for node in batch_xml.childNodes:
- if node.nodeType == ELEMENT_NODE:
+ if node.nodeType == Node.ELEMENT_NODE:
if node.nodeName == 'module':
total = total + 1
status = node.getAttribute('status')
@@ -549,7 +548,7 @@
c = 0
for node in batch_xml.childNodes:
- if node.nodeType == ELEMENT_NODE:
+ if node.nodeType == Node.ELEMENT_NODE:
if node.nodeName == 'module':
module_xml = node
c = c + 1
@@ -558,17 +557,17 @@
if status == '0' or status == '4':
# module executed, dig deeper into request
for node_i in module_xml.childNodes:
- if node_i.nodeType == ELEMENT_NODE:
+ if node_i.nodeType == Node.ELEMENT_NODE:
if node_i.nodeName == 'API_error':
return -2, 'API error'
elif node_i.nodeName == 'response':
for node_j in node_i.childNodes:
- if node_j.nodeType == ELEMENT_NODE:
+ if node_j.nodeType == Node.ELEMENT_NODE:
if node_j.nodeName == 'function_response':
code = -11111111
msg = 'BUG'
for var in node_j.childNodes:
- if var.nodeType == ELEMENT_NODE:
+ if var.nodeType == Node.ELEMENT_NODE:
if var.nodeName == 'var':
if var.getAttribute('name') == 'success' and var.getAttribute('value') == 'true':
return 0, ''
^ permalink raw reply [flat|nested] 4+ messages in thread* [Cluster-devel] conga/luci cluster/form-macros homebase/homeba ...
@ 2007-07-12 15:44 rmccabe
0 siblings, 0 replies; 4+ messages in thread
From: rmccabe @ 2007-07-12 15:44 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-07-12 15:44:43
Modified files:
luci/cluster : form-macros
luci/homebase : homebase_common.js
luci/site/luci/Extensions: FenceHandler.py LuciClusterInfo.py
PropsObject.py homebase_adapters.py
Log message:
- Cleanups
- Better exception handling and error logging for fence validation
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.202&r2=1.203
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.51&r2=1.52
--- conga/luci/cluster/form-macros 2007/07/12 02:42:42 1.202
+++ conga/luci/cluster/form-macros 2007/07/12 15:44:43 1.203
@@ -3273,7 +3273,7 @@
<div id="fence_selection_block" class="invisible">
<form name="main_fence_form">
- <select name="select_div" onchange="alert('ALERT')">
+ <select name="select_div">
<option value="fence-form-new-device">------ Use an existing Fence Device ------</option>
<tal:block tal:repeat="f fencedevinfo/fencedevs">
<option class="shared_fencedev"
--- conga/luci/homebase/homebase_common.js 2007/07/11 22:47:07 1.18
+++ conga/luci/homebase/homebase_common.js 2007/07/12 15:44:43 1.19
@@ -281,13 +281,13 @@
del_img.className = 'deleteRow';
del_img.onclick = new Function('delete_element_id(\'' + newrow.id + '\')');
- sltab.appendChild(newrow);
dcol.appendChild(del_img);
hcol.appendChild(newsys);
pcol.appendChild(newsysp);
newrow.appendChild(hcol);
newrow.appendChild(pcol);
newrow.appendChild(dcol);
+ sltab.appendChild(newrow);
form.numStorage.value = ++num_systems;
if (num_systems === 2) {
--- conga/luci/site/luci/Extensions/FenceHandler.py 2007/06/25 16:03:38 1.19
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2007/07/12 15:44:43 1.20
@@ -6,6 +6,8 @@
# Free Software Foundation.
from ClusterModel.Device import Device
+from conga_constants import LUCI_DEBUG_MODE
+from LuciSyslog import get_logger
FD_VAL_FAIL = 1
FD_VAL_SUCCESS = 0
@@ -152,6 +154,7 @@
'fence_manual': ['name']
}
+luci_log = get_logger()
def makeNCName(name):
### name must conform to relaxNG ID type ##
@@ -178,6 +181,8 @@
model.setModified(True)
return (FD_VAL_SUCCESS, fencedev.getAttribute('name'))
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VNFD0: %r %s' % (e, str(e)))
ret = [ FD_PROVIDE_AGENT ]
return (FD_VAL_FAIL, ret)
@@ -188,6 +193,8 @@
if not old_fence_name:
raise Exception, 'blank'
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VFD0: %r %s' % (e, str(e)))
return (FD_VAL_FAIL, [ FD_PROVIDE_NAME ])
fencedev = None
@@ -200,6 +207,8 @@
if fencedev is None:
raise Exception, 'fencedev is None'
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VFD1: %r %s' % (e, str(e)))
return (FD_VAL_FAIL, [ FD_PROVIDE_NAME ])
try:
@@ -208,6 +217,8 @@
model.setModified(True)
return (FD_VAL_SUCCESS, fencedev.getAttribute('name'))
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VFD2: %r %s' % (e, str(e)))
ret = [ FD_PROVIDE_NAME ]
return (FD_VAL_FAIL, ret)
@@ -219,6 +230,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -226,6 +238,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -257,8 +270,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_wti_fd(form, fencedev):
@@ -268,6 +279,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -299,7 +311,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
return errors
def val_brocade_fd(form, fencedev):
@@ -309,6 +320,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -316,6 +328,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -347,8 +360,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_vixel_fd(form, fencedev):
@@ -358,6 +369,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -389,7 +401,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
return errors
def val_mcdata_fd(form, fencedev):
@@ -399,6 +410,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -406,6 +418,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -437,8 +450,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_gnbd_fd(form, fencedev):
@@ -448,10 +459,10 @@
server = form['servers'].strip()
if not server:
raise Exception, 'blank'
+ fencedev.addAttribute('servers', server)
except Exception, e:
errors.append(FD_PROVIDE_SERVER)
- fencedev.addAttribute('servers', server)
return errors
def val_egenera_fd(form, fencedev):
@@ -461,10 +472,10 @@
cserver = form['cserver'].strip()
if not cserver:
raise Exception, 'blank'
+ fencedev.addAttribute('cserver', cserver)
except Exception, e:
errors.append(FD_PROVIDE_CSERVER)
- fencedev.addAttribute('cserver', cserver)
return errors
def val_sanbox2_fd(form, fencedev):
@@ -474,6 +485,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -481,6 +493,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -512,8 +525,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_bladecenter_fd(form, fencedev):
@@ -523,6 +534,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -530,6 +542,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -561,8 +574,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_bullpap_fd(form, fencedev):
@@ -572,6 +583,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -579,6 +591,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -610,8 +623,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_noop_fd(dummy, _dummy):
@@ -626,6 +637,7 @@
hostname = form['hostname'].strip()
if not hostname:
raise Exception, 'blank'
+ fencedev.addAttribute('hostname', hostname)
except Exception, e:
errors.append(FD_PROVIDE_HOSTNAME)
@@ -633,6 +645,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -664,8 +677,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('hostname', hostname)
- fencedev.addAttribute('login', log)
return errors
def val_drac_fd(form, fencedev):
@@ -675,6 +686,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -682,6 +694,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -713,8 +726,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_rps10_fd(form, fencedev):
@@ -724,6 +735,7 @@
device = form['device'].strip()
if not device:
raise Exception, 'blank'
+ fencedev.addAttribute('device', device)
except Exception, e:
errors.append(FD_PROVIDE_DEVICE)
@@ -731,11 +743,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fencedev.addAttribute('port', port)
except Exception, e:
errors.append(FD_PROVIDE_PORT)
- fencedev.addAttribute('device', device)
- fencedev.addAttribute('port', port)
return errors
def val_ipmilan_fd(form, fencedev):
@@ -745,6 +756,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -752,6 +764,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -805,8 +818,6 @@
except Exception, e:
fencedev.removeAttribute('lanplus')
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_ilo_fd(form, fencedev):
@@ -816,6 +827,7 @@
hostname = form['hostname'].strip()
if not hostname:
raise Exception, 'blank'
+ fencedev.addAttribute('hostname', hostname)
except Exception, e:
errors.append(FD_PROVIDE_HOSTNAME)
@@ -823,6 +835,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -854,8 +867,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('hostname', hostname)
- fencedev.addAttribute('login', log)
return errors
FD_VALIDATE = {
@@ -919,10 +930,15 @@
if len(ret) < 1 and name_change is True:
try:
model.rectifyNewFencedevicenameWithFences(old_fence_name, fence_name)
- except:
+ except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vfd0: %s %r %s' \
+ % (fence_agent, e, str(e)))
return [ FD_NEW_FAIL % fence_agent ]
return ret
- except:
+ except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vfd1: %s %r %s' % (fence_agent, e, str(e)))
return [ FD_NEW_FAIL % fence_agent ]
# Validation Methods for Fence Instances
@@ -934,6 +950,7 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
@@ -948,7 +965,6 @@
except Exception, e:
errors.append(FI_PROVIDE_SWITCH)
- fenceinst.addAttribute('port', port)
return errors
def val_wti_fi(form, fenceinst):
@@ -958,10 +974,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_brocade_fi(form, fenceinst):
@@ -971,10 +987,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_vixel_fi(form, fenceinst):
@@ -984,10 +1000,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_gnbd_fi(form, fenceinst):
@@ -997,10 +1013,10 @@
ip = form['ipaddress'].strip()
if not ip:
raise Exception, 'blank'
+ fenceinst.addAttribute('ipaddress', ip)
except Exception, e:
errors.append(FI_PROVIDE_IPADDRESS)
- fenceinst.addAttribute('ipaddress', ip)
return errors
def val_sanbox2_fi(form, fenceinst):
@@ -1010,10 +1026,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_bladecenter_fi(form, fenceinst):
@@ -1023,10 +1039,10 @@
blade = form['blade'].strip()
if not blade:
raise Exception, 'blank'
+ fenceinst.addAttribute('blade', blade)
except Exception, e:
errors.append(FI_PROVIDE_BLADE)
- fenceinst.addAttribute('blade', blade)
return errors
def val_mcdata_fi(form, fenceinst):
@@ -1036,10 +1052,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_egenera_fi(form, fenceinst):
@@ -1049,6 +1065,7 @@
lpan = form['lpan'].strip()
if not lpan:
raise Exception, 'blank'
+ fenceinst.addAttribute('lpan', lpan)
except Exception, e:
errors.append(FI_PROVIDE_ELPAN)
@@ -1056,11 +1073,10 @@
pserver = form['pserver'].strip()
if not pserver:
raise Exception, 'blank'
+ fenceinst.addAttribute('pserver', pserver)
except Exception, e:
errors.append(FI_PROVIDE_ELPAN)
- fenceinst.addAttribute('lpan', lpan)
- fenceinst.addAttribute('pserver', pserver)
return errors
def val_bullpap_fi(form, fenceinst):
@@ -1070,10 +1086,10 @@
domain = form['domain'].strip()
if not domain:
raise Exception, 'blank'
+ fenceinst.addAttribute('domain', domain)
except Exception, e:
errors.append(FI_PROVIDE_DOMAIN)
- fenceinst.addAttribute('domain', domain)
return errors
def val_xvm_fi(form, fenceinst):
@@ -1083,10 +1099,10 @@
domain = form['domain'].strip()
if not domain:
raise Exception, 'blank'
+ fenceinst.addAttribute('domain', domain)
except Exception, e:
errors.append(FI_PROVIDE_DOMAIN)
- fenceinst.addAttribute('domain', domain)
return errors
def val_scsi_fi(form, fenceinst):
@@ -1096,10 +1112,10 @@
nodename = form['nodename'].strip()
if not nodename:
raise Exception, 'blank'
+ fenceinst.addAttribute('nodename', nodename)
except Exception, e:
errors.append(FI_PROVIDE_NODENAME)
- fenceinst.addAttribute('nodename', nodename)
return errors
def val_noop_fi(dummy, _dummy):
@@ -1141,6 +1157,8 @@
if len(ret) > 0:
return (FD_VAL_FAIL, ret)
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vfi0: %s: %r %s' % (fence_agent, e, str(e)))
return (FD_VAL_FAIL, [ FI_NEW_FAIL % fence_agent ])
return (FD_VAL_SUCCESS, fenceinst)
--- conga/luci/site/luci/Extensions/LuciClusterInfo.py 2007/07/03 17:05:59 1.5
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py 2007/07/12 15:44:43 1.6
@@ -1525,6 +1525,7 @@
model = ModelBuilder(0, None, None, cluster_conf_node)
if not model:
raise Exception, 'ModelBuilder() returned None'
+ model.setIsVirtualized(isVirtualized)
except Exception, e:
try:
if LUCI_DEBUG_MODE is True:
@@ -1534,7 +1535,6 @@
luci_log.debug_verbose('GMB1: ModelBuilder failed')
return None
- model.setIsVirtualized(isVirtualized)
return model
def getModelForCluster(self, clustername):
@@ -1550,12 +1550,11 @@
model = getModelBuilder(None, rc, rc.dom0())
if not model:
raise Exception, 'model is none'
+ return model
except Exception, e:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('GMFC1: unable to get model builder for %s: %r %s' % (clustername, e, str(e)))
- return None
-
- return model
+ return None
def getClusterOS(self, rc):
from HelperFunctions import resolveOSType
--- conga/luci/site/luci/Extensions/PropsObject.py 2007/07/03 17:05:59 1.4
+++ conga/luci/site/luci/Extensions/PropsObject.py 2007/07/12 15:44:43 1.5
@@ -26,7 +26,7 @@
return self.__vars
def export_xml(self, doc, parent_node):
- props = doc.createElement(str(PROPS_TAG))
+ props = doc.createElement(PROPS_TAG)
parent_node.appendChild(props)
for var in self.__vars:
props.appendChild(self.__vars[var].export_xml(doc))
@@ -36,7 +36,7 @@
props = None
for node in parent_node.childNodes:
if node.nodeType == ELEMENT_NODE:
- if node.nodeName == str(PROPS_TAG):
+ if node.nodeName == PROPS_TAG:
props = node
if props is None:
return self
--- conga/luci/site/luci/Extensions/homebase_adapters.py 2007/06/25 16:03:39 1.51
+++ conga/luci/site/luci/Extensions/homebase_adapters.py 2007/07/12 15:44:43 1.52
@@ -39,7 +39,7 @@
errors = list()
messages = list()
- if '__SYSTEM' in request.form:
+ if request.form.has_key('__SYSTEM'):
system_names = request.form['__SYSTEM']
for i in system_names:
if not i:
@@ -50,7 +50,7 @@
else:
messages.append('Removed storage system "%s" successfully' % i)
- if '__CLUSTER' in request.form:
+ if request.form.has_key('__CLUSTER'):
cluster_names = request.form['__CLUSTER']
for i in cluster_names:
if not i:
@@ -70,9 +70,8 @@
if not request.form.has_key('deluserId'):
return (False, { 'errors': [ 'No User ID given' ] })
- userId = request.form['deluserId']
-
try:
+ userId = request.form['deluserId'].strip()
user = self.portal_membership.getMemberById(userId)
if not user:
raise Exception, 'user %s does not exist' % userId
@@ -117,8 +116,10 @@
if not request.form.has_key('newUserName'):
return (False, { 'errors': [ 'No user name given' ] })
+
if not request.form.has_key('newPassword'):
return (False, { 'errors': [ 'No password given' ] })
+
if not request.form.has_key('newPasswordConfirm'):
return (False, { 'errors': [ 'You didn\'t confirm the password' ] })
@@ -133,12 +134,21 @@
if passwd != pwconfirm:
return (False, { 'errors': [ 'The passwords given do not match' ]})
+ user_props = {
+ 'username': user,
+ 'password': passwd,
+ 'confirm': passwd,
+ 'roles': [ 'Member' ],
+ 'domains': [],
+ 'email': '%s at conga.example.com' % user
+ }
+
try:
- self.portal_registration.addMember(user, passwd, properties = { 'username': user, 'password': passwd, 'confirm': passwd, 'roles': [ 'Member' ], 'domains': [], 'email': '%s at conga.example.com' % user })
+ self.portal_registration.addMember(user, passwd, properties=user_props)
except Exception, e:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('VAU0: %s: %r %s' % (user, e, str(e)))
- return (False, { 'errors': [ 'Unable to add new user "%s"' % user ] })
+ return (False, { 'errors': [ 'Unable to add new user "%s": %s ' % (user, str(e)) ] })
if not self.portal_membership.getMemberById(user):
return (False, { 'errors': [ 'Unable to add new user "%s"' % user ] })
@@ -542,11 +552,13 @@
except:
pass_num = 1
- add_cluster = { 'name': cluster_name,
- 'pass': pass_num,
- 'cluster_os': cluster_os,
- 'identical_passwds': same_node_passwds,
- 'check_certs': check_certs }
+ add_cluster = {
+ 'name': cluster_name,
+ 'pass': pass_num,
+ 'cluster_os': cluster_os,
+ 'identical_passwds': same_node_passwds,
+ 'check_certs': check_certs
+ }
system_list, incomplete, new_errors, messages = parseHostForm(request, check_certs)
errors.extend(new_errors)
^ permalink raw reply [flat|nested] 4+ messages in thread* [Cluster-devel] conga/luci cluster/form-macros homebase/homeba ...
@ 2006-08-16 19:08 rmccabe
0 siblings, 0 replies; 4+ messages in thread
From: rmccabe @ 2006-08-16 19:08 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-08-16 19:08:36
Modified files:
luci/cluster : form-macros
luci/homebase : homebase_common.js
Log message:
more cluster properties config form bits, and cleanups for homebase
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.2&r2=1.3
--- conga/luci/cluster/form-macros 2006/08/15 22:27:05 1.44
+++ conga/luci/cluster/form-macros 2006/08/16 19:08:35 1.45
@@ -398,6 +398,27 @@
</div>
<div id="configTabContent" tal:condition="python: configTabNum == 3">
+ <script type="text/javascript">
+ var prev_mcast_str = '';
+
+ function disable_mcast(addrId) {
+ addrObj = document.getElementById(addrId);
+ if (!addrObj || addrObj.disabled)
+ return;
+ addrObj.disabled = true;
+ prev_mcast_str = addrObj.value;
+ addrObj.value = '';
+ }
+
+ function enable_mcast(addrId) {
+ addrObj = document.getElementById(addrId);
+ if (!addrObj || !addrObj.disabled)
+ return;
+ addrObj.disabled = false;
+ addrObj.value = prev_mcast_str;
+ }
+ </script>
+
<form name="multicast" action="" method="get" tal:attributes="action clusterinfo/multicast_url">
<table id="systemsTable" class="systemsTable" border="0" cellspacing="0">
<thead class="systemsTable">
@@ -412,7 +433,7 @@
<tr class="systemsTable">
<td class="systemsTable">
<input type="radio" name="mcast" value="False"
- onchecked="javascript:document.getElementById('mcast_address').disabled=true;"
+ onClick="disable_mcast('mcast_address');"
tal:attributes="checked python:clusterinfo['is_mcast'] != 'True'"
/>
Let cluster choose the multicast address
@@ -422,7 +443,7 @@
<tr class="systemsTable">
<td class="systemsTable">
<input type="radio" name="mcast" value="True"
- onchecked="javascript:document.getElementById('mcast_address').disabled=false;"
+ onClick="enable_mcast('mcast_address');"
tal:attributes="checked python:clusterinfo['is_mcast'] == 'True'"
/>
@@ -435,7 +456,7 @@
<input type="text" name="mcast_address" id="mcast_address"
tal:attributes="
disabled python: clusterinfo['is_mcast'] != 'True' and '1' or '0';
- value clusterinfo/mcast_addr"
+ value python: clusterinfo['is_mcast'] == 'True' and clusterinfo['mcast_addr'] or '';"
/>
</td>
</tr>
@@ -454,6 +475,120 @@
<div id="configTabContent" tal:condition="python: configTabNum == 4">
<form name="quorum_partition" action="" method="get" tal:attributes="action clusterinfo/quorumd_url">
+ <script type="text/javascript">
+ oldInput = null;
+
+ function addHeuristic(parent_name) {
+ parent = document.getElementById(parent_name);
+ if (!parent)
+ return;
+ hnum = document.getElementById('num_heuristics');
+ if (!hnum)
+ return;
+
+ var cur_hnum = Number(hnum.value) + 1;
+ if (cur_hnum >= 10) {
+ alert('There is a maximum of 10 heuristics.');
+ return;
+ }
+ hstr = 'heuristic' + cur_hnum + ':';
+
+ name_td = document.createElement('td');
+ name_td.className = 'systemsTable';
+ name_input = document.createElement('input');
+ name_input.className = 'qdname qdisk';
+ name_input.setAttribute('name', hstr + 'hname');
+ name_input.setAttribute('id', hstr + 'hname');
+ name_input.setAttribute('type', 'text');
+ name_td.appendChild(name_input);
+
+ path_td = document.createElement('td');
+ path_td.className = 'systemsTable';
+ path_input = document.createElement('input');
+ path_input.className = 'qdpath qdisk';
+ path_input.setAttribute('name', hstr + 'hprog');
+ path_input.setAttribute('id', hstr + 'hprog');
+ path_input.setAttribute('type', 'text');
+ path_td.appendChild(path_input);
+
+ interval_td = document.createElement('td');
+ interval_td.className = 'systemsTable';
+ interval_input = document.createElement('input');
+ interval_input.className = 'qdint qdisk';
+ interval_input.setAttribute('name', hstr + 'hinterval');
+ interval_input.setAttribute('id', hstr + 'hinterval');
+ interval_input.setAttribute('type', 'text');
+ interval_td.appendChild(interval_input);
+
+ score_td = document.createElement('td');
+ score_td.className = 'systemsTable';
+ score_input = document.createElement('input');
+ score_input.className = 'qdscore qdisk';
+ score_input.setAttribute('name', hstr + 'hscore');
+ score_input.setAttribute('id', hstr + 'hscore');
+ score_input.setAttribute('type', 'input');
+ score_td.appendChild(score_input);
+
+ tr = document.createElement('tr');
+ tr.className = 'systemsTable';
+ tr.appendChild(name_td);
+ tr.appendChild(path_td);
+ tr.appendChild(interval_td);
+ tr.appendChild(score_td);
+ parent.appendChild(tr);
+ hnum.value++;
+ }
+
+ function disableChildrenInput(parent_name) {
+ parent = document.getElementById(parent_name);
+ if (!parent)
+ return;
+
+ inputElem = parent.getElementsByTagName('input');
+ if (!inputElem || inputElem.length < 1) {
+ oldInput = null;
+ return;
+ }
+ if (inputElem[0].disabled)
+ return;
+ oldInput = new Array(inputElem.length);
+ for (var i = 0 ; i < inputElem.length ; i++) {
+ e = inputElem[i];
+
+ e.disabled = true;
+ if (e.type == 'button')
+ continue;
+ oldInput[e.name] = e.value;
+ e.value = '';
+ }
+ }
+
+ function enableChildrenInput(parent_name) {
+ parent = document.getElementById(parent_name);
+ if (!parent)
+ return;
+
+ inputElem = parent.getElementsByTagName('input');
+ if (!inputElem || inputElem.length < 1) {
+ return;
+ }
+
+ if (!inputElem[0].disabled)
+ return;
+
+ for (var i = 0 ; i < inputElem.length ; i++) {
+ e = inputElem[i];
+ e.disabled = false;
+ if (e.type == 'button')
+ continue;
+ if (oldInput && oldInput[e.name])
+ e.value = oldInput[e.name];
+ else
+ e.value = '';
+ }
+ oldInput = null;
+ }
+ </script>
<div class="configTabContent">
<table id="systemsTable" class="systemsTable" border="0" cellspacing="0">
<thead class="systemsTable">
@@ -465,13 +600,17 @@
</thead>
<tbody class="systemsTable">
- <tr class="systemsTable"><td class="systemsTable">
- <input type="radio" name="quorumd" value="False" checked="" tal:attributes="checked python:clusterinfo['is_quorumd'] != 'True'"/>
+ <tr class="systemsTable" id="st_row"><td class="systemsTable" id="st_col">
+ <input type="radio" name="quorumd" value="False"
+ onClick="disableChildrenInput('quorumdisk');"
+ tal:attributes="checked python:clusterinfo['is_quorumd'] != 'True'"/>
Do not use a Quorum Partition
</td></tr>
<tr class="systemsTable"><td class="systemsTable">
- <input type="radio" name="quorumd" value="True"/>
+ <input type="radio" name="quorumd" value="True"
+ onClick="enableChildrenInput('quorumdisk');"
+ tal:attributes="checked python:clusterinfo['is_quorumd'] == 'True'"/>
Use a Quorum Partition
</td></tr>
</tbody>
@@ -558,7 +697,7 @@
</tr>
</thead>
- <tbody class="systemsTable"
+ <tbody class="systemsTable" id='heuristicList'
tal:define="global heuristics clusterinfo/hlist">
<tal:block tal:condition="python: not len(heuristics)">
@@ -619,7 +758,7 @@
</tbody>
<tfoot>
<tr class="systemsTable"><td class="systemsTable">
- <input class="addrow" type="button" value="Add another heuristic">
+ <input class="addrow" type="button" value="Add another heuristic" onClick="addHeuristic('heuristicList');">
</td></tr>
</tfoot>
</table>
@@ -630,6 +769,9 @@
<div class="hbSubmit spacing configTabContent">
<input class="hbSubmit" type="submit" value="Apply">
</div>
+ <script tal:condition="python:clusterinfo['is_quorumd'] != 'True'">
+ disableChildrenInput('quorumdisk');
+ </script>
</form>
</div>
</div>
--- conga/luci/homebase/homebase_common.js 2006/07/18 19:25:20 1.2
+++ conga/luci/homebase/homebase_common.js 2006/08/16 19:08:36 1.3
@@ -114,14 +114,14 @@
var num_systems = form.numStorage.value;
var newsys = document.createElement('input');
- newsys.setAttribute('style', 'padding:.20em !important;width:200px;');
+ newsys.className = 'hbInputSys';
newsys.setAttribute('name', '__SYSTEM' + num_systems + ':Addr');
newsys.setAttribute('id', '__SYSTEM' + num_systems + ':Addr');
newsys.setAttribute('type', 'text');
newsys.setAttribute('value', '');
var newsysp = document.createElement('input');
- newsysp.setAttribute('style', 'padding:.20em !important;width:160px;');
+ newsysp.className = 'hbInputPass';
newsysp.setAttribute('name', '__SYSTEM' + num_systems + ':Passwd');
newsysp.setAttribute('id', '__SYSTEM' + num_systems + ':Passwd');
newsysp.setAttribute('type', 'password');
@@ -134,10 +134,11 @@
}
var newrow = document.createElement('tr');
+ newrow.className = 'systemsTable';
var hcol = document.createElement('td')
- hcol.setAttribute('style', 'margin: 0em;padding: 0em 1em .33em 0em;background: #dee7ec;padding-left: .5em;text-align: left;');
+ hcol.className = 'systemsTable';
var pcol = document.createElement('td')
- pcol.setAttribute('style', 'margin: 0em;padding: 0em 1em .33em 0em;background: #dee7ec;padding-left: .5em;text-align: left;');
+ pcol.className = 'systemsTable';
hcol.appendChild(newsys)
pcol.appendChild(newsysp)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-12 22:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-17 16:22 [Cluster-devel] conga/luci cluster/form-macros homebase/homeba rmccabe
-- strict thread matches above, loose matches on Subject: below --
2007-07-12 22:35 rmccabe
2007-07-12 15:44 rmccabe
2006-08-16 19:08 rmccabe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).