Skip to content

Commit

Permalink
Merge pull request #14542 from idryzhov/nb-op-cb-split
Browse files Browse the repository at this point in the history
Add more northbound operation types
  • Loading branch information
choppsv1 authored Jan 12, 2024
2 parents 0f5a79a + 7e48299 commit 20d0d47
Show file tree
Hide file tree
Showing 12 changed files with 413 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ configuration. Here’s the declaration of this structure (taken from the
/*
* Operation to apply (either NB_OP_CREATE, NB_OP_MODIFY or
* NB_OP_DELETE).
* NB_OP_DESTROY).
*/
enum nb_operation operation;
Expand Down Expand Up @@ -1205,7 +1205,7 @@ This example shows how to create a list entry:
},
{
.xpath = "./access-list",
.operation = acl ? NB_OP_MODIFY : NB_OP_DELETE,
.operation = acl ? NB_OP_MODIFY : NB_OP_DESTROY,
.value = acl,
},
};
Expand Down Expand Up @@ -1242,7 +1242,7 @@ When deleting a list entry, all non-key leaves can be ignored:
struct cli_config_change changes[] = {
{
.xpath = ".",
.operation = NB_OP_DELETE,
.operation = NB_OP_DESTROY,
},
};
Expand Down
5 changes: 4 additions & 1 deletion lib/mgmt.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ message YangData {
enum CfgDataReqType {
REQ_TYPE_NONE = 0;
SET_DATA = 1;
DELETE_DATA = 2;
REMOVE_DATA = 2;
CREATE_DATA = 3;
DELETE_DATA = 4;
REPLACE_DATA = 5;
}

message YangCfgDataReq {
Expand Down
23 changes: 19 additions & 4 deletions lib/mgmt_be_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,26 @@ static int mgmt_be_update_setcfg_in_batch(struct mgmt_be_client *client_ctx,
for (index = 0; index < num_req; index++) {
cfg_chg = &txn_req->req.set_cfg.cfg_changes[index];

if (cfg_req[index]->req_type
== MGMTD__CFG_DATA_REQ_TYPE__DELETE_DATA)
/*
* Treat all operations as destroy or modify, because we don't
* need additional existence checks on the backend. Everything
* is already checked by mgmtd.
*/
switch (cfg_req[index]->req_type) {
case MGMTD__CFG_DATA_REQ_TYPE__DELETE_DATA:
case MGMTD__CFG_DATA_REQ_TYPE__REMOVE_DATA:
cfg_chg->operation = NB_OP_DESTROY;
else
cfg_chg->operation = NB_OP_CREATE;
break;
case MGMTD__CFG_DATA_REQ_TYPE__SET_DATA:
case MGMTD__CFG_DATA_REQ_TYPE__CREATE_DATA:
case MGMTD__CFG_DATA_REQ_TYPE__REPLACE_DATA:
cfg_chg->operation = NB_OP_MODIFY;
break;
case MGMTD__CFG_DATA_REQ_TYPE__REQ_TYPE_NONE:
case _MGMTD__CFG_DATA_REQ_TYPE_IS_INT_SIZE:
default:
continue;
}

strlcpy(cfg_chg->xpath, cfg_req[index]->data->xpath,
sizeof(cfg_chg->xpath));
Expand Down
Loading

0 comments on commit 20d0d47

Please sign in to comment.