diff --git a/openstack_dashboard/dashboards/project/vpn/forms.py b/openstack_dashboard/dashboards/project/vpn/forms.py index 462cdc20b2..31c3e47a87 100644 --- a/openstack_dashboard/dashboards/project/vpn/forms.py +++ b/openstack_dashboard/dashboards/project/vpn/forms.py @@ -249,7 +249,7 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm): dpd_interval = forms.IntegerField( min_value=1, label=_("Dead peer detection interval"), - help_text=_("Valid integer")) + help_text=_("Valid integer lesser than the DPD timeout")) dpd_timeout = forms.IntegerField( min_value=1, label=_("Dead peer detection timeout"), @@ -264,6 +264,16 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm): failure_url = 'horizon:project:vpn:index' + def clean(self): + cleaned_data = super(UpdateIPSecSiteConnection, self).clean() + interval = cleaned_data.get('dpd_interval') + timeout = cleaned_data.get('dpd_timeout') + + if not interval < timeout: + msg = _("DPD Timeout must be greater than DPD Interval") + self._errors['dpd_timeout'] = self.error_class([msg]) + return cleaned_data + def handle(self, request, context): context['admin_state_up'] = (context['admin_state_up'] == 'True') try: diff --git a/openstack_dashboard/dashboards/project/vpn/workflows.py b/openstack_dashboard/dashboards/project/vpn/workflows.py index 4c2dce0aba..76ce2d2b08 100644 --- a/openstack_dashboard/dashboards/project/vpn/workflows.py +++ b/openstack_dashboard/dashboards/project/vpn/workflows.py @@ -408,7 +408,7 @@ class AddIPSecSiteConnectionOptionalAction(workflows.Action): dpd_interval = forms.IntegerField( min_value=1, label=_("Dead peer detection interval"), initial=30, - help_text=_("Valid integer")) + help_text=_("Valid integer lesser than DPD timeout")) dpd_timeout = forms.IntegerField( min_value=1, label=_("Dead peer detection timeout"), initial=120, @@ -436,6 +436,17 @@ class AddIPSecSiteConnectionOptionalAction(workflows.Action): self.fields['dpd_action'].choices = dpd_action_choices return dpd_action_choices + def clean(self): + cleaned_data = super(AddIPSecSiteConnectionOptionalAction, + self).clean() + interval = cleaned_data.get('dpd_interval') + timeout = cleaned_data.get('dpd_timeout') + + if not interval < timeout: + msg = _("DPD Timeout must be greater than DPD Interval") + self._errors['dpd_timeout'] = self.error_class([msg]) + return cleaned_data + class Meta(object): name = _("Optional Parameters") permissions = ('openstack.services.network',)