Thanks all for you help, but managed to manipulate the python script to give what I want. I'll try and figure out a way to share how it works, but I'll explain a little here.
Have created three files:
- EXOS_json_based_config_generator.py
- EXOS_parameters.json
- EXOS_with_vlan.j2
The file EXOS_with_vlan.j2 holds the config I want to replicate \ repeat, and looks like the following:
{% for vlan in vlans %}
create vlan "{{ vlan.name }}"
configure vlan {{ vlan.name }} tag {{ vlan.number }}
configure vlan {{ vlan.name }} add ports 1:29,1:34 tagged
configure vlan {{ vlan.name }} ipaddress {{ vlan.ip }} 255.255.255.0
enable ipforwarding vlan {{ vlan.name }}
configure elrp-client periodic {{ vlan.name }} ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan {{ vlan.name }}
create vrrp vlan {{ vlan.name }} vrid 1
configure vrrp vlan {{ vlan.name }} vrid 1 add {{ vlan.vip }}
configure vrrp vlan {{ vlan.name }} vrid 1 priority 150
enable vrrp vlan {{ vlan.name }} vrid 1
configure ospf vlan {{ vlan.name }} priority 0
configure ospf add vlan {{ vlan.name }} area 0.0.0.0 passive
{% endfor %}
The EXOS_parameters.json file contains the dictionary elements I want to repeat in the config above. Now to create that file I simply take a CSV format of my details, which look like the following:
name number ip vip
Hyper-V 100 10.0.0.253 10.0.0.254
DC-Controllers 10 10.0.1.253 10.0.1.254
SQL-Database 20 10.0.2.253 10.0.2.254
App-Servers 30 10.0.3.253 10.0.3.254
Web-Servers 40 10.0.4.253 10.0.4.254
Print-Servers 50 10.0.5.253 10.0.5.254
Email-Services 60 10.0.6.253 10.0.6.254
Citrix-Server 70 10.0.7.253 10.0.7.254
File-Server 80 10.0.8.253 10.0.8.254
Security-Apps 90 10.0.9.253 10.0.9.254
Firewall 106 10.0.10.253 10.0.10.254
Remote-VPN 110 10.0.11.253 10.0.11.254
Wireless 150 10.0.15.253 10.0.15.254
VoIP -servers 120 10.0.20.253 10.0.20.254
Building Services 160 10.0.60.253 10.0.60.254
SwipeCard 170 10.0.70.253 10.0.70.254
CCTV 180 10.0.80.253 10.0.80.254
BEMS 190 10.0.90.253 10.0.90.254
iSCSI 1240 10.0.240.253 10.0.240.254
Point-to-Point 1254 10.0.254.253 10.0.254.254
Core-MGMT 1255 10.0.255.253 10.0.255.254
And then just run it through an online CSV to JSON converter like the following:
http://www.csvjson.com/csv2json
The output I save to the EXOS_parameters.json file.
When done I just run the following script "EXOS_json_based_config_generator.py", and wallah!!!
You get the config output below in a text file, and all I had to do was input the parameters - will save me a whole bunch of time
🙂
create vlan "Hyper-V"
configure vlan Hyper-V tag 100
configure vlan Hyper-V add ports 1:29,1:34 tagged
configure vlan Hyper-V ipaddress 10.0.0.253 255.255.255.0
enable ipforwarding vlan Hyper-V
configure elrp-client periodic Hyper-V ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Hyper-V
create vrrp vlan Hyper-V vrid 1
configure vrrp vlan Hyper-V vrid 1 add 10.0.0.254
configure vrrp vlan Hyper-V vrid 1 priority 150
enable vrrp vlan Hyper-V vrid 1
configure ospf vlan Hyper-V priority 0
configure ospf add vlan Hyper-V area 0.0.0.0 passive
create vlan "DC-Controllers"
configure vlan DC-Controllers tag 10
configure vlan DC-Controllers add ports 1:29,1:34 tagged
configure vlan DC-Controllers ipaddress 10.0.1.253 255.255.255.0
enable ipforwarding vlan DC-Controllers
configure elrp-client periodic DC-Controllers ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan DC-Controllers
create vrrp vlan DC-Controllers vrid 1
configure vrrp vlan DC-Controllers vrid 1 add 10.0.1.254
configure vrrp vlan DC-Controllers vrid 1 priority 150
enable vrrp vlan DC-Controllers vrid 1
configure ospf vlan DC-Controllers priority 0
configure ospf add vlan DC-Controllers area 0.0.0.0 passive
create vlan "SQL-Database"
configure vlan SQL-Database tag 20
configure vlan SQL-Database add ports 1:29,1:34 tagged
configure vlan SQL-Database ipaddress 10.0.2.253 255.255.255.0
enable ipforwarding vlan SQL-Database
configure elrp-client periodic SQL-Database ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan SQL-Database
create vrrp vlan SQL-Database vrid 1
configure vrrp vlan SQL-Database vrid 1 add 10.0.2.254
configure vrrp vlan SQL-Database vrid 1 priority 150
enable vrrp vlan SQL-Database vrid 1
configure ospf vlan SQL-Database priority 0
configure ospf add vlan SQL-Database area 0.0.0.0 passive
create vlan "App-Servers"
configure vlan App-Servers tag 30
configure vlan App-Servers add ports 1:29,1:34 tagged
configure vlan App-Servers ipaddress 10.0.3.253 255.255.255.0
enable ipforwarding vlan App-Servers
configure elrp-client periodic App-Servers ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan App-Servers
create vrrp vlan App-Servers vrid 1
configure vrrp vlan App-Servers vrid 1 add 10.0.3.254
configure vrrp vlan App-Servers vrid 1 priority 150
enable vrrp vlan App-Servers vrid 1
configure ospf vlan App-Servers priority 0
configure ospf add vlan App-Servers area 0.0.0.0 passive
create vlan "Web-Servers"
configure vlan Web-Servers tag 40
configure vlan Web-Servers add ports 1:29,1:34 tagged
configure vlan Web-Servers ipaddress 10.0.4.253 255.255.255.0
enable ipforwarding vlan Web-Servers
configure elrp-client periodic Web-Servers ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Web-Servers
create vrrp vlan Web-Servers vrid 1
configure vrrp vlan Web-Servers vrid 1 add 10.0.4.254
configure vrrp vlan Web-Servers vrid 1 priority 150
enable vrrp vlan Web-Servers vrid 1
configure ospf vlan Web-Servers priority 0
configure ospf add vlan Web-Servers area 0.0.0.0 passive
create vlan "Print-Servers"
configure vlan Print-Servers tag 50
configure vlan Print-Servers add ports 1:29,1:34 tagged
configure vlan Print-Servers ipaddress 10.0.5.253 255.255.255.0
enable ipforwarding vlan Print-Servers
configure elrp-client periodic Print-Servers ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Print-Servers
create vrrp vlan Print-Servers vrid 1
configure vrrp vlan Print-Servers vrid 1 add 10.0.5.254
configure vrrp vlan Print-Servers vrid 1 priority 150
enable vrrp vlan Print-Servers vrid 1
configure ospf vlan Print-Servers priority 0
configure ospf add vlan Print-Servers area 0.0.0.0 passive
create vlan "Email-Services"
configure vlan Email-Services tag 60
configure vlan Email-Services add ports 1:29,1:34 tagged
configure vlan Email-Services ipaddress 10.0.6.253 255.255.255.0
enable ipforwarding vlan Email-Services
configure elrp-client periodic Email-Services ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Email-Services
create vrrp vlan Email-Services vrid 1
configure vrrp vlan Email-Services vrid 1 add 10.0.6.254
configure vrrp vlan Email-Services vrid 1 priority 150
enable vrrp vlan Email-Services vrid 1
configure ospf vlan Email-Services priority 0
configure ospf add vlan Email-Services area 0.0.0.0 passive
create vlan "Citrix-Server"
configure vlan Citrix-Server tag 70
configure vlan Citrix-Server add ports 1:29,1:34 tagged
configure vlan Citrix-Server ipaddress 10.0.7.253 255.255.255.0
enable ipforwarding vlan Citrix-Server
configure elrp-client periodic Citrix-Server ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Citrix-Server
create vrrp vlan Citrix-Server vrid 1
configure vrrp vlan Citrix-Server vrid 1 add 10.0.7.254
configure vrrp vlan Citrix-Server vrid 1 priority 150
enable vrrp vlan Citrix-Server vrid 1
configure ospf vlan Citrix-Server priority 0
configure ospf add vlan Citrix-Server area 0.0.0.0 passive
create vlan "File-Server"
configure vlan File-Server tag 80
configure vlan File-Server add ports 1:29,1:34 tagged
configure vlan File-Server ipaddress 10.0.8.253 255.255.255.0
enable ipforwarding vlan File-Server
configure elrp-client periodic File-Server ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan File-Server
create vrrp vlan File-Server vrid 1
configure vrrp vlan File-Server vrid 1 add 10.0.8.254
configure vrrp vlan File-Server vrid 1 priority 150
enable vrrp vlan File-Server vrid 1
configure ospf vlan File-Server priority 0
configure ospf add vlan File-Server area 0.0.0.0 passive
create vlan "Security-Apps"
configure vlan Security-Apps tag 90
configure vlan Security-Apps add ports 1:29,1:34 tagged
configure vlan Security-Apps ipaddress 10.0.9.253 255.255.255.0
enable ipforwarding vlan Security-Apps
configure elrp-client periodic Security-Apps ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Security-Apps
create vrrp vlan Security-Apps vrid 1
configure vrrp vlan Security-Apps vrid 1 add 10.0.9.254
configure vrrp vlan Security-Apps vrid 1 priority 150
enable vrrp vlan Security-Apps vrid 1
configure ospf vlan Security-Apps priority 0
configure ospf add vlan Security-Apps area 0.0.0.0 passive
create vlan "Firewall"
configure vlan Firewall tag 106
configure vlan Firewall add ports 1:29,1:34 tagged
configure vlan Firewall ipaddress 10.0.10.253 255.255.255.0
enable ipforwarding vlan Firewall
configure elrp-client periodic Firewall ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Firewall
create vrrp vlan Firewall vrid 1
configure vrrp vlan Firewall vrid 1 add 10.0.10.254
configure vrrp vlan Firewall vrid 1 priority 150
enable vrrp vlan Firewall vrid 1
configure ospf vlan Firewall priority 0
configure ospf add vlan Firewall area 0.0.0.0 passive
create vlan "Remote-VPN"
configure vlan Remote-VPN tag 110
configure vlan Remote-VPN add ports 1:29,1:34 tagged
configure vlan Remote-VPN ipaddress 10.0.11.253 255.255.255.0
enable ipforwarding vlan Remote-VPN
configure elrp-client periodic Remote-VPN ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Remote-VPN
create vrrp vlan Remote-VPN vrid 1
configure vrrp vlan Remote-VPN vrid 1 add 10.0.11.254
configure vrrp vlan Remote-VPN vrid 1 priority 150
enable vrrp vlan Remote-VPN vrid 1
configure ospf vlan Remote-VPN priority 0
configure ospf add vlan Remote-VPN area 0.0.0.0 passive
create vlan "Wireless"
configure vlan Wireless tag 150
configure vlan Wireless add ports 1:29,1:34 tagged
configure vlan Wireless ipaddress 10.0.15.253 255.255.255.0
enable ipforwarding vlan Wireless
configure elrp-client periodic Wireless ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Wireless
create vrrp vlan Wireless vrid 1
configure vrrp vlan Wireless vrid 1 add 10.0.15.254
configure vrrp vlan Wireless vrid 1 priority 150
enable vrrp vlan Wireless vrid 1
configure ospf vlan Wireless priority 0
configure ospf add vlan Wireless area 0.0.0.0 passive
create vlan "VoIP -servers"
configure vlan VoIP -servers tag 120
configure vlan VoIP -servers add ports 1:29,1:34 tagged
configure vlan VoIP -servers ipaddress 10.0.20.253 255.255.255.0
enable ipforwarding vlan VoIP -servers
configure elrp-client periodic VoIP -servers ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan VoIP -servers
create vrrp vlan VoIP -servers vrid 1
configure vrrp vlan VoIP -servers vrid 1 add 10.0.20.254
configure vrrp vlan VoIP -servers vrid 1 priority 150
enable vrrp vlan VoIP -servers vrid 1
configure ospf vlan VoIP -servers priority 0
configure ospf add vlan VoIP -servers area 0.0.0.0 passive
create vlan "Building Services"
configure vlan Building Services tag 160
configure vlan Building Services add ports 1:29,1:34 tagged
configure vlan Building Services ipaddress 10.0.60.253 255.255.255.0
enable ipforwarding vlan Building Services
configure elrp-client periodic Building Services ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Building Services
create vrrp vlan Building Services vrid 1
configure vrrp vlan Building Services vrid 1 add 10.0.60.254
configure vrrp vlan Building Services vrid 1 priority 150
enable vrrp vlan Building Services vrid 1
configure ospf vlan Building Services priority 0
configure ospf add vlan Building Services area 0.0.0.0 passive
create vlan "SwipeCard"
configure vlan SwipeCard tag 170
configure vlan SwipeCard add ports 1:29,1:34 tagged
configure vlan SwipeCard ipaddress 10.0.70.253 255.255.255.0
enable ipforwarding vlan SwipeCard
configure elrp-client periodic SwipeCard ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan SwipeCard
create vrrp vlan SwipeCard vrid 1
configure vrrp vlan SwipeCard vrid 1 add 10.0.70.254
configure vrrp vlan SwipeCard vrid 1 priority 150
enable vrrp vlan SwipeCard vrid 1
configure ospf vlan SwipeCard priority 0
configure ospf add vlan SwipeCard area 0.0.0.0 passive
create vlan "CCTV"
configure vlan CCTV tag 180
configure vlan CCTV add ports 1:29,1:34 tagged
configure vlan CCTV ipaddress 10.0.80.253 255.255.255.0
enable ipforwarding vlan CCTV
configure elrp-client periodic CCTV ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan CCTV
create vrrp vlan CCTV vrid 1
configure vrrp vlan CCTV vrid 1 add 10.0.80.254
configure vrrp vlan CCTV vrid 1 priority 150
enable vrrp vlan CCTV vrid 1
configure ospf vlan CCTV priority 0
configure ospf add vlan CCTV area 0.0.0.0 passive
create vlan "BEMS"
configure vlan BEMS tag 190
configure vlan BEMS add ports 1:29,1:34 tagged
configure vlan BEMS ipaddress 10.0.90.253 255.255.255.0
enable ipforwarding vlan BEMS
configure elrp-client periodic BEMS ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan BEMS
create vrrp vlan BEMS vrid 1
configure vrrp vlan BEMS vrid 1 add 10.0.90.254
configure vrrp vlan BEMS vrid 1 priority 150
enable vrrp vlan BEMS vrid 1
configure ospf vlan BEMS priority 0
configure ospf add vlan BEMS area 0.0.0.0 passive
create vlan "iSCSI"
configure vlan iSCSI tag 1240
configure vlan iSCSI add ports 1:29,1:34 tagged
configure vlan iSCSI ipaddress 10.0.240.253 255.255.255.0
enable ipforwarding vlan iSCSI
configure elrp-client periodic iSCSI ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan iSCSI
create vrrp vlan iSCSI vrid 1
configure vrrp vlan iSCSI vrid 1 add 10.0.240.254
configure vrrp vlan iSCSI vrid 1 priority 150
enable vrrp vlan iSCSI vrid 1
configure ospf vlan iSCSI priority 0
configure ospf add vlan iSCSI area 0.0.0.0 passive
create vlan "Point-to-Point"
configure vlan Point-to-Point tag 1254
configure vlan Point-to-Point add ports 1:29,1:34 tagged
configure vlan Point-to-Point ipaddress 10.0.254.253 255.255.255.0
enable ipforwarding vlan Point-to-Point
configure elrp-client periodic Point-to-Point ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Point-to-Point
create vrrp vlan Point-to-Point vrid 1
configure vrrp vlan Point-to-Point vrid 1 add 10.0.254.254
configure vrrp vlan Point-to-Point vrid 1 priority 150
enable vrrp vlan Point-to-Point vrid 1
configure ospf vlan Point-to-Point priority 0
configure ospf add vlan Point-to-Point area 0.0.0.0 passive
create vlan "Core-MGMT"
configure vlan Core-MGMT tag 1255
configure vlan Core-MGMT add ports 1:29,1:34 tagged
configure vlan Core-MGMT ipaddress 10.0.255.253 255.255.255.0
enable ipforwarding vlan Core-MGMT
configure elrp-client periodic Core-MGMT ports 61,1 interval 1 log-and-trap disable-port ingress permanent
enable bootprelay ipv4 vlan Core-MGMT
create vrrp vlan Core-MGMT vrid 1
configure vrrp vlan Core-MGMT vrid 1 add 10.0.255.254
configure vrrp vlan Core-MGMT vrid 1 priority 150
enable vrrp vlan Core-MGMT vrid 1
configure ospf vlan Core-MGMT priority 0
configure ospf add vlan Core-MGMT area 0.0.0.0 passive