Disallow network creation when label > 255. Fixes bug 965008

Added length check for label. Without length check,
label is truncated. Warning is shown by sqlalchemy layer.

Raise an InvalidInput exception when validation fails (like
rest of the surroudning code)

Change-Id: Iae517e03099e36f1c00f4742049834a9231a2fff
This commit is contained in:
Mandar Vaze
2012-04-02 03:02:22 -07:00
parent caa1b282c7
commit 2cea9b0413
2 changed files with 4 additions and 1 deletions

View File

@@ -126,7 +126,6 @@ Lorin Hochstein <lorin@nimbisservices.com>
Lvov Maxim <usrleon@gmail.com>
Mandar Vaze <mandar.vaze@vertex.co.in>
Mandell Degerness <mdegerne@gmail.com>
Mandar Vaze <mandar.vaze@vertex.co.in>
Mark McClain <mark.mcclain@dreamhost.com>
Mark McLoughlin <markmc@redhat.com>
Mark Washenberger <mark.washenberger@rackspace.com>

View File

@@ -740,6 +740,10 @@ class NetworkCommands(object):
# check for certain required inputs
if not label:
raise exception.NetworkNotCreated(req='--label')
# Size of "label" column in nova.networks is 255, hence the restriction
if len(label) > 255:
reason = _("Maximum allowed length for 'label' is 255.")
raise exception.InvalidInput(reason=reason)
if not (fixed_range_v4 or fixed_range_v6):
req = '--fixed_range_v4 or --fixed_range_v6'
raise exception.NetworkNotCreated(req=req)