03-11-2022 03:53 AM
In a package in python I have to clear "ip sla" configurations on devices that has been configured using SNMP. This configurations does not compare in the "show running-config" output and NSO does not has evidence of them. So usual configuration commands in configuration has no effect on those hidden configurations.
I see that via NSO CLI I can use these commands to show and delete the hidden configuration:
request devices device TIR-Cisco4221 live-status exec any args show\ ip\ sla\ configuration\ 6001
request devices device TIR-Cisco4221 config EXEC exec args no\ ip\ sla\ 6001
How can I reproduce those command in python version 3 code?
Solved! Go to Solution.
04-01-2022 12:59 PM
Hello,
You can use ncs_pycli https://github.com/NSO-developer/ncs_pycli https://pypi.org/project/ncs-pycli/ that can help you and you will save a lot of time. You can use tab for autocompletion.
Concerning your example , here the code for
request devices device TIR-Cisco4221 live-status exec any args show\ ip\ sla\ configuration\ 6001
request devices device TIR-Cisco4221 config EXEC exec args no\ ip\ sla\ 6001
device_name = "PE10" #GET The devie from ncs.application import get_device device = get_device(root,device_name) #### You can also get the device using root.devices device = root.devices.device[device_name] ####### Executing command show ip sla configuration 6001 using ANY ############ exec_input = device.live_status.ios_stats__exec.any.get_input() exec_input.args.create("show ip sla configuration 6001") output= device.live_status.ios_stats__exec.any(exec_input) ##To get the result of the command print(output.result) ####### Executing command show ip sla configuration 6001 using SHOW ############ exec_show = device.live_status.ios_stats__exec.show.get_input() exec_show.args.create("ip sla configuration 6001") output_show= device.live_status.ios_stats__exec.show(exec_show) ##To get the result of the command print(output_show.result) ######## Executing command no ip sla 11 using exec #######" exec_conf_input = device.config.ios__EXEC.exec.get_input() exec_conf_input.args.create("no ip sla 11") output_exec= device.config.ios__EXEC.exec(exec_conf_input) print(output_exec.result)
03-11-2022 04:12 AM
How can I reproduce those command in python version 3 code?
if i understand correcly you looking to use below cmmand : (with python ?)
show ip sla
no ip sla
03-11-2022 04:16 AM
Yes.
Mind that the second command is issued in config mode on the device CLI. Usinc the NSO CLIS it is used the command.
Thanks
04-01-2022 12:59 PM
Hello,
You can use ncs_pycli https://github.com/NSO-developer/ncs_pycli https://pypi.org/project/ncs-pycli/ that can help you and you will save a lot of time. You can use tab for autocompletion.
Concerning your example , here the code for
request devices device TIR-Cisco4221 live-status exec any args show\ ip\ sla\ configuration\ 6001
request devices device TIR-Cisco4221 config EXEC exec args no\ ip\ sla\ 6001
device_name = "PE10" #GET The devie from ncs.application import get_device device = get_device(root,device_name) #### You can also get the device using root.devices device = root.devices.device[device_name] ####### Executing command show ip sla configuration 6001 using ANY ############ exec_input = device.live_status.ios_stats__exec.any.get_input() exec_input.args.create("show ip sla configuration 6001") output= device.live_status.ios_stats__exec.any(exec_input) ##To get the result of the command print(output.result) ####### Executing command show ip sla configuration 6001 using SHOW ############ exec_show = device.live_status.ios_stats__exec.show.get_input() exec_show.args.create("ip sla configuration 6001") output_show= device.live_status.ios_stats__exec.show(exec_show) ##To get the result of the command print(output_show.result) ######## Executing command no ip sla 11 using exec #######" exec_conf_input = device.config.ios__EXEC.exec.get_input() exec_conf_input.args.create("no ip sla 11") output_exec= device.config.ios__EXEC.exec(exec_conf_input) print(output_exec.result)
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide