]> git.proxmox.com Git - mirror_frr.git/commitdiff
vtysh: add the "show yang operational-data" command
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 23 Sep 2019 12:38:03 +0000 (09:38 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 23 Sep 2019 12:38:05 +0000 (09:38 -0300)
The right way to implement this command in vtysh is the following:
* Send the command to each running FRR daemon;
* Collect the command output from each daemon;
* Parse the text outputs into libyang lyd_node structures. Then merge
  all these data trees into a single one. Finally, print the merged
  data trees to the standard output (libyang will take care of
  combining duplicate nodes as necessary).

What this commit does is to allow vtysh to send the "show yang
operational-data" command to a single daemon only (the last
parameter).  It's a quick workaround to allow us to write topotests
using YANG-modeled data until we do the real thing (full vtysh
northbound integration).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
vtysh/vtysh.c

index ea079d8b18a5728d7f6b5be7b8cba42ad1ab9853..a0614c08757dbc52635a0c79f491044e983a1858 100644 (file)
@@ -2423,6 +2423,31 @@ DEFUN (vtysh_show_error_code,
 }
 
 /* Northbound. */
+DEFUN (show_yang_operational_data,
+       show_yang_operational_data_cmd,
+       "show yang operational-data XPATH$xpath\
+         [{\
+          format <json$json|xml$xml>\
+          |translate WORD$translator_family\
+        }]" DAEMONS_LIST,
+       SHOW_STR
+       "YANG information\n"
+       "Show YANG operational data\n"
+       "XPath expression specifying the YANG data path\n"
+       "Set the output format\n"
+       "JavaScript Object Notation\n"
+       "Extensible Markup Language\n"
+       "Translate operational data\n"
+       "YANG module translator\n"
+       DAEMONS_STR)
+{
+       int idx_protocol = argc - 1;
+       char *fcmd = argv_concat(argv, argc - 1, 0);
+       int ret = vtysh_client_execute_name(argv[idx_protocol]->text, fcmd);
+       XFREE(MTYPE_TMP, fcmd);
+       return ret;
+}
+
 DEFUNSH(VTYSH_ALL, debug_nb,
        debug_nb_cmd,
        "[no] debug northbound\
@@ -4040,6 +4065,7 @@ void vtysh_init_vty(void)
        install_element(CONFIG_NODE, &vtysh_debug_memstats_cmd);
 
        /* northbound */
+       install_element(VIEW_NODE, &show_yang_operational_data_cmd);
        install_element(ENABLE_NODE, &debug_nb_cmd);
        install_element(CONFIG_NODE, &debug_nb_cmd);