Validate VLAN tags on VLAN creation
Change-Id: Ic7a498cf6cf8c8f765691f4a495abec79bc960fb
diff --git a/db/db.py b/db/db.py
index 3e33133..b09cc0a 100644
--- a/db/db.py
+++ b/db/db.py
@@ -105,8 +105,13 @@
#
# Constraints:
# Names and tags must be unique
+ # Tags must be in the range 1-4095 (802.1q spec)
+ #
def create_vlan(self, name, tag, is_base_vlan):
+ if int(tag) < 1 or int(tag) > 4095:
+ raise InputError("VLAN tag %d is outside of the valid range (1-4095)" % int(tag)
+
vlan_id = self.get_vlan_id_by_name(name)
if vlan_id is not None:
raise InputError("VLAN name %s is already in use" % name)