cancel
Showing results for 
Search instead for 
Did you mean: 

EXOS configuration scripting tool

EXOS configuration scripting tool

Anonymous
Not applicable
Hi,

Going to throw this out there in the hope the community has some ideas.

I often find myself building configs with a lot of repative configuration statements, so was looking for a means of automating this.

Have played a little with python, but I'm very new to it so can't quit adopt it for use.

Found this article https://codingnetworker.com/2015/09/configuration-generator-with-python-and-jinja2/ where I changed the config to match EXOS and used a CSV file to fill in the parameters:

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
This worked fine, except the elements above I need to repeat for every parameter listed. For example I might have 100 'vlan-name', 'vlan-number', 'vlan-ip' etc

So I need it to cyclic through each of the parameters and stop when finished. Although the article details the use of JSON which might do the trick, the preparation of that file would take too long. Whereas the creation of a CSV file with all the details in would be much easier and quicker to create.

Perhaps there is an easier way to do it, or something that already exits?

Look forward to any answers.

Thanks in advance

12 REPLIES 12

Dave_Hammers
Extreme Employee
I'm not sure if this will do what you want.
In EXOS 22.3 is the USBZTP feature.
As part of that capability, you can clone an entire switch to a USB memory module, including any configuration and then use that to initialize another switch.

The way this might help your needs is if you had a base configuration and EXOS release version you wanted to start with on each switch,
  • Start with your reference switch
  • configure the base configuration you want on all switches
  • save
  • clone to USB
  • insert that USB in a new switch
  • clone from USB
the new switch is now a copy of your reference switch.
  • both EXOS partitions
  • The entire /usr/local/cfg directory
  • licenses are not copied
Some things to keep in mind:
  • the entire configuration directory is cloned, including any scripts, policy files etc.
  • if the reference configuration has IP addresses, they will also be cloned and may need to be changed on the new switch.

Johannes_Dennin
New Contributor
I've built something similiar, very basic with YAML files instead of JSON for easier readability:

https://github.com/joxz/yml2xos

It's configured to my needs but easy to make it fit to other needs.

Ignore the deploy.py it doesn't work 

Anonymous
Not applicable
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

EtherMAN
Contributor III
What you are asking about is built into Netsight. There are many canned scripts that can be run on single or groups of switches ... Port groups ect. The power of scripting is being able to create a command and make configuration changes in the switches with less chance of human error.. We for example have a unique script for each of our EAPS rings that anytime we need to create and add a new vlan to a ring all the engineers need to do is go to the correct port group map for that ring and run the script. It prompts them for the the vlan tag and name... the rest is built into the script.

Same thing would apply if you need to say change something in all your devices ... single script run on hundreds of switches 10 or 20 at a time till it's done... If you dont have Netsight then get a demo key up and running and you can see how the scripts are triigger and used and over time you build your own library of scripts unique to you

Anonymous
Not applicable
Hi Larry,

Thanks for the information.

Had seen this previously, and I can see its value but not in what I want to achieve - although admittedly some of it goes over my head.

To take an example from the section you gave, this piece of code is given:

enable cli scripting Set var count 1 while ($count < 101) do Create vlan v$count configure vlan v$count ipaddress 10.$(count).1.1/16 set var count ($count + 1) endwhile show vlan
This is useful in creating a 100 VLANs should the IP address used be uniform to (count), but this is rarely the case, and the method couldn't be used to supplement a Name that could be anything, and a tag number that also wouldn't be uniform to a count.

The information I need to enter though I already have in a spreadsheet that I used to create a schema, so I can extrapolate any of that information in any form, but I need to be able to add it on mass to make the config generator of any use, as it could be hundreds of different lines.

Do yo know anyway to do that with anything that exists within Extreme or any tool that might be good at the job?

Many thanks

GTM-P2G8KFN