Skip to content

Commit 587f88c

Browse files
committed
fixup! subscription: return parent node to oper_state callback
1 parent f6de384 commit 587f88c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

sysrepo/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,15 @@ def subscribe_module_change(
372372

373373
self.subscriptions.append(sub)
374374

375-
OperDataCallbackType = Callable[[str, Optional[libyang.DNode], Any], Optional[Dict]]
375+
OperDataCallbackType = Callable[[str, Optional[str], Any], Optional[Dict]]
376376
"""
377377
Callback to be called when the operational data are requested.
378378
379379
:arg xpath:
380380
The XPath requested by a client. Can be None if the client requested for all the
381381
module operational data.
382-
:arg parent:
383-
Pointer to an existing parent of the requested nodes. It is None for top-level
382+
:arg parent_xpath:
383+
XPath to an existing parent of the requested nodes. It is None for top-level
384384
nodes. Caller is supposed to append the requested nodes to this data subtree
385385
and return either the original parent or a top-level node.
386386
:arg private_data:

sysrepo/subscription.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,17 @@ def oper_data_callback(session, sub_id, module, xpath, req_xpath, req_id, parent
367367
else:
368368
extra_info = {}
369369

370-
parent_node = None
370+
parent_xpath = None
371371
if parent[0]:
372372
with session.get_ly_ctx() as ly_ctx:
373-
parent_node = DNode.new(ly_ctx, parent[0])
373+
parent_xpath = DNode.new(ly_ctx, parent[0]).path()
374374

375375
if is_async_func(callback):
376376
task_id = req_id
377377

378378
if task_id not in subscription.tasks:
379379
task = subscription.loop.create_task(
380-
callback(req_xpath, parent_node, private_data, **extra_info)
380+
callback(req_xpath, parent_xpath, private_data, **extra_info)
381381
)
382382
task.add_done_callback(
383383
functools.partial(subscription.task_done, task_id, "oper")
@@ -394,7 +394,7 @@ def oper_data_callback(session, sub_id, module, xpath, req_xpath, req_id, parent
394394
oper_data = task.result()
395395

396396
else:
397-
oper_data = callback(req_xpath, parent_node, private_data, **extra_info)
397+
oper_data = callback(req_xpath, parent_xpath, private_data, **extra_info)
398398

399399
if isinstance(oper_data, dict):
400400
# convert oper_data to a libyang.DNode object

0 commit comments

Comments
 (0)