NACM write path delete works as well
This commit is contained in:
parent
1dff0e681b
commit
5be5b02a84
7 changed files with 86 additions and 64 deletions
|
|
@ -227,10 +227,11 @@ check_body_namespace(cxobj *x0,
|
|||
static int
|
||||
text_modify(clicon_handle h,
|
||||
cxobj *x0,
|
||||
yang_stmt *y0,
|
||||
cxobj *x0p,
|
||||
cxobj *x0t,
|
||||
cxobj *x1,
|
||||
cxobj *x1t,
|
||||
yang_stmt *y0,
|
||||
enum operation_type op,
|
||||
char *username,
|
||||
cxobj *xnacm,
|
||||
|
|
@ -319,7 +320,7 @@ text_modify(clicon_handle h,
|
|||
* of ordered-by user and (changed) insert attribute.
|
||||
*/
|
||||
if (!permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x1, x0?NACM_UPDATE:NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
if ((ret = nacm_datanode_write(h, x1, x1t, x0?NACM_UPDATE:NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
|
@ -336,7 +337,7 @@ text_modify(clicon_handle h,
|
|||
case OP_NONE: /* fall thru */
|
||||
if (x0==NULL){
|
||||
if ((op != OP_NONE) && !permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x1, NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
if ((ret = nacm_datanode_write(h, x1, x1t, NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
|
@ -403,7 +404,7 @@ text_modify(clicon_handle h,
|
|||
x0bstr = xml_value(x0b);
|
||||
if (x0bstr==NULL || strcmp(x0bstr, x1bstr)){
|
||||
if ((op != OP_NONE) && !permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x1,
|
||||
if ((ret = nacm_datanode_write(h, x1, x1t,
|
||||
x0bstr==NULL?NACM_CREATE:NACM_UPDATE,
|
||||
username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
|
|
@ -429,7 +430,7 @@ text_modify(clicon_handle h,
|
|||
case OP_REMOVE: /* fall thru */
|
||||
if (x0){
|
||||
if ((op != OP_NONE) && !permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x0, NACM_DELETE, username, xnacm, cbret)) < 0)
|
||||
if ((ret = nacm_datanode_write(h, x0, x0t, NACM_DELETE, username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
|
@ -491,7 +492,7 @@ text_modify(clicon_handle h,
|
|||
* of ordered-by user and (changed) insert attribute.
|
||||
*/
|
||||
if (!permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x1, x0?NACM_UPDATE:NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
if ((ret = nacm_datanode_write(h, x1, x1t, x0?NACM_UPDATE:NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
|
@ -517,7 +518,7 @@ text_modify(clicon_handle h,
|
|||
if (op == OP_NONE)
|
||||
break;
|
||||
if (op==OP_MERGE && !permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x0, x0?NACM_UPDATE:NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
if ((ret = nacm_datanode_write(h, x1, x1t, x0?NACM_UPDATE:NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
|
@ -534,7 +535,7 @@ text_modify(clicon_handle h,
|
|||
} /* anyxml, anydata */
|
||||
if (x0==NULL){
|
||||
if (op==OP_MERGE && !permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x1, NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
if ((ret = nacm_datanode_write(h, x1, x1t, NACM_CREATE, username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
|
@ -605,7 +606,8 @@ text_modify(clicon_handle h,
|
|||
x1cname = xml_name(x1c);
|
||||
x0c = x0vec[i++];
|
||||
yc = yang_find_datanode(y0, x1cname);
|
||||
if ((ret = text_modify(h, x0c, yc, x0, x1c, x1t, op,
|
||||
if ((ret = text_modify(h, x0c, x0, x0t, x1c, x1t,
|
||||
yc, op,
|
||||
username, xnacm, permit, cbret)) < 0)
|
||||
goto done;
|
||||
/* If xml return - ie netconf error xml tree, then stop and return OK */
|
||||
|
|
@ -626,7 +628,7 @@ text_modify(clicon_handle h,
|
|||
case OP_REMOVE: /* fall thru */
|
||||
if (x0){
|
||||
if (!permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x0, NACM_DELETE, username, xnacm, cbret)) < 0)
|
||||
if ((ret = nacm_datanode_write(h, x0, x0t, NACM_DELETE, username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
|
@ -673,6 +675,7 @@ text_modify(clicon_handle h,
|
|||
static int
|
||||
text_modify_top(clicon_handle h,
|
||||
cxobj *x0,
|
||||
cxobj *x0t,
|
||||
cxobj *x1,
|
||||
cxobj *x1t,
|
||||
yang_stmt *yspec,
|
||||
|
|
@ -709,7 +712,7 @@ text_modify_top(clicon_handle h,
|
|||
case OP_REMOVE:
|
||||
case OP_REPLACE:
|
||||
if (!permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x0, NACM_DELETE, username, xnacm, cbret)) < 0)
|
||||
if ((ret = nacm_datanode_write(h, x0, x0t, NACM_DELETE, username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
|
@ -743,7 +746,7 @@ text_modify_top(clicon_handle h,
|
|||
/* Special case top-level replace */
|
||||
else if (op == OP_REPLACE || op == OP_DELETE){
|
||||
if (!permit && xnacm){
|
||||
if ((ret = nacm_datanode_write(h, x1t, x1, NACM_UPDATE, username, xnacm, cbret)) < 0)
|
||||
if ((ret = nacm_datanode_write(h, x1, x1t, NACM_UPDATE, username, xnacm, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
|
@ -777,7 +780,8 @@ text_modify_top(clicon_handle h,
|
|||
goto done;
|
||||
x0c = NULL;
|
||||
}
|
||||
if ((ret = text_modify(h, x0c, yc, x0, x1c, x1t, op,
|
||||
if ((ret = text_modify(h, x0c, x0, x0t, x1c, x1t,
|
||||
yc, op,
|
||||
username, xnacm, permit, cbret)) < 0)
|
||||
goto done;
|
||||
/* If xml return - ie netconf error xml tree, then stop and return OK */
|
||||
|
|
@ -921,7 +925,7 @@ xmldb_put(clicon_handle h,
|
|||
* Modify base tree x with modification x1. This is where the
|
||||
* new tree is made.
|
||||
*/
|
||||
if ((ret = text_modify_top(h, x0, x1, x1, yspec, op, username, xnacm, permit, cbret)) < 0)
|
||||
if ((ret = text_modify_top(h, x0, x0, x1, x1, yspec, op, username, xnacm, permit, cbret)) < 0)
|
||||
goto done;
|
||||
/* If xml return - ie netconf error xml tree, then stop and return OK */
|
||||
if (ret == 0){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue