cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
566
Views
0
Helpful
4
Replies
yale.prince
Beginner

Purge alarms via RESTCONF

Hi all,

 

I wish to the following via the RESTCONF, i can do it via python maapi and the ncs_cli

ncs_cli - 

alarms alarm-list alarm ncs package-load-failure /packages/package[name='tailf-hcc'] "" purge

mappi

root.alarms.alarm_list.alarm['ncs', 'al:package-load-failure', "/ncs:packages/ncs:package[ncs:name='tailf-hcc']", ""].purge()

 

could some one please help translate either of the above in the a RESTCONF request

 

Thanks

Regards

Yale

 

 

4 REPLIES 4
gmuloche
Cisco Employee

Hello,

 

this is how I would address it to figure out the action restconf path "easily" with `| display restconf`. Sadly we cannot used this filter when trying to execute the action.

 

(I am using 5.6 here):

admin@ncs# show alarms alarm-list alarm ncs package-load-failure /packages/package[name='resource-manager'] "" | display restconf
/restconf/data/tailf-ncs-alarms:alarms/alarm-list/alarm=ncs,al%3Apackage-load-failure,%2Fncs%3Apackages%2Fncs%3Apackage%5Bncs%3Aname%3D%27resource-manager%27%5D,""/is-cleared true
[...]

and so the POST RESTCONF call would be:

/restconf/data/tailf-ncs-alarms:alarms/alarm-list/alarm=ncs,al%3Apackage-load-failure,%2Fncs%3Apackages%2Fncs%3Apackage%5Bncs%3Aname%3D%27resource-manager%27%5D,""/purge

Now you have also this very cool package you can install in your development environment that would give you the same answer: https://gitlab.com/nso-developer/rest-api-explorer (make sure to tick the option to display the module names)

Screenshot 2021-11-18 at 14.53.38.png

ramkraja
Cisco Employee

What works now is this:

restconf/operations/tailf-ncs-alarms:alarms/alarm-list/alarm=ncs,package-load-failure,%2Fpackages%2Fpackage%5Bname%3D%27tailf-hcc%27%5D,/purge

This is the url-encoded RESTCONF path to the 'purge' action for that alarm.

Note the last comma - it encodes the last key for the alarm list (ie, the empty string).

Also note that the 'package-load-failure' and the package itself (/packages/package[name='tailf-hcc']) are not namespace qualified. Qualifying them results in an error as of now.

perander
Cisco Employee

Something like the following:

curl -X POST --data '<input></input>' \
"http://localhost:8080/restconf/data/tailf-ncs-alarms:alarms/alarm-list/alarm=ncs,al:package-load-failure,/ncs:packages/ncs:package[ncs:name='tailf-hcc'],/purge"

Note that the following requirements with the alarm keys as in your other
question [0] might apply: urlencode and maybe no prefixes in "managed-object".

[0] https://community.cisco.com/t5/nso-developer-hub-discussions/maapi-to-restconf/m-p/4504186

Hallo all, 
I have the same issue on nso v5.6 
I tried the sollutions you gave to Yale but none of the is working. 
Is there anybody that test those solutions and got succesfull response  ?

 

Is there any other solution ?