]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/northbound_cli.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / northbound_cli.c
index 5cf5f93b437c51ed3161423c951a5f3a684056b8..e9c89d202906dfac18c38d70b086cb7c6adee212 100644 (file)
@@ -195,9 +195,12 @@ int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt, ...)
                va_end(ap);
        }
 
-       if (vty_mgmt_fe_enabled()) {
+       if (vty_mgmt_should_process_cli_apply_changes(vty)) {
                VTY_CHECK_XPATH;
 
+               if (vty->type == VTY_FILE)
+                       return CMD_SUCCESS;
+
                implicit_commit = vty_needs_implicit_commit(vty);
                ret = vty_mgmt_send_config_data(vty);
                if (ret >= 0 && !implicit_commit)
@@ -224,7 +227,7 @@ int nb_cli_apply_changes_clear_pending(struct vty *vty,
                va_end(ap);
        }
 
-       if (vty_mgmt_fe_enabled()) {
+       if (vty_mgmt_should_process_cli_apply_changes(vty)) {
                VTY_CHECK_XPATH;
 
                implicit_commit = vty_needs_implicit_commit(vty);
@@ -1434,6 +1437,7 @@ DEFPY (show_yang_operational_data,
        struct lyd_node *dnode;
        char *strp;
        uint32_t print_options = LYD_PRINT_WITHSIBLINGS;
+       int ret;
 
        if (xml)
                format = LYD_XML;
@@ -1454,10 +1458,15 @@ DEFPY (show_yang_operational_data,
 
        /* Obtain data. */
        dnode = yang_dnode_new(ly_ctx, false);
-       if (nb_oper_data_iterate(xpath, translator, 0, nb_cli_oper_data_cb,
-                                dnode)
-           != NB_OK) {
-               vty_out(vty, "%% Failed to fetch operational data.\n");
+       ret = nb_oper_data_iterate(xpath, translator, 0, nb_cli_oper_data_cb,
+                                  dnode);
+       if (ret != NB_OK) {
+               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);
                return CMD_WARNING;
        }