* 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
|
||||
|
||||
### Corrected Bugs
|
||||
* Prefix of rpc was ignored
|
||||
* https://github.com/clicon/clixon/issues/30
|
||||
* Added cli returna value also for single commands (eg -1)
|
||||
* Fixed JSON unbalanced braces resulting in assert.
|
||||
|
||||
|
|
|
|||
|
|
@ -888,10 +888,17 @@ netconf_application_rpc(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
cbuf_reset(cb);
|
||||
// if (xml_namespace(xn))
|
||||
if (xml_namespace(xn) == NULL){
|
||||
xml_parse_va(xret, NULL, "<rpc-reply><rpc-error>"
|
||||
"<error-tag>operation-failed</error-tag>"
|
||||
"<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));
|
||||
// else
|
||||
// cprintf(cb, "/%s", xml_name(xn)); /* XXX not accepdted by below */
|
||||
/* Find yang rpc statement, return yang rpc statement if found */
|
||||
if (yang_abs_schema_nodeid(yspec, cbuf_get(cb), Y_RPC, &yrpc) < 0)
|
||||
goto done;
|
||||
|
|
@ -937,6 +944,7 @@ netconf_application_rpc(clicon_handle h,
|
|||
retval = 1; /* handled by callback */
|
||||
goto done;
|
||||
}
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
if (cb)
|
||||
|
|
|
|||
|
|
@ -1048,8 +1048,13 @@ api_operations_post(clicon_handle h,
|
|||
clicon_debug(1, "%s oppath: %s", __FUNCTION__, oppath);
|
||||
|
||||
/* 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){
|
||||
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 (netconf_operation_failed_xml(&xerr, "protocol", "yang node not found") < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -2082,9 +2082,9 @@ schema_nodeid_vec(yang_node *yn,
|
|||
* Assume schema nodeid:s have prefixes, (actually the first).
|
||||
* @see yang_desc_schema_nodeid
|
||||
* @see RFC7950 6.5
|
||||
o schema node: A node in the schema tree. One of action, container,
|
||||
leaf, leaf-list, list, choice, case, rpc, input, output,
|
||||
notification, anydata, and anyxml.
|
||||
* o schema node: A node in the schema tree. One of action, container,
|
||||
* leaf, leaf-list, list, choice, case, rpc, input, output,
|
||||
* notification, anydata, and anyxml.
|
||||
* Used in yang: deviation, top-level augment
|
||||
*/
|
||||
int
|
||||
|
|
@ -2136,7 +2136,6 @@ yang_abs_schema_nodeid(yang_spec *yspec,
|
|||
}
|
||||
}
|
||||
if (ymod == NULL){ /* Try with topnode */
|
||||
|
||||
if ((ys = yang_find_topnode(yspec, id, YC_SCHEMANODE)) == NULL){
|
||||
clicon_err(OE_YANG, 0, "Module with id:%s:%s not found", prefix,id);
|
||||
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);
|
||||
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)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -199,11 +199,11 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><star
|
|||
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>"
|
||||
|
||||
new "netconf rpc w/o 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>"
|
||||
new "netconf rpc without namespace"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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>"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue