Merge "Check delay and timeout when editing monitor"

This commit is contained in:
Jenkins 2015-05-26 11:13:35 +00:00 committed by Gerrit Code Review
commit eee1225311
2 changed files with 15 additions and 4 deletions

View File

@ -224,12 +224,13 @@ class UpdateMonitor(forms.SelfHandlingForm):
min_value=1, min_value=1,
label=_("Delay"), label=_("Delay"),
help_text=_("The minimum time in seconds between regular checks " help_text=_("The minimum time in seconds between regular checks "
"of a member")) "of a member. It must be greater than or equal to "
"timeout"))
timeout = forms.IntegerField( timeout = forms.IntegerField(
min_value=1, min_value=1,
label=_("Timeout"), label=_("Timeout"),
help_text=_("The maximum time in seconds for a monitor to wait " help_text=_("The maximum time in seconds for a monitor to wait "
"for a reply")) "for a reply. It must be less than or equal to delay"))
max_retries = forms.IntegerField( max_retries = forms.IntegerField(
max_value=10, min_value=1, max_value=10, min_value=1,
label=_("Max Retries (1~10)"), label=_("Max Retries (1~10)"),
@ -244,6 +245,15 @@ class UpdateMonitor(forms.SelfHandlingForm):
def __init__(self, request, *args, **kwargs): def __init__(self, request, *args, **kwargs):
super(UpdateMonitor, self).__init__(request, *args, **kwargs) super(UpdateMonitor, self).__init__(request, *args, **kwargs)
def clean(self):
cleaned_data = super(UpdateMonitor, self).clean()
delay = cleaned_data.get('delay')
timeout = cleaned_data.get('timeout')
if not delay >= timeout:
msg = _('Delay must be greater than or equal to timeout')
self._errors['delay'] = self.error_class([msg])
return cleaned_data
def handle(self, request, context): def handle(self, request, context):
context['admin_state_up'] = (context['admin_state_up'] == 'True') context['admin_state_up'] = (context['admin_state_up'] == 'True')
try: try:

View File

@ -492,12 +492,13 @@ class AddMonitorAction(workflows.Action):
min_value=1, min_value=1,
label=_("Delay"), label=_("Delay"),
help_text=_("The minimum time in seconds between regular checks " help_text=_("The minimum time in seconds between regular checks "
"of a member")) "of a member. It must be greater than or equal to "
"timeout"))
timeout = forms.IntegerField( timeout = forms.IntegerField(
min_value=1, min_value=1,
label=_("Timeout"), label=_("Timeout"),
help_text=_("The maximum time in seconds for a monitor to wait " help_text=_("The maximum time in seconds for a monitor to wait "
"for a reply")) "for a reply. It must be less than or equal to delay"))
max_retries = forms.IntegerField( max_retries = forms.IntegerField(
max_value=10, min_value=1, max_value=10, min_value=1,
label=_("Max Retries (1~10)"), label=_("Max Retries (1~10)"),