diff --git a/cmgd/cmgd_db.c b/cmgd/cmgd_db.c index e1ce2f129eaa..004a912e2fb8 100644 --- a/cmgd/cmgd_db.c +++ b/cmgd/cmgd_db.c @@ -520,7 +520,7 @@ int cmgd_db_hndl_send_get_data_req( void cmgd_db_dump_tree( struct vty *vty, cmgd_db_hndl_t db_hndl, const char* xpath, - LYD_FORMAT format) + FILE *f, LYD_FORMAT format) { cmgd_db_ctxt_t *db_ctxt; struct ly_out *out; @@ -538,10 +538,16 @@ void cmgd_db_dump_tree( cmgd_remove_trailing_separator(base_xpath, '/'); } - ly_out_new_memory(&str, 0, &out); + if (f) + ly_out_new_file(f, &out); + else + ly_out_new_memory(&str, 0, &out); + cmgd_db_dump_in_memory(db_hndl, base_xpath, format, out); - vty_out(vty, "%s", str); + if (!f) + vty_out(vty, "%s", str); + ly_out_free(out, NULL, 0); } diff --git a/cmgd/cmgd_db.h b/cmgd/cmgd_db.h index 6d4df41ff160..a47f77a884b8 100644 --- a/cmgd/cmgd_db.h +++ b/cmgd/cmgd_db.h @@ -162,7 +162,7 @@ extern int cmgd_db_hndl_send_get_data_req( cmgd_yang_getdata_req_t *data_req, int num_reqs); extern void cmgd_db_dump_tree( struct vty *vty, cmgd_db_hndl_t db_hndl, const char* xpath, - LYD_FORMAT format); + FILE *f, LYD_FORMAT format); extern void cmgd_db_status_write_one( struct vty *vty, cmgd_db_hndl_t db_hndl); diff --git a/cmgd/cmgd_vty.c b/cmgd/cmgd_vty.c index ec868f136435..dae46b9f111a 100644 --- a/cmgd/cmgd_vty.c +++ b/cmgd/cmgd_vty.c @@ -418,7 +418,7 @@ DEFPY(show_cmgd_get_data, DEFPY(show_cmgd_dump_data, show_cmgd_dump_data_cmd, - "show cmgd database-contents db-name WORD$dbname [xpath WORD$path] format WORD$format_str", + "show cmgd database-contents db-name WORD$dbname [xpath WORD$path] [filepath WORD$filepath] format WORD$format_str", SHOW_STR CMGD_STR "Get Database Contenents from a specific database\n" @@ -426,12 +426,15 @@ DEFPY(show_cmgd_dump_data, "