[luci] luci: Fix the interaction of the force_unmount and nfsrestart checkboxes
by Ryan McCabe
commit 64280cdd482da07eaa2d43b9950eb76ca721c935
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Thu Nov 29 15:40:55 2012 -0500
luci: Fix the interaction of the force_unmount and nfsrestart checkboxes
Fix the interaction of the force_unmount and nfsrestart checkboxes
on the service creation and edit forms.
Resolves: rhbz#822502
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
luci/public/js/resource.js | 30 ++++++++++++++++++++++--------
luci/public/js/service.js | 9 +++++++++
luci/templates/resource_list.html | 12 ++++++------
3 files changed, 37 insertions(+), 14 deletions(-)
---
diff --git a/luci/public/js/resource.js b/luci/public/js/resource.js
index a839875..00bf5ff 100644
--- a/luci/public/js/resource.js
+++ b/luci/public/js/resource.js
@@ -16,19 +16,33 @@ $(function() {
function swap_resource_form(resource_form_id) {
var form_jelem = $(document.getElementById(resource_form_id));
$('#resource_form_area').empty();
- form_jelem.clone().appendTo('#resource_form_area');
+ var form_clone = form_jelem.clone();
+ var cur_force_unmount = $('input[name="force_unmount"]', form_clone);
+ if ($(cur_force_unmount).length) {
+ $(cur_force_unmount).attr('id', 'force_unmount_global');
+ var cur_nfsrestart = $('input[name="nfsrestart"]', form_clone);
+ if ($(cur_nfsrestart).length) {
+ $(cur_nfsrestart).attr('id', 'nfsrestart_global');
+ }
+ }
+ $(form_clone).appendTo('#resource_form_area');
}
-function forceunmount_update(form) {
- var nfsrestart_cb = form.nfsrestart;
- if (!nfsrestart_cb) {
+function forceunmount_update(res_id) {
+ var force_unmount = document.getElementById(res_id);
+ if (!force_unmount) {
+ return;
+ }
+
+ var nfsr_cb = document.getElementById(res_id.replace("force_unmount", "nfsrestart"));
+ if (!nfsr_cb) {
return;
}
- if (form.force_unmount.checked) {
- nfsrestart_cb.disabled = false;
+ if (force_unmount.checked) {
+ nfsr_cb.disabled = false;
} else {
- nfsrestart_cb.checked = false;
- nfsrestart_cb.disabled = true;
+ nfsr_cb.checked = false;
+ nfsr_cb.disabled = true;
}
}
diff --git a/luci/public/js/service.js b/luci/public/js/service.js
index 8331fdb..e7da75d 100644
--- a/luci/public/js/service.js
+++ b/luci/public/js/service.js
@@ -170,6 +170,15 @@ function insert_resource(res_id, container_id, form, parent_id) {
var cur_resid_elem = $('input[name="form_id"]', form_jelem);
$(cur_resid_elem).val(cur_id_str);
+ var cur_force_unmount = $('input[name="force_unmount"]', form_jelem);
+ if ($(cur_force_unmount).length) {
+ $(cur_force_unmount).attr('id', 'force_unmount_' + cur_id_str);
+ var cur_nfsrestart = $('input[name="nfsrestart"]', form_jelem);
+ if ($(cur_nfsrestart).length) {
+ $(cur_nfsrestart).attr('id', 'nfsrestart_' + cur_id_str);
+ }
+ }
+
var parent_resid_elem = $('input[name="parent_id"]', form_jelem);
$(parent_resid_elem).val(parent_id);
diff --git a/luci/templates/resource_list.html b/luci/templates/resource_list.html
index d914922..1d2f5c6 100644
--- a/luci/templates/resource_list.html
+++ b/luci/templates/resource_list.html
@@ -201,8 +201,8 @@
<td>Force Unmount</td>
<td>
<input type="checkbox" class="checkbox" name="force_unmount"
- onchange="forceunmount_update(this.form)"
- py:attrs="{'checked':(res and res.getBinaryAttribute('force_unmount')) and 'checked' or None, 'disabled':global_resource and 'disabled' or None}" />
+ onchange="forceunmount_update(this.getAttribute('id'))"
+ py:attrs="{'id': defined('cur_id_str') and 'force_unmount_' + cur_id_str or (res and 'force_unmount_' + res.getAttribute('name') or None), 'checked':(res and res.getBinaryAttribute('force_unmount')) and 'checked' or None, 'disabled':global_resource and 'disabled' or None}" />
</td>
</tr>
<tr>
@@ -216,7 +216,7 @@
<td>Enable NFS daemon and lockd workaround</td>
<td>
<input type="checkbox" class="checkbox" name="nfsrestart"
- py:attrs="{'checked':(res and res.getBinaryAttribute('nfsrestart')) and 'checked' or None, 'disabled':(global_resource or not res or not res.getBinaryAttribute('force_unmount')) and 'disabled' or None}" />
+ py:attrs="{'id': defined('cur_id_str') and 'nfsrestart_' + cur_id_str or (res and 'nfsrestart_' + res.getAttribute('name') or None),'checked':(res and res.getBinaryAttribute('nfsrestart')) and 'checked' or None, 'disabled':(global_resource or not res or not res.getBinaryAttribute('force_unmount')) and 'disabled' or None}" />
</td>
</tr>
<tr>
@@ -317,15 +317,15 @@
<td>Force Unmount</td>
<td>
<input type="checkbox" class="checkbox" name="force_unmount"
- onchange="forceunmount_update(this.form)"
- py:attrs="{'checked':(res and res.getBinaryAttribute('force_unmount')) and 'checked' or None, 'disabled':global_resource and 'disabled' or None}" />
+ onchange="forceunmount_update(this.getAttribute('id'))"
+ py:attrs="{'id': defined('cur_id_str') and 'force_unmount_' + cur_id_str or (res and 'force_unmount_' + res.getAttribute('name') or None), 'checked':(res and res.getBinaryAttribute('force_unmount')) and 'checked' or None, 'disabled':global_resource and 'disabled' or None}" />
</td>
</tr>
<tr>
<td>Enable NFS daemon and lockd workaround</td>
<td>
<input type="checkbox" class="checkbox" name="nfsrestart"
- py:attrs="{'checked':(res and res.getBinaryAttribute('nfsrestart')) and 'checked' or None, 'disabled':(global_resource or not res or not res.getBinaryAttribute('force_unmount')) and 'disabled' or None}" />
+ py:attrs="{'id': defined('cur_id_str') and 'nfsrestart_' + cur_id_str or (res and 'nfsrestart_' + res.getAttribute('name') or None),'checked':(res and res.getBinaryAttribute('nfsrestart')) and 'checked' or None, 'disabled':(global_resource or not res or not res.getBinaryAttribute('force_unmount')) and 'disabled' or None}" />
</td>
</tr>
<tr>
11 years, 6 months
[luci] luci: Audit of resource agent checkbox input
by Ryan McCabe
commit dbf80eeb659641c0f254456ef7ac830038e5f589
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Thu Nov 29 15:33:24 2012 -0500
luci: Audit of resource agent checkbox input
Always write '1' instead of 'on' for enabled checkboxes. The resource
agents are inconsistent in what values they accept for true and false
inputs. All accept 1/0, though, so be consistent in using that.
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
luci/validation/validate_resource.py | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/luci/validation/validate_resource.py b/luci/validation/validate_resource.py
index 413112e..20ecdb9 100644
--- a/luci/validation/validate_resource.py
+++ b/luci/validation/validate_resource.py
@@ -116,9 +116,17 @@ def addIp(res, rname, model, **kw):
kw['monitor_link'] = '0'
else:
kw['monitor_link'] = '1'
+
+ if not kw.has_key('disable_rdisc'):
+ kw['disable_rdisc'] = '0'
+ else:
+ kw['disable_rdisc'] = '1'
+
errors = config_resource(params, res, rname, **kw)
if res.getBinaryAttribute('monitor_link') is True:
res.removeAttribute('monitor_link')
+ if not res.getBinaryAttribute('disable_rdisc'):
+ res.removeAttribute('disable_rdisc')
return errors
def addFs(res, rname, model, **kw):
@@ -145,6 +153,10 @@ def addFs(res, rname, model, **kw):
if (res.getBinaryAttribute('nfsrestart')
and not res.getBinaryAttribute('force_unmount')):
errors.append(_('nfsrestart requires force_unmount to be enabled'))
+
+ for a in ('force_unmount', 'quick_status', 'self_fence', 'force_fsck', 'nfsrestart'):
+ if res.getAttribute(a) == 'on':
+ res.addAttribute(a, '1')
return errors
def addClusterfs(res, rname, model, **kw):
@@ -169,6 +181,9 @@ def addClusterfs(res, rname, model, **kw):
if (res.getBinaryAttribute('nfsrestart')
and not res.getBinaryAttribute('force_unmount')):
errors.append(_('nfsrestart requires force_unmount to be enabled'))
+ for a in ('force_unmount', 'self_fence', 'nfsrestart'):
+ if res.getAttribute(a) == 'on':
+ res.addAttribute(a, '1')
return errors
def addNetfs(res, rname, model, **kw):
@@ -183,6 +198,10 @@ def addNetfs(res, rname, model, **kw):
)
errors = config_resource(params, res, rname, **kw)
+ for a in ('force_unmount', 'no_unmount'):
+ if res.getAttribute(a) == 'on':
+ res.addAttribute(a, '1')
+ return errors
return errors
def addVM(res, rname, model, **kw):
@@ -225,6 +244,10 @@ def addNFSClient(res, rname, model, **kw):
res.addAttribute('path', path_override)
else:
res.removeAttribute('path')
+
+ allow_recover = res.getAttribute('allow_recover')
+ if allow_recover == 'on':
+ res.addAttribute('allow_recover', '1')
return errors
def addNFSExport(res, rname, model, **kw):
@@ -377,6 +400,9 @@ def addSAPDatabase(res, rname, model, **kw):
res.addAttribute('DBTYPE', 'ORA')
if not dbtype.upper() in ( 'ORA', 'DB6', 'ADA' ):
errors.append(_('Invalid database type: %s') % dbtype)
+ for a in ('DBJ2EE_ONLY', 'STRICT_MONITORING', 'AUTOMATIC_RECOVER'):
+ if res.getAttribute(a) == 'on':
+ res.addAttribute(a, '1')
return errors
def addSAPInstance(res, rname, model, **kw):
@@ -395,6 +421,8 @@ def addSAPInstance(res, rname, model, **kw):
errors = config_resource(params, res, rname, **kw)
res.removeAttribute('name')
res.addAttribute('InstanceName', rname)
+ if res.getAttribute('AUTOMATIC_RECOVER') == 'on':
+ res.addAttribute('AUTOMATIC_RECOVER', '1')
return errors
def addSybaseASE(res, rname, model, **kw):
11 years, 6 months
[luci] luci: additional fix for templates vs. unicode
by Jan Pokorný
commit fa25174761def14c75d0ce4b5843e29f61d2aa54
Author: Jan Pokorny <jpokorny(a)redhat.com>
Date: Thu Nov 29 14:15:07 2012 +0100
luci: additional fix for templates vs. unicode
Resolves: rhbz#807344
Signed-off-by: Jan Pokorny <jpokorny(a)redhat.com>
luci/controllers/cluster.py | 17 +++++++++++++++--
luci/lib/helpers.py | 10 ++++++++++
luci/templates/failover.html | 6 +++---
luci/templates/fence.html | 8 ++++++--
luci/templates/resource.html | 4 ++--
luci/templates/service.html | 2 +-
6 files changed, 37 insertions(+), 10 deletions(-)
---
diff --git a/luci/controllers/cluster.py b/luci/controllers/cluster.py
index af6b1cb..48d0837 100644
--- a/luci/controllers/cluster.py
+++ b/luci/controllers/cluster.py
@@ -13,7 +13,7 @@ from tg import request, expose, redirect, flash, app_globals, tmpl_context, requ
# third party imports
from repoze.what.predicates import not_anonymous, in_any_group, is_user, Any, NotAuthorizedError
-from luci.lib.helpers import ugettext as _
+from luci.lib.helpers import quote_plus, ugettext as _
# project specific imports
from luci.lib.base import BaseController
@@ -28,7 +28,7 @@ from luci.validation.validate_resource import validate_clusvc_form, validate_res
from luci.lib.ClusterConf.Method import Method
from luci.lib.ClusterConf.Unfence import Unfence
from luci.validation.validate_fence import validate_fenceinstance
-from urllib import unquote_plus, quote_plus
+from urllib import unquote_plus
import logging
log = logging.getLogger(__name__)
@@ -641,6 +641,10 @@ class IndividualClusterController(BaseController):
if 'name' in request.params:
servicename = request.params['name']
+ self.get_model()
+ if not self.model.getService(servicename):
+ servicename = None
+
return dict(page='nodes', name=servicename, base_url=base_url, services_cmd=services_cmd)
@expose("luci.templates.service")
@@ -809,6 +813,10 @@ class IndividualClusterController(BaseController):
if 'name' in request.params:
failovername = request.params['name']
+ self.get_model()
+ if not self.model.getFailoverDomainByName(failovername):
+ failovername = None
+
return dict(page='nodes', name=failovername, base_url = '/cluster/' + self.name + '/failovers', failovers_cmd=failovers_cmd)
@expose("luci.templates.failover")
@@ -924,6 +932,11 @@ class IndividualClusterController(BaseController):
fencename = args[0]
else:
fencename = None
+
+ self.get_model()
+ if not self.model.getFenceDeviceByName(fencename):
+ fencename = None
+
return dict(page='nodes', name=fencename, base_url='/cluster/' + self.name + '/fences', fences_cmd=fences_cmd)
@expose("luci.templates.fence")
diff --git a/luci/lib/helpers.py b/luci/lib/helpers.py
index 4b9bf35..93ca3c5 100644
--- a/luci/lib/helpers.py
+++ b/luci/lib/helpers.py
@@ -12,6 +12,8 @@ __all__ = ['singleton',
'relativeUrlSlashPrefix', 'relativeUrlList2Str']
from pylons.i18n import ugettext, lazy_ugettext
+from urllib import quote_plus as quote_plus_impl
+
def singleton(cls):
"""Trivial class decorator that replace the class with an instance of it."""
@@ -48,3 +50,11 @@ def relativeUrlList2Str(*url_parts):
"""
return relativeUrlSlashPrefix(u'/'.join(url_parts))
+
+
+#-------------------------------------------------------------------------------
+# Functions related to HTML entities un/quoting.
+
+def quote_plus(s):
+ """urllib's quote_plus, but works with unicode as well."""
+ return quote_plus_impl(s.encode('UTF-8') if isinstance(s, unicode) else s)
diff --git a/luci/templates/failover.html b/luci/templates/failover.html
index 297a7f8..8a40dc8 100644
--- a/luci/templates/failover.html
+++ b/luci/templates/failover.html
@@ -7,7 +7,7 @@
<xi:include href="master.html" />
<?python
- from urllib import quote_plus
+ from luci.lib.helpers import quote_plus
?>
<head>
@@ -114,7 +114,7 @@
<div id="details_header">
<h3 py:content="name">Failover Domain name</h3>
<div id="details_header_buttons">
- <a href="${tg.url(failovers_cmd + '?command=Delete' + '&name=' + name)}" id="dh_delete" title="delete"><span class="hide">Delete</span></a>
+ <a href="${tg.url(failovers_cmd + '?command=Delete' + '&name=' + quote_plus(name))}" id="dh_delete" title="delete"><span class="hide">Delete</span></a>
</div>
</div>
@@ -123,7 +123,7 @@
<div class="details_inner">
<form action="${tg.url(failovers_cmd + '?command=update_properties')}" method="post">
<input py:if="expertMode" type="hidden" name="expert_mode" value="1"/>
- <input type="hidden" name="name" value="${name}"/>
+ <input type="hidden" name="name" value="${quote_plus(name)}"/>
<input type="submit" value="Update Properties" class="float_button"/>
<table id="fdom_tattr">
<tr>
diff --git a/luci/templates/fence.html b/luci/templates/fence.html
index a97bf3e..cd2bd23 100644
--- a/luci/templates/fence.html
+++ b/luci/templates/fence.html
@@ -6,6 +6,10 @@
<xi:include href="master.html" />
+<?python
+ from luci.lib.helpers import quote_plus
+?>
+
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
<title>${title()}</title>
@@ -50,7 +54,7 @@
onclick="update_multi_action(this)" class="MultiActionItem"/>
</td>
<!--! If the fence is shared, display appropriate icon. -->
- <td class="main_id"><a href="${tg.url(base_url + '/' + entity_name)}">${entity_name}</a></td>
+ <td class="main_id"><a href="${tg.url(base_url + '/' + quote_plus(entity_name))}">${entity_name}</a></td>
<td class="fence_tlist_type">${fence_data.getPrettyName()}</td>
<!--! Branch according to whether the fence is local or shared. -->
<py:choose test="local_fence">
@@ -119,7 +123,7 @@
<div id="details_header">
<h3 py:content="name">Fence A</h3>
<div id="details_header_buttons">
- <a href="${tg.url(fences_cmd + '?command=Delete' + '&name=' + name)}" id="dh_delete" title="delete"><span class="hide">delete</span></a>
+ <a href="${tg.url(fences_cmd + '?command=Delete' + '&name=' + quote_plus(name))}" id="dh_delete" title="delete"><span class="hide">delete</span></a>
</div>
<span class="details_header_info_label">Type</span> <span class="details_header_info">${details.getPrettyName()}</span>
</div>
diff --git a/luci/templates/resource.html b/luci/templates/resource.html
index d91e09c..1b47c6f 100644
--- a/luci/templates/resource.html
+++ b/luci/templates/resource.html
@@ -7,7 +7,7 @@
<xi:include href="master.html" />
<?python
- from urllib import quote_plus
+ from luci.lib.helpers import quote_plus
?>
<head>
@@ -116,7 +116,7 @@
<div id="details_header">
<h3 py:content="name"/>
<div id="details_header_buttons">
- <a href="${tg.url(resources_cmd + '?command=Delete' + '&name=' + name)}" id="dh_delete" title="delete"><span class="hide">delete</span></a>
+ <a href="${tg.url(resources_cmd + '?command=Delete' + '&name=' + quote_plus(name))}" id="dh_delete" title="delete"><span class="hide">delete</span></a>
</div>
</div>
diff --git a/luci/templates/service.html b/luci/templates/service.html
index 93a3995..1df82af 100644
--- a/luci/templates/service.html
+++ b/luci/templates/service.html
@@ -7,7 +7,7 @@
<xi:include href="master.html" />
<?python
- from urllib import quote_plus
+ from luci.lib.helpers import quote_plus
?>
<head>
11 years, 6 months
[luci] luci: Fix garbled error messages
by Ryan McCabe
commit 6dd7d119b3ad4fdb55f537044da32a8d37ea3003
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Wed Nov 28 13:56:14 2012 -0500
luci: Fix garbled error messages
Fix failover domain related error messages that were returned as
strings instead of lists, causing the error messages to be garbled.
Resolves: rhbz#880363
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
luci/validation/validate_cluster_prop.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/luci/validation/validate_cluster_prop.py b/luci/validation/validate_cluster_prop.py
index 62d0a9d..9fedfb1 100644
--- a/luci/validation/validate_cluster_prop.py
+++ b/luci/validation/validate_cluster_prop.py
@@ -37,10 +37,10 @@ def validate_fdom_prop_form(model, **kw):
fdom_name = kw.get('name')
if not fdom_name or fdom_name.isspace():
- return (False, {'errors': _('No failover domain name was given')})
+ return (False, {'errors': [_('No failover domain name was given')]})
fdom = model.getFailoverDomainByName(fdom_name)
if not fdom:
- return (False, {'errors': _('No failover domain named "%s" exists') % fdom_name})
+ return (False, {'errors': [_('No failover domain named "%s" exists') % fdom_name]})
fdom.setOrdered(kw.get('ordered') is not None)
fdom.setRestricted(kw.get('restricted') is not None)
@@ -89,10 +89,10 @@ def validate_fdom_prop_settings_form(model, **kw):
fdom_name = kw.get('name')
if not fdom_name or fdom_name.isspace():
- return (False, {'errors': _('No failover domain name was given')})
+ return (False, {'errors': [_('No failover domain name was given')]})
fdom = model.getFailoverDomainByName(fdom_name)
if not fdom:
- return (False, {'errors': _('No failover domain named "%s" exists') % fdom_name})
+ return (False, {'errors': [_('No failover domain named "%s" exists') % fdom_name]})
restricted = fdom.getRestricted()
ordered = fdom.getOrdered()
11 years, 6 months
[luci] luci: Add missing JS include
by Ryan McCabe
commit d5b752675d63d4a75cfb6cfc4173309a404f6074
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Wed Nov 28 12:59:15 2012 -0500
luci: Add missing JS include
Add a missing javascript include to the services page that caused
changing the state of the "force unmount" checkbox to not update the
state of the nfsrestart checkbox.
Resolves: rhbz#822502
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
luci/templates/service.html | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/luci/templates/service.html b/luci/templates/service.html
index ef76bea..93a3995 100644
--- a/luci/templates/service.html
+++ b/luci/templates/service.html
@@ -20,6 +20,7 @@
cluster_status = tmpl_context.cluster.get_status()">
<script type="text/javascript" src="/js/encoder.js"></script>
<script type="text/javascript" src="/js/service.js"></script>
+ <script type="text/javascript" src="/js/resource.js"></script>
<xi:include href="resource_list.html" />
${resource_container(cluster_data)}
11 years, 6 months
[luci] luci: Fix value for LVM self_fence
by Ryan McCabe
commit 26488ac435c8ca5eadf4db4b7fdac21a6b6f3eb0
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Fri Nov 16 09:28:47 2012 -0500
luci: Fix value for LVM self_fence
The LVM resource agent does not accept on/off, only yes/no and 1/0
as values for its self_fence attribute. Write 1 instead of on.
Resolves: rhbz#877392
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
luci/validation/validate_resource.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/luci/validation/validate_resource.py b/luci/validation/validate_resource.py
index 25e02cf..413112e 100644
--- a/luci/validation/validate_resource.py
+++ b/luci/validation/validate_resource.py
@@ -345,6 +345,9 @@ def addLVM(res, rname, model, **kw):
('self_fence', '', False, None)
)
errors = config_resource(params, res, rname, **kw)
+ self_fence = res.getAttribute('self_fence')
+ if self_fence == 'on':
+ res.addAttribute('self_fence', '1')
return errors
def addSAPDatabase(res, rname, model, **kw):
11 years, 6 months
[luci] luci: Fix handling of subtree options
by Ryan McCabe
commit 616e70d2a760175bd27262766efb85e63ea980fd
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Thu Nov 15 11:08:48 2012 -0500
luci: Fix handling of subtree options
For subtrees, error out if __max_failures is set by __failure_expire_time
is not, and vice versa. Also error out if __max_restarts is set but
__restart_expire_time is not, and vice versa.
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
luci/validation/validate_resource.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/luci/validation/validate_resource.py b/luci/validation/validate_resource.py
index 674f420..25e02cf 100644
--- a/luci/validation/validate_resource.py
+++ b/luci/validation/validate_resource.py
@@ -824,6 +824,7 @@ def validate_clusvc_form(model, **kw):
except:
errors.append(_('Invalid value for max restarts for %s: %s') % (cur_res_name, max_restarts))
else:
+ max_restarts = None
resObj.delResMaxRestarts()
resObj.delResRestartExpireTime()
@@ -834,8 +835,14 @@ def validate_clusvc_form(model, **kw):
except:
errors.append(_('Invalid value for restart expire time for %s: %s') % (cur_res_name, restart_expire_time))
else:
+ restart_expire_time = None
resObj.delResRestartExpireTime()
+ if max_restarts and not restart_expire_time:
+ errors.append(_('Restart expire time must be set if maximum restarts is set for resource \"%s\" subtree') % dummy_form['resourcename'])
+ if not max_restarts and restart_expire_time:
+ errors.append(_('Maximum restarts must be set if restart expire time is set for resource \"%s\" subtree') % dummy_form['resourcename'])
+
max_failures = dummy_form.get('__max_failures')
if max_failures and not max_failures.isspace():
try:
@@ -843,6 +850,7 @@ def validate_clusvc_form(model, **kw):
except:
errors.append(_('Invalid value for max failures for %s: %s') % (cur_res_name, max_failures))
else:
+ max_failures = None
resObj.delMaxFailures()
resObj.delFailureExpireTime()
@@ -853,8 +861,14 @@ def validate_clusvc_form(model, **kw):
except:
errors.append(_('Invalid value for failure expire time for %s: %s') % (cur_res_name, failure_expire_time))
else:
+ failure_expire_time = None
resObj.delFailureExpireTime()
+ if max_failures and not failure_expire_time:
+ errors.append(_('Failure expire time must be set if maximum failures is set for resource \"%s\" subtree') % dummy_form['resourcename'])
+ if not max_failures and failure_expire_time:
+ errors.append(_('Maximum failures must be set if failure expire time is set for resource \"%s\" subtree') % dummy_form['resourcename'])
+
form_hash[form_id]['obj'] = resObj
if len(errors) > 0:
11 years, 6 months
[luci] luci: Error out if max_restarts is set but not restart_expire_time
by Ryan McCabe
commit 0f0db639ab786c386fb8182fa82ce6bbe93dda8e
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Thu Nov 15 10:56:52 2012 -0500
luci: Error out if max_restarts is set but not restart_expire_time
Error out if max_restarts is set but restart_expire_time is not set,
and vice versa, on the service group config form.
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
luci/validation/validate_resource.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/luci/validation/validate_resource.py b/luci/validation/validate_resource.py
index 7969e0b..674f420 100644
--- a/luci/validation/validate_resource.py
+++ b/luci/validation/validate_resource.py
@@ -613,6 +613,7 @@ def validate_clusvc_form(model, **kw):
except:
errors.append(_('Maximum restarts must be a number greater than or equal to 0'))
else:
+ max_restarts = None
new_service.delMaxRestarts()
restart_expire_time = kw.get('restart_expire_time')
@@ -622,7 +623,13 @@ def validate_clusvc_form(model, **kw):
except:
errors.append(_('Restart expire time must be a number greater than or equal to 0'))
else:
+ restart_expire_time = None
new_service.delRestartExpireTime()
+
+ if max_restarts and not restart_expire_time:
+ errors.append(_('Restart expire time must be set if maximum restarts is set'))
+ if not max_restarts and restart_expire_time:
+ errors.append(_('Maximum restarts must be set if restart expire time is set'))
else:
new_service.delMaxRestarts()
new_service.delRestartExpireTime()
11 years, 6 months