aboutsummaryrefslogtreecommitdiff
path: root/util.py
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2015-08-03 19:28:25 +0100
committerSteve McIntyre <steve.mcintyre@linaro.org>2015-08-03 19:28:25 +0100
commit6b8d386d0563fb1769b985605adbf748fa37452a (patch)
tree0fdf67b256a80d6f4edc02199f18b63a2550c3fb /util.py
parent42122b777643c175c3d1213fafc41796960f9ce2 (diff)
If we're passed a VLAN tag of -1, find and allocate the first unused
Change-Id: Ibabf1c88ec33aa382d3d35b5af468aeb3ee708a8
Diffstat (limited to 'util.py')
-rw-r--r--util.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/util.py b/util.py
index 864591e..d1b2a51 100644
--- a/util.py
+++ b/util.py
@@ -203,6 +203,11 @@ class VlanUtil:
db = state.db
config = state.config
+ # Check for tag == -1, i.e. use the next available tag
+ if tag == -1:
+ tag = db.find_lowest_unused_vlan_tag()
+ logging.debug('create_vlan called with a tag of -1, found first unused tag %d', tag)
+
# 1. Database record first
try:
logging.debug('Adding DB record first: name %s, tag %d, is_base_vlan %d', name, tag, is_base_vlan)
@@ -291,7 +296,7 @@ class VlanUtil:
s.switch_disconnect()
del s
- return vlan_id # If we're successful
+ return (vlan_id, tag) # If we're successful
# Complex call
# 1. Check in the DB if there are any ports on the VLAN. Bail if so