mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 17:27:42 +00:00
lib: always return valid data format for show yang command.
For JSON return `{}` for XPath return an XML comment `<!-- Not found -->` Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
4ac51e2430
commit
d249d7e0ab
@ -1434,6 +1434,7 @@ DEFPY (show_yang_operational_data,
|
|||||||
struct lyd_node *dnode;
|
struct lyd_node *dnode;
|
||||||
char *strp;
|
char *strp;
|
||||||
uint32_t print_options = LYD_PRINT_WITHSIBLINGS;
|
uint32_t print_options = LYD_PRINT_WITHSIBLINGS;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (xml)
|
if (xml)
|
||||||
format = LYD_XML;
|
format = LYD_XML;
|
||||||
@ -1454,10 +1455,15 @@ DEFPY (show_yang_operational_data,
|
|||||||
|
|
||||||
/* Obtain data. */
|
/* Obtain data. */
|
||||||
dnode = yang_dnode_new(ly_ctx, false);
|
dnode = yang_dnode_new(ly_ctx, false);
|
||||||
if (nb_oper_data_iterate(xpath, translator, 0, nb_cli_oper_data_cb,
|
ret = nb_oper_data_iterate(xpath, translator, 0, nb_cli_oper_data_cb,
|
||||||
dnode)
|
dnode);
|
||||||
!= NB_OK) {
|
if (ret != NB_OK) {
|
||||||
vty_out(vty, "%% Failed to fetch operational data.\n");
|
if (format == LYD_JSON)
|
||||||
|
vty_out(vty, "{}\n");
|
||||||
|
else {
|
||||||
|
/* embed ly_last_errmsg() when we get newer libyang */
|
||||||
|
vty_out(vty, "<!-- Not found -->\n");
|
||||||
|
}
|
||||||
yang_dnode_free(dnode);
|
yang_dnode_free(dnode);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user