-
Notifications
You must be signed in to change notification settings - Fork 25
Description
I'm registering a module change subscription with the flag enabled=True and the initial callback doesn't always provide the change information that is expected.
Assuming that the sysrepo operational datastore has this contents
{
"ietf-interfaces:interfaces": {
"interface": [
{
"name": "eno0",
"type": "iana-if-type:ethernetCsmacd",
"enabled": "true"
}
]
}
}then this code reproduces the issue:
import sysrepo
xpaths = (
"/ietf-interfaces:interfaces/interface[name='eno0']/name", # OK
"/ietf-interfaces:interfaces/interface[name='eno0']/type", # OK
"/ietf-interfaces:interfaces/interface[name='eno0']/enabled", # OK
"/ietf-interfaces:interfaces/interface[type='iana-if-type:ethernetCsmacd']/name", # ERROR
"/ietf-interfaces:interfaces/interface[type='iana-if-type:ethernetCsmacd']/type", # OK
"/ietf-interfaces:interfaces/interface[type='iana-if-type:ethernetCsmacd']/enabled", # ERROR
"/ietf-interfaces:interfaces/interface[enabled='true']/name", # ERROR
"/ietf-interfaces:interfaces/interface[enabled='true']/type", # ERROR
"/ietf-interfaces:interfaces/interface[enabled='true']/enabled", # OK
)
connection = sysrepo.SysrepoConnection()
for xpath in xpaths:
global n_changes
session = connection .start_session("operational")
session.subscribe_module_change(
"ietf-interfaces",
xpath,
change_cb,
passive=True,
done_only=True,
enabled=True,
)
print(f"{xpath}: {n_changes != 0}")It expects that each subscription is executed during subscription already (due to the enabled=True flag) and prints the number of changes the callback found. Some work and some don't - see the # OK' and '# ERROR' comments behind the xpaths. Looks like it works only when filtering the list key (i.e. name`) or when the filtered element is part of the result anyway, but not when I filter the list items for property A but query property B.
This works fine when using the libyang API directly, so I assume it has something to do with how the changes are collected as the filter string itself is passed as-is to the C API.