Show proper warning message if security group rule is incomplete
* fixes bug 944472 Change-Id: I1a275385547f09dc317ba213767f80036b3bca7c
This commit is contained in:
parent
a6c39e5ba6
commit
a23434dae4
@ -92,18 +92,25 @@ class AddRule(forms.SelfHandlingForm):
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(AddRule, self).clean()
|
||||
to_port = cleaned_data.get("to_port", None)
|
||||
from_port = cleaned_data.get("from_port", None)
|
||||
if to_port == None:
|
||||
msg = _('The "to" port number must not be empty.')
|
||||
raise ValidationError(msg)
|
||||
to_port = cleaned_data.get("to_port", None)
|
||||
cidr = cleaned_data.get("cidr", None)
|
||||
|
||||
if from_port == None:
|
||||
msg = _('The "from" port number must not be empty.')
|
||||
msg = _('The "from" port number is invalid.')
|
||||
raise ValidationError(msg)
|
||||
if to_port == None:
|
||||
msg = _('The "to" port number is invalid.')
|
||||
raise ValidationError(msg)
|
||||
if to_port < from_port:
|
||||
msg = _('The "to" port number must be greater than or equal to '
|
||||
'the "from" port number.')
|
||||
raise ValidationError(msg)
|
||||
|
||||
if cidr == None:
|
||||
msg = _('The "CIDR" is invalid')
|
||||
raise ValidationError(msg)
|
||||
|
||||
return cleaned_data
|
||||
|
||||
def handle(self, request, data):
|
||||
|
@ -30,4 +30,4 @@ validate_ipv4_cidr = validators.RegexValidator(ipv4_cidr_re)
|
||||
|
||||
def validate_port_range(port):
|
||||
if port not in range(-1, 65535):
|
||||
raise ValidationError(u'%d is not a valid port number' % port)
|
||||
raise ValidationError("Not a valid port number")
|
||||
|
@ -817,7 +817,6 @@ tr.terminated {
|
||||
|
||||
form div.clearfix.error {
|
||||
width: 330px;
|
||||
padding: 10px 10px;
|
||||
}
|
||||
|
||||
/* Region selector in header */
|
||||
|
Loading…
x
Reference in New Issue
Block a user