Webex Teams :
https://www.webex.com/team-collaboration.html
and to use the Webex APIs :
To get started with Genie/pyATS :
https://pubhub.devnetcloud.com/media/genie-docs/docs/cookbooks/index.html
Here is the topology used to test this project:
GNS3 was used with Cisco routers equipped with IOS images and a Linux machine as admin since the framework Genie/PyATS works only on Linux or Mac OSX. However, you can use the Windows Subsystem for Linux (WSL, as the case used in this project). This allows to test the project even if we do not have recent versions of GNS3 or EVE-NG with IOS-XE which consumes resources (RAM and CPU). However, you can test this project using your own emulator or the DevNet SANDBOX Cisco Modeling Labs (CML). You just need to modify the parameters concerning the information about the devices used in the connex.yml file (IP addresses, users, IOS type, ...). Here is the link for the SANDBOX catalogs, just choose the one from Cisco Modeling Labs : https://devnetsandbox.cisco.com/RM/Topology.
The best practice is to leverage Python Virtual Environments (env). Please follow these steps to clone the Git repository and create and active the virtual environment:
git clone https://github.com/cherifimehdi/Genie_Webex.git
cd Genie_Webex
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
As the packages used are found in requirements.txt file, alternatively, you can install the packages as follows:
pip3 install pyats[full]
pip3 install requests
pip3 install requests-toolbelt
You must create a Webex Teams Space in order to test this project. Please refer to https://developer.webex.com/ to learn more how to use APIs to create Spaces and manage messages.
You must create the Golden_Config folder before running multi_golden_config.py script in order to save the golden configuration in the desired configuration state of the devices.
If you use the golden configuration files provided for each router used in this project (Refer to Golden_Config folder), you need to create RSA Keys to enable SSH. The credentials used could be found in connex.yml file.
Feel free to change the parameters in connex.yml file according to your devices configuration and types (os, ip, credentials,...)
In multi_config_stat.py, I used Disk0 to store the startup-config (golden configuration in desired state), you must change it according to your device configuration. To save it, use the command : copy running-config disk0:startup-config
in each device. The following figure shows the content of Disk0 for R1 router:
Please update the access_token and room_id in multi_config_stat.py according to your setting in Webex Teams.
Before running the test, please ensure that you run the multi_golden_config.py script in order to ensure the golden configuration (Desired configuration) in the folder Golden_Config for comparison purposes.
python3 multi_golden_config.py
The configuration is saved as string dictionary as indicated in the following figure.
Here the flowchart of the project scenario :
Here we run the script multi_config_stat.py
python3 multi_config_stat.py
Here the result in Genie_Webex space
In this case a loopback interface is configured in R2 as follows :
Then we run the script multi_config_stat.py again:
python3 multi_config_stat.py
Here the result sended to Webex Teams space:
Here the content of the file change_R2.txt
The golden configuration restoring process is applied (by exploiting the command configure replace disk0:startup-config force) as indicated in the following figure:
Active Cisco CCAI Instructor and Network Engineering Trainer. Part of Cisco DevNet Class 2020. Cisco DevNet Code Exchange and Automation Exchange Contributor.
I am interesting in all about NetDevOps, Networking programmability and automation. I am a Cisco contents fan.
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community