cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
540
Views
10
Helpful
3
Replies

Deletion of hidden configurazioni on IOS device (live-status)

Fantolino
Level 1
Level 1

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?

1 Accepted Solution

Accepted Solutions

Nabsch
Spotlight
Spotlight

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)

View solution in original post

3 Replies 3

balaji.bandi
Hall of Fame
Hall of Fame
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

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

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

Nabsch
Spotlight
Spotlight

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)