02-12-2022 10:42 AM
Have created my first Python script!
The project gave me a real world example to practice.
Probably is the most terribly written program ever (still working on it), but it does function. Decided to publish now in case it is useful to someone in the meantime, as saved me a considerable amount of time on large deployments. There isn't much exception handling, so if you use it and hit an issue let me know.
The script can be found here - Github Repository
It basically takes an EOS backup file, or an Excel configuration template file (included in repository) and produces all the VLAN / Interface configuration into VOSS. Equally it will take the EOS config and create a spreadsheet with all the configuration details like IP address, VLAN ID, VRRP VIP, Helpers etc.
Accompanying the python script file is an example EOS backup file called 'eos_full_config.txt', and the VOSS Excel configuration template 'Config_Temp_Ver08'. At this time the script only supports the 'Interface' tab in the Excel file, but I do have another python script that creates the generic configs from the 'Fabric' tab that fully creates the VOSS ready to roll. This will be added in later additions.
This is configured in Python 3, and will need to do a PIP install for openpyxl and inquirer.
Here is an example of what the 'interface' tab in the Excel configuration template file looks like:
The Excel configuration template might be useful just on its own without the script, as is something I generally work with customers to fill out on a new deployments.
The EOS backup file and the Excel (.xlsx) needs to be in the same location as the python script file.
A series of questions will be asked when the script runs where you choose:
This program will extrapolate the following from an EOS backup file:
set vlan name 64 "Power House GUEST LAN"
interface vlan.0.64
ip address 10.119.64.3 255.255.255.0 primary
vrrp create 1 v2-IPv4
vrrp address 1 110.119.64.1
vrrp priority 1 200
vrrp accept-mode 1
vrrp enable 1
ip helper-address 10.119.0.140
ip helper-address 10.119.0.200
no ip redirects
exit
And convert to something like the below.
vlan create 64 name "Power House GUEST LAN" type port-mstprstp 0
vlan i-sid 64 12110064
interface vlan 64
ip address 10.119.255.10 255.255.255.0
ip vrrp version 3
ip vrrp address 2 112
ip vrrp 112 backup-master enable
ip vrrp 112 enable
ip vrrp 112 priority 200
ip dhcp-relay
ip dhcp-relay mode dhcp
ip ospf area 0.0.0.0
ip ospf network passive
ip ospf enable
ip igmp snooping
exit
ip dhcp-relay fwd-path 10.119.255.10 10.119.0.140
ip dhcp-relay fwd-path 10.119.255.10 10.119.0.140 enable
ip dhcp-relay fwd-path 10.119.255.10 10.119.0.140 mode bootp_dhcp
ip dhcp-relay fwd-path 10.119.255.10 10.119.0.200
ip dhcp-relay fwd-path 10.119.255.10 10.119.0.200 enable
ip dhcp-relay fwd-path 10.119.255.10 10.119.0.200 mode bootp_dhcp
exit
If anyone try's it, open to any criticism, suggestions, problems with running it etc
Still have a lot to learn, so hopefully the script, exception handling, comments etc will get better over time.
Work will continue to improve it, tidy it up, and will later include conversation of EXOS and CISCO IOS config.
Thanks,
Martin