Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more northbound operation types #14542

Merged
merged 6 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading