Corrected "No yang spec" printed on tty on leafref CLI usage

This commit is contained in:
Olof hagsand 2018-01-06 13:40:14 +01:00
parent 071667102c
commit 83cb696d0e
5 changed files with 22 additions and 15 deletions

View file

@ -11,6 +11,8 @@
* Clixon XML C-lib prior to 3.4.0. As enabled with `configure --with-xml-compat`
### Corrected Bugs
* Corrected "No yang spec" printed on tty on leafref CLI usage
### Known issues
## 3.4.0 (1 January 2018)

View file

@ -71,10 +71,11 @@
/*! Send internal netconf rpc from client to backend
* @param[in] h CLICON handle
* @param[in] msg Encoded message. Deallocate woth free
* @param[out] xret Return value from backend as netconf xml tree. Free w xml_free
* @param[out] xret Return value from backend as xml tree. Free w xml_free
* @param[inout] sock0 If pointer exists, do not close socket to backend on success
* and return it here. For keeping a notify socket open
* Note: sock0 is if connection should be persistent, like a notification/subscribe api
* @note sock0 is if connection should be persistent, like a notification/subscribe api
* @note xret is populated with yangspec according to standard handle yangspec
*/
int
clicon_rpc_msg(clicon_handle h,
@ -87,6 +88,7 @@ clicon_rpc_msg(clicon_handle h,
int port;
char *retdata = NULL;
cxobj *xret = NULL;
yang_spec *yspec;
if ((sock = clicon_sock(h)) == NULL){
clicon_err(OE_FATAL, 0, "CLICON_SOCK option not set");
@ -119,9 +121,12 @@ clicon_rpc_msg(clicon_handle h,
break;
}
clicon_debug(1, "%s retdata:%s", __FUNCTION__, retdata);
if (retdata &&
xml_parse_string(retdata, NULL, &xret) < 0)
goto done;
if (retdata){
yspec = clicon_dbspec_yang(h);
if (xml_parse_string(retdata, yspec, &xret) < 0)
goto done;
}
if (xret0){
*xret0 = xret;
xret = NULL;

View file

@ -592,11 +592,8 @@ match_base_child(cxobj *x0,
}
/* Get match */
{
yang_node *y0;
int yorder;
if ((y0 = yc->ys_parent) == NULL)
goto done;
/* XXX: No we cant do this. on uppermost layer it can look like this:
* config
* ximport-----ymod = ietf
@ -613,7 +610,12 @@ match_base_child(cxobj *x0,
*x0cp = xml_search(x0, xml_name(x1c), yorder, yc->ys_keyword, keynr, keyvec, keyval);
}
else{
#if 1 /* This is just a warning, but a catcher for when xml tree is not
populated with yang spec. If you see this, a previous inovation of,
for example xml_spec_populate() may be missing
*/
clicon_log(LOG_WARNING, "%s No yspec", __FUNCTION__);
#endif
*x0cp = xml_match(x0, xml_name(x1c), yc->ys_keyword, keynr, keyvec, keyval);
}
#else

View file

@ -549,10 +549,8 @@ yang_find_myprefix(yang_stmt *ys)
clicon_err(OE_YANG, 0, "My yang module not found");
goto done;
}
if ((yprefix = yang_find((yang_node*)ymod, Y_PREFIX, NULL)) == NULL){
clicon_err(OE_YANG, 0, "No prefix in my module");
if ((yprefix = yang_find((yang_node*)ymod, Y_PREFIX, NULL)) == NULL)
goto done;
}
prefix = yprefix->ys_argument;
done:
return prefix;
@ -729,7 +727,6 @@ yang_find_module_by_prefix(yang_stmt *ys,
clicon_err(OE_YANG, 0, "My yang spec not found");
goto done;
}
myprefix = yang_find_myprefix(ys);
if ((my_ymod = ys_module(ys)) == NULL){
clicon_err(OE_YANG, 0, "My yang module not found");
goto done;
@ -741,7 +738,8 @@ yang_find_module_by_prefix(yang_stmt *ys,
goto done;
}
#endif
if (strcmp(myprefix, prefix) == 0){
myprefix = yang_find_myprefix(ys);
if (myprefix && strcmp(myprefix, prefix) == 0){
ymod = my_ymod;
goto done;
}

View file

@ -55,7 +55,7 @@ if [ $? -ne 0 ]; then
err
fi
new "start backend"
new "start backend -s init -f $cfg -y $fyang"
# start new backend
sudo clixon_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
@ -102,7 +102,7 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" "<rpc><validate><source><candidat
new "leafref discard-changes"
expecteof "$clixon_netconf -qf $cfg" "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
exit
new "cli leafref lo"
expectfn "$clixon_cli -1f $cfg -y $fyang -l o set default-address absname lo" "^$"