diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2024-03-26 19:24:45 +0200 |
|---|---|---|
| committer | Mark Stapp <mjs@cisco.com> | 2024-08-27 09:53:02 -0400 |
| commit | 82e52e0f21c12aa5b7270032c32b38e1fa33aa28 (patch) | |
| tree | 6a771925348869c500ab278fd54fb30b267bc7bf /lib/northbound_cli.c | |
| parent | 5dac6961540422a1ca139fae8c5ea9e5a437c4ba (diff) | |
lib: common debug config output
Implement common code for debug config output and remove daemon-specific
code that is duplicated everywhere.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/northbound_cli.c')
| -rw-r--r-- | lib/northbound_cli.c | 57 |
1 files changed, 13 insertions, 44 deletions
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index 0e89c5315c..f70bae9ed2 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -22,13 +22,19 @@ #include "northbound_db.h" #include "lib/northbound_cli_clippy.c" -struct debug nb_dbg_cbs_config = {0, "Northbound callbacks: configuration"}; -struct debug nb_dbg_cbs_state = {0, "Northbound callbacks: state"}; -struct debug nb_dbg_cbs_rpc = {0, "Northbound callbacks: RPCs"}; -struct debug nb_dbg_cbs_notify = {0, "Northbound callbacks: notifications"}; -struct debug nb_dbg_notif = {0, "Northbound notifications"}; -struct debug nb_dbg_events = {0, "Northbound events"}; -struct debug nb_dbg_libyang = {0, "libyang debugging"}; +struct debug nb_dbg_cbs_config = { 0, "debug northbound callbacks configuration", + "Northbound callbacks: configuration" }; +struct debug nb_dbg_cbs_state = { 0, "debug northbound callbacks state", + "Northbound callbacks: state" }; +struct debug nb_dbg_cbs_rpc = { 0, "debug northbound callbacks rpc", + "Northbound callbacks: RPCs" }; +struct debug nb_dbg_cbs_notify = { 0, "debug northbound callbacks notify", + "Northbound callbacks: notifications" }; +struct debug nb_dbg_notif = { 0, "debug northbound notifications", + "Northbound notifications" }; +struct debug nb_dbg_events = { 0, "debug northbound events", + "Northbound events" }; +struct debug nb_dbg_libyang = { 0, "debug northbound libyang", "libyang" }; struct nb_config *vty_shared_candidate_config; static struct event_loop *master; @@ -1842,22 +1848,6 @@ DEFPY (rollback_config, } /* Debug CLI commands. */ -static struct debug *nb_debugs[] = { - &nb_dbg_cbs_config, &nb_dbg_cbs_state, &nb_dbg_cbs_rpc, - &nb_dbg_cbs_notify, &nb_dbg_notif, &nb_dbg_events, - &nb_dbg_libyang, -}; - -static const char *const nb_debugs_conflines[] = { - "debug northbound callbacks configuration", - "debug northbound callbacks state", - "debug northbound callbacks rpc", - "debug northbound callbacks notify", - "debug northbound notifications", - "debug northbound events", - "debug northbound libyang", -}; - DEFPY (debug_nb, debug_nb_cmd, "[no] debug northbound\ @@ -1910,26 +1900,6 @@ DEFPY (debug_nb, return CMD_SUCCESS; } -DEFINE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty)); - -static int nb_debug_config_write(struct vty *vty) -{ - for (unsigned int i = 0; i < array_size(nb_debugs); i++) - if (DEBUG_MODE_CHECK(nb_debugs[i], DEBUG_MODE_CONF)) - vty_out(vty, "%s\n", nb_debugs_conflines[i]); - - hook_call(nb_client_debug_config_write, vty); - - return 1; -} - -static struct cmd_node nb_debug_node = { - .name = "northbound debug", - .node = NORTHBOUND_DEBUG_NODE, - .prompt = "", - .config_write = nb_debug_config_write, -}; - void nb_cli_install_default(int node) { _install_element(node, &show_config_candidate_section_cmd); @@ -1998,7 +1968,6 @@ void nb_cli_init(struct event_loop *tm) debug_install(&nb_dbg_events); debug_install(&nb_dbg_libyang); - install_node(&nb_debug_node); install_element(ENABLE_NODE, &debug_nb_cmd); install_element(CONFIG_NODE, &debug_nb_cmd); |
