sysrepo
2.12.0
YANG-based system repository for all-around configuration management.
|
Functions | |
int | sr_dup_changes_iter (sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter) |
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in module-change callbacks. It can be used even outside the callback. More... | |
void | sr_free_change_iter (sr_change_iter_t *iter) |
Frees sr_change_iter_t iterator and all memory allocated within it. More... | |
struct lyd_node * | sr_get_change_diff (sr_session_ctx_t *session) |
Get the changes directly in the form of a diff in module-change callbacks. It cannot be used outside the callback. More... | |
int | sr_get_change_next (sr_session_ctx_t *session, sr_change_iter_t *iter, sr_change_oper_t *operation, sr_val_t **old_value, sr_val_t **new_value) |
Return the next change from the provided iterator created by sr_get_changes_iter call. Data are represented as sr_val_t structures. More... | |
int | sr_get_change_tree_next (sr_session_ctx_t *session, sr_change_iter_t *iter, sr_change_oper_t *operation, const struct lyd_node **node, const char **prev_value, const char **prev_list, int *prev_dflt) |
Returns the next change from the provided iterator created by sr_get_changes_iter call. Data are represented as libyang subtrees. More... | |
int | sr_get_changes_iter (sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter) |
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in module-change callbacks. It cannot be used outside the callback. More... | |
int | sr_module_change_get_order (sr_conn_ctx_t *conn, const char *module_name, sr_datastore_t ds, uint32_t *priority) |
Get the current global priority of change subscriptions of a module. More... | |
int | sr_module_change_set_order (sr_conn_ctx_t *conn, const char *module_name, sr_datastore_t ds, uint32_t priority) |
Change the global priority of modules being notified about their changes. The default priority of every module is 0 and modules with the same priority have their callbacks notified simultaneously. More... | |
int | sr_module_change_sub_get_info (sr_subscription_ctx_t *subscription, uint32_t sub_id, const char **module_name, sr_datastore_t *ds, const char **xpath, uint32_t *filtered_out) |
Get information about an existing change subscription. More... | |
int | sr_module_change_sub_modify_xpath (sr_subscription_ctx_t *subscription, uint32_t sub_id, const char *xpath) |
Modify an existing change subscription by changing its XPath filter. More... | |
int | sr_module_change_subscribe (sr_session_ctx_t *session, const char *module_name, const char *xpath, sr_module_change_cb callback, void *private_data, uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription) |
Subscribe for changes made in the specified module. More... | |
enum | sr_event_t { SR_EV_UPDATE, SR_EV_CHANGE, SR_EV_DONE, SR_EV_ABORT, SR_EV_ENABLED, SR_EV_RPC } |
Type of the event that has occurred (passed to application callbacks). More... | |
enum | sr_change_oper_t { SR_OP_CREATED, SR_OP_MODIFIED, SR_OP_DELETED, SR_OP_MOVED } |
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next. More... | |
typedef struct sr_change_iter_s | sr_change_iter_t |
Iterator used for retrieval of a changeset using sr_get_changes_iter call. More... | |
typedef int(* | sr_module_change_cb )(sr_session_ctx_t *session, uint32_t sub_id, const char *module_name, const char *xpath, sr_event_t event, uint32_t request_id, void *private_data) |
Callback to be called on the event of changing datastore content of the specified module. More... | |
typedef struct sr_change_iter_s sr_change_iter_t |
Iterator used for retrieval of a changeset using sr_get_changes_iter call.
Definition at line 525 of file sysrepo_types.h.
typedef int(* sr_module_change_cb)(sr_session_ctx_t *session, uint32_t sub_id, const char *module_name, const char *xpath, sr_event_t event, uint32_t request_id, void *private_data) |
Callback to be called on the event of changing datastore content of the specified module.
[in] | session | Implicit session (do not stop) with information about the changed data (retrieved by sr_get_changes_iter) and the event originator session IDs. |
[in] | sub_id | Subscription ID. |
[in] | module_name | Name of the module where the change has occurred. |
[in] | xpath | XPath used when subscribing, NULL if the whole module was subscribed to. |
[in] | event | Type of the callback event that has occurred. |
[in] | request_id | Request ID unique for the specific module_name . Connected events for one request (SR_EV_CHANGE and SR_EV_DONE, for example) have the same request ID. |
[in] | private_data | Private context opaque to sysrepo, as passed to sr_module_change_subscribe call. |
Definition at line 543 of file sysrepo_types.h.
enum sr_change_oper_t |
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next.
Definition at line 515 of file sysrepo_types.h.
enum sr_event_t |
Type of the event that has occurred (passed to application callbacks).
Enumerator | |
---|---|
SR_EV_UPDATE |
Occurs before any other events and the subscriber can update the apply-changes diff. It is performed by calling |
SR_EV_CHANGE |
Occurs just before the changes are committed to the datastore, the subscriber is supposed to verify that the changes are valid and can be applied and prepare all resources required for the changes. The subscriber can still deny the changes in this phase by returning an error from the callback. |
SR_EV_DONE |
Occurs just after the changes have been successfully committed to the datastore, the subscriber can apply the changes now, but it cannot deny the changes in this phase anymore (any returned errors are just logged and ignored). |
SR_EV_ABORT |
Occurs in case that the commit transaction has failed because one of the verifiers has denied the change (returned an error). The subscriber is supposed to return the managed application to the state before the commit. Any returned errors are just logged and ignored. This event is also generated for RPC subscriptions when a later callback has failed and this one has already successfully processed SR_EV_RPC. The callback that failed will never get this event! |
SR_EV_ENABLED |
Occurs for subscriptions with the flag SR_SUBSCR_ENABLED and is normally followed by SR_EV_DONE. It can fail and will also be triggered even when there is no startup configuration (which is different from the SR_EV_CHANGE event). Also note that the callback on this event cannot return SR_ERR_CALLBACK_SHELVE. |
SR_EV_RPC |
Occurs for a standard RPC execution. If a later callback fails, SR_EV_ABORT is generated. |
Definition at line 488 of file sysrepo_types.h.
int sr_dup_changes_iter | ( | sr_session_ctx_t * | session, |
const char * | xpath, | ||
sr_change_iter_t ** | iter | ||
) |
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in module-change callbacks. It can be used even outside the callback.
[in] | session | Implicit session provided in the callbacks (sr_module_change_cb). Will not work with other sessions. |
[in] | xpath | XPath selecting the changes. Note that you must select all the changes specifically, not just subtrees (to get a full change subtree //. can be appended to the XPath)! Also note that if you use an XPath that selects more changes than subscribed to, you may actually get them because all the changes of a module are available in every callback! |
[out] | iter | Iterator context that can be used to retrieve individual changes using sr_get_change_next calls. Allocated by the function, should be freed with sr_free_change_iter. |
void sr_free_change_iter | ( | sr_change_iter_t * | iter | ) |
Frees sr_change_iter_t iterator and all memory allocated within it.
[in] | iter | Iterator to be freed. |
struct lyd_node* sr_get_change_diff | ( | sr_session_ctx_t * | session | ) |
Get the changes directly in the form of a diff in module-change callbacks. It cannot be used outside the callback.
[in] | session | Implicit session provided in the callbacks (sr_module_change_cb). Will not work with other sessions. |
int sr_get_change_next | ( | sr_session_ctx_t * | session, |
sr_change_iter_t * | iter, | ||
sr_change_oper_t * | operation, | ||
sr_val_t ** | old_value, | ||
sr_val_t ** | new_value | ||
) |
Return the next change from the provided iterator created by sr_get_changes_iter call. Data are represented as sr_val_t structures.
[in] | session | Implicit session provided in the callbacks (sr_module_change_cb). Will not work with other sessions. |
[in,out] | iter | Iterator acquired with sr_get_changes_iter call. |
[out] | operation | Type of the operation made on the returned item. |
[out] | old_value | Old value of the item (the value before the change). NULL in case that the item has been just created (operation SR_OP_CREATED). |
[out] | new_value | New (modified) value of the the item. NULL in case that the item has been just deleted (operation SR_OP_DELETED). |
int sr_get_change_tree_next | ( | sr_session_ctx_t * | session, |
sr_change_iter_t * | iter, | ||
sr_change_oper_t * | operation, | ||
const struct lyd_node ** | node, | ||
const char ** | prev_value, | ||
const char ** | prev_list, | ||
int * | prev_dflt | ||
) |
Returns the next change from the provided iterator created by sr_get_changes_iter call. Data are represented as libyang subtrees.
node
is the created node, for user-ordered lists either prev_value
or prev_list
is always set with meaning similar to SR_OP_MOVED. SR_OP_MODIFIED - node
is the modified node, prev_value
is set to the previous value of the leaf, prev_dflt
is set if the previous leaf value was the default. SR_OP_DELETED - node
is the deleted node. SR_OP_MOVED - node
is the moved (leaf-)list instance, for user-ordered lists either prev_value
(leaf-list) or prev_list
(list) is set to the preceding instance unless the node is the first, when they are set to "" (empty string).[in] | session | Implicit session provided in the callbacks (sr_module_change_cb). Will not work with other sessions. |
[in,out] | iter | Iterator acquired with sr_get_changes_iter call. |
[out] | operation | Type of the operation made on the returned item. |
[out] | node | Affected data node always with all parents, depends on the operation. |
[out] | prev_value | Previous value, depends on the operation, may be NULL. |
[out] | prev_list | Previous list keys predicate ([key1="val1"][key2="val2"]... ), depends on the operation, may be NULL. |
[out] | prev_dflt | Previous value default flag, depends on the operation, may be NULL. |
int sr_get_changes_iter | ( | sr_session_ctx_t * | session, |
const char * | xpath, | ||
sr_change_iter_t ** | iter | ||
) |
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in module-change callbacks. It cannot be used outside the callback.
[in] | session | Implicit session provided in the callbacks (sr_module_change_cb). Will not work with other sessions. |
[in] | xpath | XPath selecting the changes. Note that you must select all the changes specifically, not just subtrees (to get a full change subtree //. can be appended to the XPath)! Also note that if you use an XPath that selects more changes than subscribed to, you may actually get them because all the changes of a module are available in every callback! |
[out] | iter | Iterator context that can be used to retrieve individual changes using sr_get_change_next calls. Allocated by the function, should be freed with sr_free_change_iter. |
int sr_module_change_get_order | ( | sr_conn_ctx_t * | conn, |
const char * | module_name, | ||
sr_datastore_t | ds, | ||
uint32_t * | priority | ||
) |
Get the current global priority of change subscriptions of a module.
Required READ access.
[in] | conn | Connection to use. |
[in] | module_name | Name of the module whose order to get. |
[in] | ds | Affected datastore. |
[out] | priority | Priority of the module. |
int sr_module_change_set_order | ( | sr_conn_ctx_t * | conn, |
const char * | module_name, | ||
sr_datastore_t | ds, | ||
uint32_t | priority | ||
) |
Change the global priority of modules being notified about their changes. The default priority of every module is 0 and modules with the same priority have their callbacks notified simultaneously.
Example callback order for modules A, B, C with A having callbacks with priority 10, 5, and 0, module B with callbacks 5, 4, and 3, and module C with 1, and 0. Simultaneously notified: ``` A10, B5, C1; A5, B4, C0; A0, B3; ``` As soon as a callback fails, its batch of callbacks is the last to be notified. Also note that the callbacks may not actually be executed concurrently in case they are handled by a single subscription (thread).
This order (of running
datastore) is also used when initializing and copying data from startup
to running
on SHM creation.
Required WRITE access.
[in] | conn | Connection to use. |
[in] | module_name | Name of the module whose order to change. |
[in] | ds | Affected datastore. |
[in] | priority | New priority of the module, higher first. |
int sr_module_change_sub_get_info | ( | sr_subscription_ctx_t * | subscription, |
uint32_t | sub_id, | ||
const char ** | module_name, | ||
sr_datastore_t * | ds, | ||
const char ** | xpath, | ||
uint32_t * | filtered_out | ||
) |
Get information about an existing change subscription.
[in] | subscription | Subscription structure to use. |
[in] | sub_id | Subscription ID of the specific subscription. |
[out] | module_name | Optional name of the module whose changes were subscribed. |
[out] | ds | Optional datastore of the subscription. |
[out] | xpath | Optional XPath filter of the subscription. |
[out] | filtered_out | Optional number of filtered-out change events of the subscription. |
int sr_module_change_sub_modify_xpath | ( | sr_subscription_ctx_t * | subscription, |
uint32_t | sub_id, | ||
const char * | xpath | ||
) |
Modify an existing change subscription by changing its XPath filter.
[in] | subscription | Subscription structure to use. |
[in] | sub_id | Subscription ID of the specific subscription to modify. |
[in] | xpath | New XPath filter to use by the subscription. |
int sr_module_change_subscribe | ( | sr_session_ctx_t * | session, |
const char * | module_name, | ||
const char * | xpath, | ||
sr_module_change_cb | callback, | ||
void * | private_data, | ||
uint32_t | priority, | ||
sr_subscr_options_t | opts, | ||
sr_subscription_ctx_t ** | subscription | ||
) |
Subscribe for changes made in the specified module.
The order of callbacks of a single module is determined by their priority
. The order of modules being notified is determined by their priority which can be adjusted by sr_module_change_set_order().
Required WRITE access. If SR_SUBSCR_PASSIVE is set, required READ access.
[in] | session | Session (DS-specific) to use. |
[in] | module_name | Name of the module of interest for change notifications. |
[in] | xpath | Optional XPath further filtering the changes that will be handled by this subscription. |
[in] | callback | Callback to be called when the change in the datastore occurs. |
[in] | private_data | Private context passed to the callback function, opaque to sysrepo. |
[in] | priority | Specifies the order in which the callbacks (within module) will be called, higher first. |
[in] | opts | Options overriding default behavior of the subscription, it is supposed to be a bitwise OR-ed value of any sr_subscr_flag_t flags. |
[in,out] | subscription | Subscription context, zeroed for first subscription, freed by sr_unsubscribe. |