]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: add minimal no-config VTY mode
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 9 Nov 2016 13:42:47 +0000 (14:42 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Thu, 10 Nov 2016 09:15:27 +0000 (10:15 +0100)
This silences the following warning from watchquagga:
"Can't save to configuration file, using vtysh."
which otherwise appears when doing a "write file" in vtysh when no
integrated-config is in use.

Also make "show memory" available in watchquagga.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/command.c
lib/command.h
watchquagga/watchquagga.c

index 56c262a647f14da9574f83553355fcf7e41972e4..e8ba63762300d677e58ac594b64c6252e24b696c 100644 (file)
@@ -3146,6 +3146,9 @@ DEFUN (config_write_file,
   struct vty *file_vty;
   struct stat conf_stat;
 
+  if (host.noconfig)
+    return CMD_SUCCESS;
+
   /* Check and see if we are operating under vtysh configuration */
   if (host.config == NULL)
     {
@@ -3270,6 +3273,9 @@ DEFUN (config_write_terminal,
   unsigned int i;
   struct cmd_node *node;
 
+  if (host.noconfig)
+    return CMD_SUCCESS;
+
   if (vty->type == VTY_SHELL_SERV)
     {
       for (i = 0; i < vector_active (cmdvec); i++)
@@ -3313,6 +3319,11 @@ DEFUN (show_startup_config,
   char buf[BUFSIZ];
   FILE *confp;
 
+  if (host.noconfig)
+    return CMD_SUCCESS;
+  if (host.config == NULL)
+    return CMD_WARNING;
+
   confp = fopen (host.config, "r");
   if (confp == NULL)
     {
@@ -4203,7 +4214,11 @@ install_default (enum node_type node)
   install_element (node, &show_running_config_cmd);
 }
 
-/* Initialize command interface. Install basic nodes and commands. */
+/* Initialize command interface. Install basic nodes and commands.
+ *
+ * terminal = 0 -- vtysh / no logging, no config control
+ * terminal = 1 -- normal daemon
+ * terminal = -1 -- watchquagga / no logging, but minimal config control */
 void
 cmd_init (int terminal)
 {
@@ -4224,6 +4239,7 @@ cmd_init (int terminal)
   host.enable = NULL;
   host.logfile = NULL;
   host.config = NULL;
+  host.noconfig = (terminal < 0);
   host.lines = -1;
   host.motd = default_motd;
   host.motdfile = NULL;
@@ -4269,12 +4285,17 @@ cmd_init (int terminal)
     {
       install_element (ENABLE_NODE, &config_logmsg_cmd);
       install_default (CONFIG_NODE);
+
+      install_element (VIEW_NODE, &show_thread_cpu_cmd);
+      install_element (ENABLE_NODE, &clear_thread_cpu_cmd);
+
+      install_element (VIEW_NODE, &show_work_queues_cmd);
     }
   
   install_element (CONFIG_NODE, &hostname_cmd);
   install_element (CONFIG_NODE, &no_hostname_cmd);
 
-  if (terminal)
+  if (terminal > 0)
     {
       install_element (CONFIG_NODE, &password_cmd);
       install_element (CONFIG_NODE, &password_text_cmd);
@@ -4313,11 +4334,6 @@ cmd_init (int terminal)
       install_element (CONFIG_NODE, &service_terminal_length_cmd);
       install_element (CONFIG_NODE, &no_service_terminal_length_cmd);
 
-      install_element (VIEW_NODE, &show_thread_cpu_cmd);
-      
-      install_element (ENABLE_NODE, &clear_thread_cpu_cmd);
-      install_element (VIEW_NODE, &show_work_queues_cmd);
-
       vrf_install_commands ();
     }
   srandom(time(NULL));
index ba40770ba3188375bfaac14444cecddea648cacf..d2fc969d7009c3a061ab29097a421e861bcc04d2 100644 (file)
@@ -56,6 +56,7 @@ struct host
 
   /* config file name of this host */
   char *config;
+  int noconfig;
 
   /* Flags for services */
   int advanced;
index 70b35f775d03b8717c84f90463de98d063e2657e..93bbb0429a5140e6af8be06458cefba4b4c2f9e6 100644 (file)
@@ -25,6 +25,7 @@
 #include <sigevent.h>
 #include <lib/version.h>
 #include "command.h"
+#include "memory_vty.h"
 
 #include <getopt.h>
 #include <sys/un.h>
@@ -1304,7 +1305,8 @@ main(int argc, char **argv)
   zprivs_init (&watchquagga_privs);
 
   master = thread_master_create();
-  cmd_init(1);
+  cmd_init(-1);
+  memory_init();
   vty_init(master);
   watchquagga_vty_init();
   vty_serv_sock(NULL, 0, WATCHQUAGGA_VTYSH_PATH);