* Prefix of rpc was ignored
* https://github.com/clicon/clixon/issues/30
This commit is contained in:
parent
578a96eff7
commit
60ce7b12bd
6 changed files with 39 additions and 17 deletions
|
|
@ -47,6 +47,8 @@
|
||||||
* See FAQ and example
|
* See FAQ and example
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
* Prefix of rpc was ignored
|
||||||
|
* https://github.com/clicon/clixon/issues/30
|
||||||
* Added cli returna value also for single commands (eg -1)
|
* Added cli returna value also for single commands (eg -1)
|
||||||
* Fixed JSON unbalanced braces resulting in assert.
|
* Fixed JSON unbalanced braces resulting in assert.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -888,12 +888,19 @@ netconf_application_rpc(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
cbuf_reset(cb);
|
cbuf_reset(cb);
|
||||||
// if (xml_namespace(xn))
|
if (xml_namespace(xn) == NULL){
|
||||||
cprintf(cb, "/%s:%s", xml_namespace(xn), xml_name(xn));
|
xml_parse_va(xret, NULL, "<rpc-reply><rpc-error>"
|
||||||
// else
|
"<error-tag>operation-failed</error-tag>"
|
||||||
// cprintf(cb, "/%s", xml_name(xn)); /* XXX not accepdted by below */
|
"<error-type>rpc</error-type>"
|
||||||
|
"<error-severity>error</error-severity>"
|
||||||
|
"<error-message>%s</error-message>"
|
||||||
|
"<error-info>Not recognized</error-info>"
|
||||||
|
"</rpc-error></rpc-reply>", xml_name(xn));
|
||||||
|
goto ok;
|
||||||
|
}
|
||||||
|
cprintf(cb, "/%s:%s", xml_namespace(xn), xml_name(xn));
|
||||||
/* Find yang rpc statement, return yang rpc statement if found */
|
/* Find yang rpc statement, return yang rpc statement if found */
|
||||||
if (yang_abs_schema_nodeid(yspec, cbuf_get(cb), Y_RPC, &yrpc) < 0)
|
if (yang_abs_schema_nodeid(yspec, cbuf_get(cb), Y_RPC, &yrpc) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Check if found */
|
/* Check if found */
|
||||||
if (yrpc != NULL){
|
if (yrpc != NULL){
|
||||||
|
|
@ -937,6 +944,7 @@ netconf_application_rpc(clicon_handle h,
|
||||||
retval = 1; /* handled by callback */
|
retval = 1; /* handled by callback */
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
if (cb)
|
if (cb)
|
||||||
|
|
|
||||||
|
|
@ -1048,8 +1048,13 @@ api_operations_post(clicon_handle h,
|
||||||
clicon_debug(1, "%s oppath: %s", __FUNCTION__, oppath);
|
clicon_debug(1, "%s oppath: %s", __FUNCTION__, oppath);
|
||||||
|
|
||||||
/* Find yang rpc statement, return yang rpc statement if found */
|
/* Find yang rpc statement, return yang rpc statement if found */
|
||||||
if (yang_abs_schema_nodeid(yspec, oppath, Y_RPC, &yrpc) < 0)
|
if (yang_abs_schema_nodeid(yspec, oppath, Y_RPC, &yrpc) < 0){
|
||||||
goto done;
|
if (netconf_operation_failed_xml(&xerr, "protocol", "yang node not found") < 0)
|
||||||
|
goto done;
|
||||||
|
if (api_return_err(h, r, xerr, pretty, use_xml) < 0)
|
||||||
|
goto done;
|
||||||
|
goto ok;
|
||||||
|
}
|
||||||
if (yrpc == NULL){
|
if (yrpc == NULL){
|
||||||
if (netconf_operation_failed_xml(&xerr, "protocol", "yang node not found") < 0)
|
if (netconf_operation_failed_xml(&xerr, "protocol", "yang node not found") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -2082,16 +2082,16 @@ schema_nodeid_vec(yang_node *yn,
|
||||||
* Assume schema nodeid:s have prefixes, (actually the first).
|
* Assume schema nodeid:s have prefixes, (actually the first).
|
||||||
* @see yang_desc_schema_nodeid
|
* @see yang_desc_schema_nodeid
|
||||||
* @see RFC7950 6.5
|
* @see RFC7950 6.5
|
||||||
o schema node: A node in the schema tree. One of action, container,
|
* o schema node: A node in the schema tree. One of action, container,
|
||||||
leaf, leaf-list, list, choice, case, rpc, input, output,
|
* leaf, leaf-list, list, choice, case, rpc, input, output,
|
||||||
notification, anydata, and anyxml.
|
* notification, anydata, and anyxml.
|
||||||
* Used in yang: deviation, top-level augment
|
* Used in yang: deviation, top-level augment
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
yang_abs_schema_nodeid(yang_spec *yspec,
|
yang_abs_schema_nodeid(yang_spec *yspec,
|
||||||
char *schema_nodeid,
|
char *schema_nodeid,
|
||||||
enum rfc_6020 keyword,
|
enum rfc_6020 keyword,
|
||||||
yang_stmt **yres)
|
yang_stmt **yres)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char **vec = NULL;
|
char **vec = NULL;
|
||||||
|
|
@ -2136,7 +2136,6 @@ yang_abs_schema_nodeid(yang_spec *yspec,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ymod == NULL){ /* Try with topnode */
|
if (ymod == NULL){ /* Try with topnode */
|
||||||
|
|
||||||
if ((ys = yang_find_topnode(yspec, id, YC_SCHEMANODE)) == NULL){
|
if ((ys = yang_find_topnode(yspec, id, YC_SCHEMANODE)) == NULL){
|
||||||
clicon_err(OE_YANG, 0, "Module with id:%s:%s not found", prefix,id);
|
clicon_err(OE_YANG, 0, "Module with id:%s:%s not found", prefix,id);
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -2145,6 +2144,11 @@ yang_abs_schema_nodeid(yang_spec *yspec,
|
||||||
clicon_err(OE_YANG, 0, "Module with id:%s:%s not found2", prefix,id);
|
clicon_err(OE_YANG, 0, "Module with id:%s:%s not found2", prefix,id);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if ((yprefix = yang_find((yang_node*)ymod, Y_PREFIX, NULL)) != NULL &&
|
||||||
|
strcmp(yprefix->ys_argument, prefix) != 0){
|
||||||
|
clicon_err(OE_YANG, 0, "Module with id:%s:%s not found", prefix,id);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (schema_nodeid_vec((yang_node*)ymod, vec+1, nvec-1, keyword, yres) < 0)
|
if (schema_nodeid_vec((yang_node*)ymod, vec+1, nvec-1, keyword, yres) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -199,11 +199,11 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><star
|
||||||
new "netconf rpc"
|
new "netconf rpc"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><rt:fib-route><routing-instance-name>ipv4</routing-instance-name><destination-address><address-family>ipv4</address-family></destination-address></rt:fib-route></rpc>]]>]]>" "^<rpc-reply><route><address-family>ipv4</address-family><next-hop><next-hop-list>"
|
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><rt:fib-route><routing-instance-name>ipv4</routing-instance-name><destination-address><address-family>ipv4</address-family></destination-address></rt:fib-route></rpc>]]>]]>" "^<rpc-reply><route><address-family>ipv4</address-family><next-hop><next-hop-list>"
|
||||||
|
|
||||||
new "netconf rpc w/o namespace"
|
new "netconf rpc without namespace"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><fib-route><routing-instance-name>ipv4</routing-instance-name><destination-address><address-family>ipv4</address-family></destination-address></fib-route></rpc>]]>]]>" "^<rpc-reply><route><address-family>ipv4</address-family><next-hop><next-hop-list>"
|
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><rt:fib-route><routing-instance-name>ipv4</routing-instance-name><destination-address><address-family>ipv4</address-family></destination-address></rt:fib-route></rpc>]]>]]>" "^<rpc-reply><route><address-family>ipv4</address-family><next-hop><next-hop-list>"
|
||||||
|
|
||||||
new "netconf empty rpc"
|
new "netconf empty rpc"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><empty/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><ex:empty/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
new "netconf client-side rpc"
|
new "netconf client-side rpc"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><ex:client-rpc><request>example</request></ex:client-rpc></rpc>]]>]]>" "^<rpc-reply><result>ok</result></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><ex:client-rpc><request>example</request></ex:client-rpc></rpc>]]>]]>" "^<rpc-reply><result>ok</result></rpc-reply>]]>]]>$"
|
||||||
|
|
|
||||||
|
|
@ -275,6 +275,9 @@ if [ -z "$match" ]; then
|
||||||
err "$expect" "$ret"
|
err "$expect" "$ret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
new2 "restconf rpc using wrong prefix"
|
||||||
|
expecteq "$(curl -s -X POST -d '{"input":{"routing-instance-name":"ipv4"}}' http://localhost/restconf/operations/wrong:fib-route)" '{"ietf-restconf:errors" : {"error": {"rpc-error": {"error-tag": "operation-failed","error-type": "protocol","error-severity": "error","error-message": "yang node not found"}}}}
'
|
||||||
|
|
||||||
new "restconf local client rpc using POST xml"
|
new "restconf local client rpc using POST xml"
|
||||||
ret=$(curl -s -X POST -H "Accept: application/yang-data+xml" -d '{"input":{"request":"example"}}' http://localhost/restconf/operations/ex:client-rpc)
|
ret=$(curl -s -X POST -H "Accept: application/yang-data+xml" -d '{"input":{"request":"example"}}' http://localhost/restconf/operations/ex:client-rpc)
|
||||||
expect="<output><result>ok</result></output>"
|
expect="<output><result>ok</result></output>"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue