Google Spreadsheet Driven Arista eAPI Automation Demo
This script realizes the concept of "SDN - Spreadsheet Defined Network" (c) Anthony P. Kuzub, CBC/ Radio Canada
The script uses Google Drive and Spreadsheet APIs to get the information that is propagated into the Arista switches using eAPI. It was written to solve one particular use case, but can be used as a demo of using a Google spreadsheet as a data source for switch configuration. It will also read some information from the switch and populate a separate tab of the spreadsheet.
The functionality currently realised:
Reading the vlan list and vlan names from the spreadsheet and creating them in the switch
Reading interface descriptions and access vlans from the spreadsheet and setting them in the switch (only one vlan per interface can be set via the script, trunk ports are not affected)
Reading interfaces status and the mac address table from the switch and writing the data to the spreadsheet
The Google spreadsheet needs to follow the exact format. A sample spreadsheet can be found HERE Please use "save as copy" to be able to edit.
The demo spreadsheet was used to drive a vEOS instance, therefore it is only limited to 12 ports.
More ports and vlans can be added to the spreadsheet.
Ports of >10GbE and multi-lane ports are also supported (e.g. Ethernet7/3).
User needs to supply the Google API json access token. Example token is provided, however it is a dummy file that will not give you access to any Google API resources. You have to provide your own API token. Follow the first step from this article as a how-to: LINK
Be aware, that the free tier of Google API has a usage quota. The limits can be found HERE. The script will cathch the API quota exhaustion error, if occures, will wait 60 seconds and will try to reconnect before repeating the tasks.
User also needs to suply a config file that has an exact name of the spreadsheet in your Google drive, IP address or a fully qualified domain name (FQDN) of the switch, and login and pass to the switch.
Example config file is provided.
spreadsheet:Switches ip:172.16.158.100 username:admin password:admin
pyeapi gspread oauth2client colorlog
Clone the repo.
git clone https://github.com/ievgen-kostiukevych/Google-Spreadsheet-Driven-Arista-eAPI-Automation-Demo.git
Use the package manager pip to install dependencies.
pip install requirements
-h for how-to use.
usage: automation.py [-h] [-vL] [-iD] [-iS] [-iV] [-c] config api [time] positional arguments: config provide the config file api provide the API json file time amount of seconds to wait before repeating tasks, default is 10 seconds optional arguments: -h, --help show this help message and exit -vL, --vlans_list read vlans from the spreadsheet and create in the switch -iD, --interfaces_description read interfaces descriptions from the spreadsheet and update in the switch -iS, --interfaces_status read interfaces status from the switch and update in the spreadsheet -iV, --interfaces_vlans read interfaces vlans from the spreadsheet and update in the switch -c, --continious repeat activated tasks after 10 seconds (default, unless time is specified)
python automation.py -vL -iD -iS -iV -c demo_config.cfg switch-automation-api.json 30
Script will execute all tasks every 30 seconds using
switch-automation-api.json Google API access token and
demo_config.cfg config source file
python automation.py -iD demo_config.cfg switch-automation-api.json
Script will update interfaces descriptions once and will exit.
python automation.py -iV -c demo_config.cfg switch-automation-api.json
Script will update interfaces access vlans every 10 seconds (default timeout value).
To stop the continious execution use keyboard interrupt
CTRL/CMD + C
This project is a demo, it is not heavily maintained.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- The first public release
- Migrate from depricated
Thank you to Robert Welch (Arista Networks) and Anthony P. Kuzub (CBC/Radio Cannada) for support and inspiration
Author – Ievgen Kostiukevych, European Broadcasting Union, Technology and Innovation
The software is provided "As is", WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
Use at your own risk.
Lab testing is ALWAYS recomended before any use for production network.