This project shows an efficent and optimized way to retrieve data from network devices with checking access process by leveraging the Validate/Monitor access to network devices with the integration of Genie/pyATS, WebEx Messenger and Syslog server use case relating with the project Check_Access.
Suppose we have 100 network devices and we have access only to 50 of them, the retriving data process is applied only to these 50 devices witch conduct to save the time with generating logs to Syslog server for maintenance purposes besides the report sent to WebEx Messenger Space.
In summary, this project aims to :
We focus here only on the result for the Syslog server notifications and the package installation and requirements, the others details like configuration files modification, topology and the WebEx Messenger result could be found at Check_Access repository related to Validate/Monitor access to network devices with the integration of Genie/pyATS, WebEx Messenger and Syslog server use case as it is a part of this project.
For testing purposes, the topology used here is the same as that used in the Check_Access project
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/Retrieve_Data_Application_Case.git
cd Retrieve_Data_Application_Case
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
pip3 install prettytable
pip3 install python-dotenv
The command show ip interface brief is used here for testing the data retrieving process
Here we run retrieve_data_application_case.py script from the Admin host:
(Retrieve_Data_Application_Case) [mehdi@Retrieve_Data_Application_Case]$python retrieve_data_application_case.py+--------------------+ | Access Check | +--------+-----------+ | Device | Status | +--------+-----------+ | R1 | Access Ok | | R2 | Access Ok | | R3 | Access Ok | +--------+-----------+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Result for R1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 {'interface': {'FastEthernet0/0': {'interface_is_ok': 'YES', 'ip_address': '192.168.1.251', 'method': 'NVRAM', 'protocol': 'up', 'status': 'up'}, 'FastEthernet0/1': {'interface_is_ok': 'YES', 'ip_address': 'unassigned', 'method': 'NVRAM', 'protocol': 'down', 'status': 'administratively down'}}} 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Result for R2 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 {'interface': {'FastEthernet0/0': {'interface_is_ok': 'YES', 'ip_address': '192.168.1.252', 'method': 'NVRAM', 'protocol': 'up', 'status': 'up'}, 'FastEthernet0/1': {'interface_is_ok': 'YES', 'ip_address': 'unassigned', 'method': 'NVRAM', 'protocol': 'down', 'status': 'administratively down'}}} 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Result for R3 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 {'interface': {'FastEthernet0/0': {'interface_is_ok': 'YES', 'ip_address': '192.168.1.253', 'method': 'NVRAM', 'protocol': 'up', 'status': 'up'}, 'FastEthernet0/1': {'interface_is_ok': 'YES', 'ip_address': 'unassigned', 'method': 'NVRAM', 'protocol': 'down', 'status': 'administratively down'}}} 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Here the result sent to the Syslog Server:
As show, the result indicate a successful in the access and the retrieving data processes for the three routers.
Now we will deactivate the management interface of the router R2
Now we run the retrieve_data_application_case.py script from the Admin host:
(Retrieve_Data_Application_Case [mehdi@Retrieve_Data_Application_Case]$ python retrieve_data_application_case.py+--------------------+ | Access Check | +--------+-----------+ | Device | Status | +--------+-----------+ | R1 | Access Ok | | R2 | No Access | | R3 | Access Ok | +--------+-----------+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Result for R1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 {'interface': {'FastEthernet0/0': {'interface_is_ok': 'YES', 'ip_address': '192.168.1.251', 'method': 'NVRAM', 'protocol': 'up', 'status': 'up'}, 'FastEthernet0/1': {'interface_is_ok': 'YES', 'ip_address': 'unassigned', 'method': 'NVRAM', 'protocol': 'down', 'status': 'administratively down'}}} 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 NO Retrieving Data Process for R2 : Refer to Result.txt for more infos 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Result for R3 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 {'interface': {'FastEthernet0/0': {'interface_is_ok': 'YES', 'ip_address': '192.168.1.253', 'method': 'NVRAM', 'protocol': 'up', 'status': 'up'}, 'FastEthernet0/1': {'interface_is_ok': 'YES', 'ip_address': 'unassigned', 'method': 'NVRAM', 'protocol': 'down', 'status': 'administratively down'}}} 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
As expected, the Syslog server received the logs:
From the results from the console and the Syslog server, we observe that there is no data retrieved from the router R2 and this process was escaped because there was no access to it which conducted to save the time.
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.
This use case shows an efficent and optimized way to retrieve data from network devices with checking access process by leveraging the Validate/Monitor access to network devices with the integration of Genie/pyATS, WebEx Messenger and Syslog server use case relating with the project Check_Access.
Suppose we have 100 network devices and we have access only to 50 of them, the retriving data process is applied only to these 50 devices witch conduct to save the time with generating logs to Syslog server for maintenance purposes besides the report sent to WebEx Messenger Space.
In summary, this project aims to :
We focus here only on the result for the Syslog server notifications and the package installation and requirements, the others details like configuration files modification, topology and the WebEx Messenger result could be found at Check_Access repository related to Validate/Monitor access to network devices with the integration of Genie/pyATS, WebEx Messenger and Syslog server use case as it is a part of this project.
Cisco DevNet Sandbox Cisco Modeling Labs
How pyATS can be used as an end-to-end DevOps automation ecosystem: Accelerating your DevOps with pyATS
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community