if (host.noconfig)
return CMD_SUCCESS;
+ nb_cli_show_config_prepare(running_config, false);
+
if (vty->type == VTY_TERM) {
vty_out(vty, "\nCurrent configuration:\n");
vty_out(vty, "!\n");
__func__);
return NB_ERR;
}
-
- /*
- * If a new node was created, call lyd_validate() only to create
- * default child nodes.
- */
- if (dnode) {
- lyd_schema_sort(dnode, 0);
- lyd_validate(&dnode,
- LYD_OPT_CONFIG | LYD_OPT_WHENAUTODEL,
- ly_native_ctx);
- }
break;
case NB_OP_DESTROY:
dnode = yang_dnode_get(candidate->dnode, xpath_edit);
return elem->parent;
}
+/* Prepare the configuration for display. */
+void nb_cli_show_config_prepare(struct nb_config *config, bool with_defaults)
+{
+ lyd_schema_sort(config->dnode, 1);
+
+ /*
+ * When "with-defaults" is used, call lyd_validate() only to create
+ * default child nodes, ignoring any possible validation error. This
+ * doesn't need to be done when displaying the running configuration
+ * since it's always fully validated.
+ */
+ if (with_defaults && config != running_config)
+ (void)lyd_validate(&config->dnode,
+ LYD_OPT_CONFIG | LYD_OPT_WHENAUTODEL,
+ ly_native_ctx);
+}
+
void nb_cli_show_dnode_cmds(struct vty *vty, struct lyd_node *root,
bool with_defaults)
{
struct yang_translator *translator,
bool with_defaults)
{
+ nb_cli_show_config_prepare(config, with_defaults);
+
switch (format) {
case NB_CFG_FMT_CMDS:
nb_cli_show_config_cmds(vty, config, with_defaults);
bool show_defaults);
/* Prototypes of internal functions. */
+extern void nb_cli_show_config_prepare(struct nb_config *config,
+ bool with_defaults);
extern void nb_cli_confirmed_commit_clean(struct vty *vty);
extern int nb_cli_confirmed_commit_rollback(struct vty *vty);
extern void nb_cli_install_default(int node);