Appendix A: Custom CLI commands (pySROS)

Custom Python applications can be written to run on SR OS. One example of an application is a custom CLI command. The following sample configuration shows how to configure a Python script get_all_interfaces.py to display all VPRN interfaces and the in/out packets in one output. For sample Python scripts, visit the Nokia pySROS GitHub repository.

For more information about pySROS, see the 7450 ESS, 7750 SR, 7950 XRS, and VSR System Management Guide and the pySROS API documentation.

Configuring a python script

configure python python-script "get_all_interfaces" { admin-state enable }
configure python python-script "get_all_interfaces" { urls ["cf3:\get_all_interfaces.py"] }
configure python python-script "get_all_interfaces" { version python3 }

configure system management-interface cli md-cli environment command-alias { alias "all-interfaces" }
configure system management-interface cli md-cli environment command-alias { alias "all-interfaces" admin-state enable }
configure system management-interface cli md-cli environment command-alias { alias "all-interfaces" description "show all VPRN interfaces" }
configure system management-interface cli md-cli environment command-alias { alias "all-interfaces" python-script "get_all_interfaces" }
configure system management-interface cli md-cli environment command-alias { alias "all-interfaces" mount-point "/show" }

# show all-interfaces 
====================================================================================================
All Interfaces on all VPRNs
====================================================================================================
VPRN            Interface Name  IPv4 Address    Oper Status     Port:VLAN       In-Pkts    Out-Pkts  
----------------------------------------------------------------------------------------------------
100             VPRN100         99.99.99.75     up              loopback        0          0         
150             To_Ixia         150.150.150.6   up              1/1/30:150      0          0         
150             VPRN150         150.150.150.75  up              loopback        0          0         
====================================================================================================