summaryrefslogtreecommitdiff
path: root/lib/northbound.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2023-10-06 02:58:58 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2024-01-11 15:06:53 +0200
commit76e4eb84dd815ddee7d7e46bb5a2635bfe2501f5 (patch)
treeea6bd2707b0146d203feabcf2c820a0756f1dbfd /lib/northbound.c
parent5d1a31403832a069d1b655bc3410fcd770ad8313 (diff)
mgmtd, lib: implement CREATE_EXCL operation
Currently, there's no difference between CREATE and MODIFY operations. To be compatible with NETCONF/RESTCONF, add new CREATE_EXCL operation that throws an error if the configuration data already exists. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/northbound.c')
-rw-r--r--lib/northbound.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/northbound.c b/lib/northbound.c
index 34f7d4f09a..f7e0d698b3 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -668,6 +668,7 @@ int nb_candidate_edit(struct nb_config *candidate,
struct lyd_node *dnode, *dep_dnode;
char xpath_edit[XPATH_MAXLEN];
char dep_xpath[XPATH_MAXLEN];
+ uint32_t options = 0;
LY_ERR err;
/* Use special notation for leaf-lists (RFC 6020, section 9.13.5). */
@@ -680,9 +681,11 @@ int nb_candidate_edit(struct nb_config *candidate,
switch (operation) {
case NB_OP_CREATE:
case NB_OP_MODIFY:
+ options = LYD_NEW_PATH_UPDATE;
+ fallthrough;
+ case NB_OP_CREATE_EXCL:
err = lyd_new_path(candidate->dnode, ly_native_ctx, xpath_edit,
- (void *)data->value, LYD_NEW_PATH_UPDATE,
- &dnode);
+ (void *)data->value, options, &dnode);
if (err) {
flog_warn(EC_LIB_LIBYANG,
"%s: lyd_new_path(%s) failed: %d", __func__,
@@ -756,6 +759,8 @@ int nb_candidate_edit(struct nb_config *candidate,
const char *nb_operation_name(enum nb_operation operation)
{
switch (operation) {
+ case NB_OP_CREATE_EXCL:
+ return "create exclusive";
case NB_OP_CREATE:
return "create";
case NB_OP_MODIFY: