Skip to content

Commit 28ee073

Browse files
committed
session: add subscription update option
Sysrepo allows to subscribe to configuration update before they are applied to the datastore so it is possible to edit them. Add the update flag to the subscribe_module_change and the subscribe_module_change_unsafe functions. Signed-off-by: Jeremie Leska <[email protected]>
1 parent 7f5c9a4 commit 28ee073

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sysrepo/session.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ def get_ly_ctx(self) -> libyang.Context:
327327
to reject changes.
328328
"""
329329

330+
# pylint: disable=too-many-arguments
330331
def subscribe_module_change(
331332
self,
332333
module: str,
@@ -338,6 +339,7 @@ def subscribe_module_change(
338339
passive: bool = False,
339340
done_only: bool = False,
340341
enabled: bool = False,
342+
update: bool = False,
341343
filter_origin: bool = False,
342344
private_data: Any = None,
343345
asyncio_register: bool = False,
@@ -372,6 +374,8 @@ def subscribe_module_change(
372374
:arg enabled:
373375
The subscriber wants to be notified about the current configuration
374376
at the moment of subscribing.
377+
:arg update:
378+
The subscriber wants to be called before the configuration is applied.
375379
:arg filter_origin:
376380
Filter events on the originator side to unburden the subscriber, but
377381
results in 0 value for filtered-out changes in the subscriber infos.
@@ -410,6 +414,7 @@ def subscribe_module_change(
410414
passive=passive,
411415
done_only=done_only,
412416
enabled=enabled,
417+
update=update,
413418
filter_origin=filter_origin,
414419
)
415420

@@ -464,6 +469,7 @@ def subscribe_module_change_unsafe(
464469
passive: bool = False,
465470
done_only: bool = False,
466471
enabled: bool = False,
472+
update: bool = False,
467473
filter_origin: bool = False,
468474
private_data: Any = None,
469475
asyncio_register: bool = False,
@@ -499,6 +505,8 @@ def subscribe_module_change_unsafe(
499505
:arg enabled:
500506
The subscriber wants to be notified about the current configuration
501507
at the moment of subscribing.
508+
:arg update:
509+
The subscriber wants to be called before the configuration is applied.
502510
:arg filter_origin:
503511
Filter events on the originator side to unburden the subscriber, but
504512
results in 0 value for filtered-out changes in the subscriber infos.
@@ -531,6 +539,7 @@ def subscribe_module_change_unsafe(
531539
passive=passive,
532540
done_only=done_only,
533541
enabled=enabled,
542+
update=update,
534543
filter_origin=filter_origin,
535544
)
536545
check_call(
@@ -1659,6 +1668,7 @@ def _subscribe_flags(
16591668
enabled=False,
16601669
oper_merge=False,
16611670
filter_origin=False,
1671+
update=False,
16621672
):
16631673
flags = 0
16641674
if no_thread:
@@ -1669,6 +1679,8 @@ def _subscribe_flags(
16691679
flags |= lib.SR_SUBSCR_DONE_ONLY
16701680
if enabled:
16711681
flags |= lib.SR_SUBSCR_ENABLED
1682+
if update:
1683+
flags |= lib.SR_SUBSCR_UPDATE
16721684
if oper_merge:
16731685
flags |= lib.SR_SUBSCR_OPER_MERGE
16741686
if filter_origin:

0 commit comments

Comments
 (0)