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
This commit is contained in:
Masco Kaliyamoorthy 2015-05-04 19:36:57 +05:30
parent 5f23ee8b87
commit 74c2a66e05
2 changed files with 23 additions and 2 deletions

View File

@ -249,7 +249,7 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm):
dpd_interval = forms.IntegerField( dpd_interval = forms.IntegerField(
min_value=1, min_value=1,
label=_("Dead peer detection interval"), label=_("Dead peer detection interval"),
help_text=_("Valid integer")) help_text=_("Valid integer lesser than the DPD timeout"))
dpd_timeout = forms.IntegerField( dpd_timeout = forms.IntegerField(
min_value=1, min_value=1,
label=_("Dead peer detection timeout"), label=_("Dead peer detection timeout"),
@ -264,6 +264,16 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm):
failure_url = 'horizon:project:vpn:index' 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): 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

@ -408,7 +408,7 @@ class AddIPSecSiteConnectionOptionalAction(workflows.Action):
dpd_interval = forms.IntegerField( dpd_interval = forms.IntegerField(
min_value=1, label=_("Dead peer detection interval"), min_value=1, label=_("Dead peer detection interval"),
initial=30, initial=30,
help_text=_("Valid integer")) help_text=_("Valid integer lesser than DPD timeout"))
dpd_timeout = forms.IntegerField( dpd_timeout = forms.IntegerField(
min_value=1, label=_("Dead peer detection timeout"), min_value=1, label=_("Dead peer detection timeout"),
initial=120, initial=120,
@ -436,6 +436,17 @@ class AddIPSecSiteConnectionOptionalAction(workflows.Action):
self.fields['dpd_action'].choices = dpd_action_choices self.fields['dpd_action'].choices = dpd_action_choices
return 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): class Meta(object):
name = _("Optional Parameters") name = _("Optional Parameters")
permissions = ('openstack.services.network',) permissions = ('openstack.services.network',)