https://github.com/hmntsharma/asynxpct
A combination of python subprocess, asyncio and pexpect libraries for network automation
https://github.com/hmntsharma/asynxpct
asyncio network-automation network-programming pexpect python
Last synced: 12 months ago
JSON representation
A combination of python subprocess, asyncio and pexpect libraries for network automation
- Host: GitHub
- URL: https://github.com/hmntsharma/asynxpct
- Owner: hmntsharma
- License: mit
- Created: 2023-03-17T16:11:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-18T15:59:18.000Z (over 3 years ago)
- Last Synced: 2025-02-25T23:32:24.346Z (over 1 year ago)
- Topics: asyncio, network-automation, network-programming, pexpect, python
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# asynxpct
A combination of python subprocess, asyncio and pexpect libraries for network automation
## Introduction
This script demonstrates the cooperation between the Python packages pexpect, asyncio and subprocess for a certain network topology.
Modify before using according to your topology
## Summary
### Synchronous module
```ruby
(vntdvops) lab@netdevops:~/github/asynxpct$ python
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xrshow
>>> xrshow.xrshow("pe1", ["show version", "show platform"])
---[ XRSHOW START ]---[ pe1 ]---[ show version ]---
Fri Mar 17 16:30:05.246 UTC
Cisco IOS XR Software, Version 7.5.2
Copyright (c) 2013-2022 by Cisco Systems, Inc.
Build Information:
Built By : ingunawa
Built On : Tue Apr 26 18:04:31 PDT 2022
Built Host : iox-ucs-061
Workspace : /auto/srcarchive14/prod/7.5.2/xrv9k/ws
Version : 7.5.2
Location : /opt/cisco/XR/packages/
Label : 7.5.2
cisco IOS-XRv 9000 () processor
System uptime is 1 day 17 hours 25 minutes
---[ XRSHOW END ]---[ pe1 ]---[ show version ]---
---[ XRSHOW START ]---[ pe1 ]---[ show platform ]---
Fri Mar 17 16:30:05.375 UTC
Node Type State Config state
--------------------------------------------------------------------------------
0/0/CPU0 R-IOSXRV9000-LC-C IOS XR RUN NSHUT
0/RP0/CPU0 R-IOSXRV9000-RP-C(Active) IOS XR RUN NSHUT
---[ XRSHOW END ]---[ pe1 ]---[ show platform ]---
>>> exit()
(vntdvops) lab@netdevops:~/github/asynxpct$
```
### Used by synchronous cli script
```ruby
(vntdvops) lab@netdevops:~/github/asynxpct$ ./xrshowcli -n pe1 -c "show version" "show platform"
---[ XRSHOW START ]---[ pe1 ]---[ show version ]---
Fri Mar 17 16:28:58.594 UTC
Cisco IOS XR Software, Version 7.5.2
Copyright (c) 2013-2022 by Cisco Systems, Inc.
Build Information:
Built By : ingunawa
Built On : Tue Apr 26 18:04:31 PDT 2022
Built Host : iox-ucs-061
Workspace : /auto/srcarchive14/prod/7.5.2/xrv9k/ws
Version : 7.5.2
Location : /opt/cisco/XR/packages/
Label : 7.5.2
cisco IOS-XRv 9000 () processor
System uptime is 1 day 17 hours 24 minutes
---[ XRSHOW END ]---[ pe1 ]---[ show version ]---
---[ XRSHOW START ]---[ pe1 ]---[ show platform ]---
Fri Mar 17 16:28:58.716 UTC
Node Type State Config state
--------------------------------------------------------------------------------
0/0/CPU0 R-IOSXRV9000-LC-C IOS XR RUN NSHUT
0/RP0/CPU0 R-IOSXRV9000-RP-C(Active) IOS XR RUN NSHUT
---[ XRSHOW END ]---[ pe1 ]---[ show platform ]---
(vntdvops) lab@netdevops:~/github/asynxpct$
```
### Finally the Asynchronous Script to use the cli script
```ruby
./asyncxpct.py
```
Kindly check the results folder for example of tests.