diff options
author | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-23 17:17:22 +0000 |
---|---|---|
committer | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-23 17:17:22 +0000 |
commit | b152907f95d784d1cf64d073772c9876fade8b91 (patch) | |
tree | 6e9682c95b52ae594bf551a4d2a6a17925cde794 | |
parent | f67956de17c288c9b810f0115485027db73670fa (diff) |
The detault VLAN will already exist, and will have a different name
from switch to switch...
Change-Id: I7df9c821b48bd71e9211cf3065b179b481486909
-rw-r--r-- | util.py | 32 |
1 files changed, 17 insertions, 15 deletions
@@ -655,26 +655,28 @@ class VlanUtil: # If a VLAN is already in the database, then that's easy - # we can just ignore it. However, we have to check that # there is not a different name for the existing VLAN tag - # - bail out if so... + # - bail out if so... UNLESS we're looking at the default + # VLAN # # If this VLAN tag is not already in the DB, we'll need to # add it there and to all the other switches (and their # trunk ports!) too. - vlan_id = db.get_vlan_id_by_tag(vlan_tag) - if vlan_id is not None: - vlan_db_name = db.get_vlan_name_by_id(vlan_id) - if vlan_name != vlan_db_name: - raise InputError("Can't add VLAN tag %d (name %s) for this switch - VLAN tag %d already exists in the database, but with a different name (%s)" % (vlan_tag, vlan_name, vlan_tag, vlan_db_name)) + if vlan_id is not state.default_vlan_id: + vlan_id = db.get_vlan_id_by_tag(vlan_tag) + if vlan_id is not None: + vlan_db_name = db.get_vlan_name_by_id(vlan_id) + if vlan_name != vlan_db_name: + raise InputError("Can't add VLAN tag %d (name %s) for this switch - VLAN tag %d already exists in the database, but with a different name (%s)" % (vlan_tag, vlan_name, vlan_tag, vlan_db_name)) - else: - # OK, we'll need to set up the new VLAN now. It can't - # be a base VLAN - switches don't have such a concept! - # Rather than create individually here, add to a - # list. *Only* once we've worked through all the - # switch's VLANs successfully (checking for existing - # records and possible clashes!) should we start - # committing changes - new_vlan_tags.append(vlan_tag) + else: + # OK, we'll need to set up the new VLAN now. It can't + # be a base VLAN - switches don't have such a concept! + # Rather than create individually here, add to a + # list. *Only* once we've worked through all the + # switch's VLANs successfully (checking for existing + # records and possible clashes!) should we start + # committing changes + new_vlan_tags.append(vlan_tag) # Now create the VLAN DB entries for vlan_tag in new_vlan_tags: |