Skip to content

Commit ffff9fc

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 ffff9fc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sysrepo/session.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ def subscribe_module_change(
338338
passive: bool = False,
339339
done_only: bool = False,
340340
enabled: bool = False,
341+
update: bool = False,
341342
filter_origin: bool = False,
342343
private_data: Any = None,
343344
asyncio_register: bool = False,
@@ -372,6 +373,8 @@ def subscribe_module_change(
372373
:arg enabled:
373374
The subscriber wants to be notified about the current configuration
374375
at the moment of subscribing.
376+
:arg update:
377+
The subscriber wants to be called before the configuration is applied.
375378
:arg filter_origin:
376379
Filter events on the originator side to unburden the subscriber, but
377380
results in 0 value for filtered-out changes in the subscriber infos.
@@ -410,6 +413,7 @@ def subscribe_module_change(
410413
passive=passive,
411414
done_only=done_only,
412415
enabled=enabled,
416+
update=update,
413417
filter_origin=filter_origin,
414418
)
415419

@@ -464,6 +468,7 @@ def subscribe_module_change_unsafe(
464468
passive: bool = False,
465469
done_only: bool = False,
466470
enabled: bool = False,
471+
update: bool = False,
467472
filter_origin: bool = False,
468473
private_data: Any = None,
469474
asyncio_register: bool = False,
@@ -499,6 +504,8 @@ def subscribe_module_change_unsafe(
499504
:arg enabled:
500505
The subscriber wants to be notified about the current configuration
501506
at the moment of subscribing.
507+
:arg update:
508+
The subscriber wants to be called before the configuration is applied.
502509
:arg filter_origin:
503510
Filter events on the originator side to unburden the subscriber, but
504511
results in 0 value for filtered-out changes in the subscriber infos.
@@ -531,6 +538,7 @@ def subscribe_module_change_unsafe(
531538
passive=passive,
532539
done_only=done_only,
533540
enabled=enabled,
541+
update=update,
534542
filter_origin=filter_origin,
535543
)
536544
check_call(
@@ -1659,6 +1667,7 @@ def _subscribe_flags(
16591667
enabled=False,
16601668
oper_merge=False,
16611669
filter_origin=False,
1670+
update=False,
16621671
):
16631672
flags = 0
16641673
if no_thread:
@@ -1669,6 +1678,8 @@ def _subscribe_flags(
16691678
flags |= lib.SR_SUBSCR_DONE_ONLY
16701679
if enabled:
16711680
flags |= lib.SR_SUBSCR_ENABLED
1681+
if update:
1682+
flags |= lib.SR_SUBSCR_UPDATE
16721683
if oper_merge:
16731684
flags |= lib.SR_SUBSCR_OPER_MERGE
16741685
if filter_origin:

0 commit comments

Comments
 (0)