Add VLANs to new switches as needed on import
Change-Id: Idf4c5b51eee433f5af7721b5c63c4d4f0792983d
diff --git a/util.py b/util.py
index 4cce8ea..0f71329 100644
--- a/util.py
+++ b/util.py
@@ -744,6 +744,14 @@
db.set_port_mode(port_id, port_mode)
+ # Make sure this switch has all the VLANs we need
+ for vlan in db.all_vlans():
+ if vlan.tag is not state.config.vland.default_vlan_tag:
+ if not vlan.tag in new_vlan_tags:
+ print "Adding VLAN tag %d to this switch" % (vlan.tag)
+ s.vlan_create(vlan.tag)
+ s.vlan_set_name(vlan.tag, vlan.name)
+
# Now, on each trunk port on the switch, we need to add all
# the VLANs already configured across our system
if not 'TrunkWildCardVlans' in s.switch_get_capabilities():
@@ -755,7 +763,6 @@
print "Adding allowed VLAN tag %d to trunk port %s" % (vlan.tag, port.name)
s.port_add_trunk_to_vlan(port.name, vlan.tag)
-
# Done with this switch \o/
s.switch_save_running_config()
s.switch_disconnect()