11-17-2021 04:39 AM
hi all i can do this via maapi, but how can i do the same via restconf
import ncs
with ncs.maapi.Maapi() as maapi:
with ncs.maapi.Session(maapi, 'admin', 'system'):
with maapi.start_write_trans() as trans:
root = ncs.maagic.get_root(trans)
print(root.alarms.alarm_list.alarm['ncs', 'al:package-load-failure', "/ncs:packages/ncs:package[ncs:name='tailf-hcc']", ""])
print(root.alarms.alarm_list.alarm['ncs', 'al:package-load-failure', "/ncs:packages/ncs:package[ncs:name='tailf-hcc']", ""].is_cleared)
this get will show me all the https://nso:cisco1234@10.10.1.1:8888/restconf/data/tailf-ncs-alarms:alarms/alarm-list/tailf-ncs-alarms:alarm
but i want to filter on just the single one
eg somthing like
Thanks
Regards
Yale
11-18-2021 05:28 AM - edited 11-18-2021 05:59 AM
You are referencing the list /alarms/alarm-list/alarm which has a multi leaf key,
the values are separated by comma. For further details see
RFC 8040 Section 3.5.3. Encoding Data Resource Identifiers in the Request URI.
+--rw alarms
+--ro alarm-list
+--ro alarm* [device type managed-object specific-problem]
You should be able to get the same results with something like the following
RESTCONF requests (note that there are four, 4, leaf values in the key)
https://nso:cisco1234@10.10.1.1:8888/restconf/data/tailf-ncs-alarms:alarms/alarm-list/alarm=ncs,al:package-load-failure,/ncs:packages/ncs:package[ncs:name='tailf-hcc'],
You probably need to urlencode the values, omitted that here for brevity.
EDIT: A coworker pointed out to me that it might not work to supply
"managed-object" with prefixes, e.g.
/ncs:packages/ncs:package[ncs:name='tailf-hcc']
But instead supplying the value without prefixes might work
/packages/package[name='tailf-hcc']
We filed an issue for it and will investigate this further.
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