diff options
| author | Christian Hopps <chopps@labn.net> | 2023-06-27 13:58:54 -0400 |
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2023-06-27 18:00:56 -0400 |
| commit | dbb1bc6f355ae53ce1f2402a1ac196e9f9e18a42 (patch) | |
| tree | 95440d9560362977bbd485ffdab1b30f7f8f5cc0 /lib/vty.c | |
| parent | 6267c2aaad2a503ae24885d3ffc9a7867fccb6c0 (diff) | |
mgmtd: consolidate getcfg and getdata msgs into "get"
eliminates tons of copy and paste code.
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/vty.c')
| -rw-r--r-- | lib/vty.c | 51 |
1 files changed, 8 insertions, 43 deletions
@@ -3822,8 +3822,9 @@ int vty_mgmt_send_commit_config(struct vty *vty, bool validate_only, bool abort) return 0; } -int vty_mgmt_send_get_config(struct vty *vty, Mgmtd__DatastoreId datastore, - const char **xpath_list, int num_req) +int vty_mgmt_send_get_req(struct vty *vty, bool is_config, + Mgmtd__DatastoreId datastore, const char **xpath_list, + int num_req) { Mgmtd__YangData yang_data[VTY_MAXCFGCHANGES]; Mgmtd__YangGetDataReq get_req[VTY_MAXCFGCHANGES]; @@ -3841,13 +3842,11 @@ int vty_mgmt_send_get_config(struct vty *vty, Mgmtd__DatastoreId datastore, get_req[i].data = &yang_data[i]; getreq[i] = &get_req[i]; } - if (mgmt_fe_send_getcfg_req(mgmt_fe_client, vty->mgmt_session_id, - vty->mgmt_req_id, datastore, getreq, - num_req)) { - zlog_err( - "Failed to send GET-CONFIG to MGMTD for req-id %" PRIu64 - ".", - vty->mgmt_req_id); + if (mgmt_fe_send_get_req(mgmt_fe_client, vty->mgmt_session_id, + vty->mgmt_req_id, is_config, datastore, getreq, + num_req)) { + zlog_err("Failed to send GET- to MGMTD for req-id %" PRIu64 ".", + vty->mgmt_req_id); vty_out(vty, "Failed to send GET-CONFIG to MGMTD!\n"); return -1; } @@ -3857,40 +3856,6 @@ int vty_mgmt_send_get_config(struct vty *vty, Mgmtd__DatastoreId datastore, return 0; } -int vty_mgmt_send_get_data(struct vty *vty, Mgmtd__DatastoreId datastore, - const char **xpath_list, int num_req) -{ - Mgmtd__YangData yang_data[VTY_MAXCFGCHANGES]; - Mgmtd__YangGetDataReq get_req[VTY_MAXCFGCHANGES]; - Mgmtd__YangGetDataReq *getreq[VTY_MAXCFGCHANGES]; - int i; - - vty->mgmt_req_id++; - - for (i = 0; i < num_req; i++) { - mgmt_yang_get_data_req_init(&get_req[i]); - mgmt_yang_data_init(&yang_data[i]); - - yang_data->xpath = (char *)xpath_list[i]; - - get_req[i].data = &yang_data[i]; - getreq[i] = &get_req[i]; - } - if (mgmt_fe_send_getdata_req(mgmt_fe_client, vty->mgmt_session_id, - vty->mgmt_req_id, datastore, getreq, - num_req)) { - zlog_err("Failed to send GET-DATA to MGMTD for req-id %" PRIu64 - ".", - vty->mgmt_req_id); - vty_out(vty, "Failed to send GET-DATA to MGMTD!\n"); - return -1; - } - - vty->mgmt_req_pending_cmd = "MESSAGE_GETDATA_REQ"; - - return 0; -} - /* Install vty's own commands like `who' command. */ void vty_init(struct event_loop *master_thread, bool do_command_logging) { |
