Skip to content

Commit

Permalink
server BUGFIX edit-config replace fix
Browse files Browse the repository at this point in the history
Fixes #49
  • Loading branch information
michalvasko committed Dec 1, 2016
1 parent 6b85e16 commit 50b1b9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions server/op_editconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ edit_get_op(struct lyd_node *node, enum NP2_EDIT_OP parentop, enum NP2_EDIT_DEFO
}
}

if (parentop > 0) {
switch (parentop) {
case NP2_EDIT_REPLACE:
return NP2_EDIT_REPLACE_INNER;
case 0:
return (enum NP2_EDIT_OP)defop;
default:
return parentop;
} else {
return (enum NP2_EDIT_OP) defop;
}

cleanup:
Expand Down Expand Up @@ -384,10 +387,10 @@ op_editconfig(struct lyd_node *rpc, struct nc_session *ncs)
/* apply change to sysrepo */
switch (op[op_index]) {
case NP2_EDIT_MERGE:
case NP2_EDIT_REPLACE:
/* create the node */
ret = sr_set_item(sessions->srs, path, &value, 0);
break;
case NP2_EDIT_REPLACE_INNER:
case NP2_EDIT_CREATE:
/* create the node, but it must not exists */
ret = sr_set_item(sessions->srs, path, &value, SR_EDIT_STRICT);
Expand All @@ -396,6 +399,7 @@ op_editconfig(struct lyd_node *rpc, struct nc_session *ncs)
/* remove the node, but it must exists */
ret = sr_delete_item(sessions->srs, path, SR_EDIT_STRICT);
break;
case NP2_EDIT_REPLACE:
case NP2_EDIT_REMOVE:
/* remove the node */
ret = sr_delete_item(sessions->srs, path, 0);
Expand Down
1 change: 1 addition & 0 deletions server/operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum NP2_EDIT_OP {
NP2_EDIT_MERGE,
NP2_EDIT_CREATE,
NP2_EDIT_REPLACE,
NP2_EDIT_REPLACE_INNER,
NP2_EDIT_DELETE,
NP2_EDIT_REMOVE
};
Expand Down

0 comments on commit 50b1b9d

Please sign in to comment.