From 74c2a66e0559c9d5cefe3e68310e3046f0cdfe19 Mon Sep 17 00:00:00 2001 From: Masco Kaliyamoorthy Date: Mon, 4 May 2015 19:36:57 +0530 Subject: [PATCH] check DPD interval and timeout for IPSec site connection While creating and updating IPSec Site Connection, the DPD interval should be lesser than DPD timeout. this Condition can be validated at client side. This patch validating the interval and timeout for update and create forms. Change-Id: I039149190358ca6a6b53ba75c8f08267047b201b Closes-Bug: #1451440 --- openstack_dashboard/dashboards/project/vpn/forms.py | 12 +++++++++++- .../dashboards/project/vpn/workflows.py | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) 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',)