2. Order of operation

Since the config generator is far from perfect – unlike myself – there are a few functions that can wreck havoc on your configuration output if you’re not careful. (Using the example layout from the script itself works fine.) When you import the module for use in other scripts, be sure to:

2.1. migrate_ports() before vlan_extract()

vlan_extract() will also prune any VLANs that are not assigned to edge ports so as to clean out the VLAN database.

2.2. trunk_cleanup() before remove_mdix_and_dot1q()

If ports are configured with switchport mode trunk but still contain commands for access ports, all encapsulation configuration will be removed

2.3. Call add_snooping() last

Adding ip dhcp snooping too early will cause the switch to believe that it should be applied to an interface. Since it is not a valid interface command, it discards it from the startup-config. It should be invoked last with a least one function called in-between it and migrate_ports(), that way a buffer is put between the configuration generated by them.

Note

It should also be called after migrate_ports() so that pruned VLANs are not added to the list

2.3.1. Example

Calling too early:

interface vlan 300
 ip address 10.23.21.4 255.255.255.128
 no ip route-cache
! The switch will mistakenly apply the next line to VLAN 300 and discard
ip dhcp snooping vlan 24,109,209,309,318,483,509,609,620,651,709,902,985,1902
no ip dhcp snooping information option
ip dhcp snooping