]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh: When dry-running no need to start/end configuration 7744/head
authorDonald Sharp <sharpd@nvidia.com>
Tue, 15 Dec 2020 19:45:23 +0000 (14:45 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 15 Dec 2020 20:33:17 +0000 (15:33 -0500)
When doing a dry run don't send start/end configuration
commands.

Ticket: CM-32665
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
vtysh/vtysh.c
vtysh/vtysh.h
vtysh/vtysh_config.c
vtysh/vtysh_main.c

index c78132508fddfee71dba1864117a6ff7ef71ec6a..c3fb663f558ffc06f7099b6bdbdf69f679224270 100644 (file)
@@ -3187,7 +3187,7 @@ DEFUN (vtysh_copy_to_running,
        int ret;
        const char *fname = argv[1]->arg;
 
-       ret = vtysh_read_config(fname);
+       ret = vtysh_read_config(fname, true);
 
        /* Return to enable mode - the 'read_config' api leaves us up a level */
        vtysh_execute_no_pager("enable");
index d2675a81b9650120b419e72d0533b2e57109ac26..b2e37074f71aa947bc87852ec17f27e9ef4d362f 100644 (file)
@@ -92,7 +92,7 @@ void config_add_line(struct list *, const char *);
 
 int vtysh_mark_file(const char *filename);
 
-int vtysh_read_config(const char *);
+int vtysh_read_config(const char *filename, bool dry_run);
 int vtysh_write_config_integrated(void);
 
 void vtysh_config_parse_line(void *, const char *);
index c8154d9694a50a5e7582c69a81b2d5d42a4f373b..47f426b5e0723c31903f1e1b1321e90ad9bf75c0 100644 (file)
@@ -515,7 +515,7 @@ void vtysh_config_dump(void)
 }
 
 /* Read up configuration file from file_name. */
-static int vtysh_read_file(FILE *confp)
+static int vtysh_read_file(FILE *confp, bool dry_run)
 {
        struct vty *vty;
        int ret;
@@ -528,12 +528,14 @@ static int vtysh_read_file(FILE *confp)
        vtysh_execute_no_pager("enable");
        vtysh_execute_no_pager("configure terminal");
 
-       vtysh_execute_no_pager("XFRR_start_configuration");
+       if (!dry_run)
+               vtysh_execute_no_pager("XFRR_start_configuration");
 
        /* Execute configuration file. */
        ret = vtysh_config_from_file(vty, confp);
 
-       vtysh_execute_no_pager("XFRR_end_configuration");
+       if (!dry_run)
+               vtysh_execute_no_pager("XFRR_end_configuration");
 
        vtysh_execute_no_pager("end");
        vtysh_execute_no_pager("disable");
@@ -544,7 +546,7 @@ static int vtysh_read_file(FILE *confp)
 }
 
 /* Read up configuration file from config_default_dir. */
-int vtysh_read_config(const char *config_default_dir)
+int vtysh_read_config(const char *config_default_dir, bool dry_run)
 {
        FILE *confp = NULL;
        int ret;
@@ -557,7 +559,7 @@ int vtysh_read_config(const char *config_default_dir)
                return CMD_ERR_NO_FILE;
        }
 
-       ret = vtysh_read_file(confp);
+       ret = vtysh_read_file(confp, dry_run);
        fclose(confp);
 
        return (ret);
index 6e28df79d6c54823aeb6c11a2009d56c26c2ab9f..db7cc312d684ed4d022cc5ef9e2180a460a347bd 100644 (file)
@@ -459,7 +459,7 @@ int main(int argc, char **argv, char **env)
                /* Read vtysh configuration file before connecting to daemons.
                 * (file may not be readable to calling user in SUID mode) */
                suid_on();
-               vtysh_read_config(vtysh_config);
+               vtysh_read_config(vtysh_config, dryrun);
                suid_off();
        }
        /* Error code library system */
@@ -478,9 +478,9 @@ int main(int argc, char **argv, char **env)
        /* Start execution only if not in dry-run mode */
        if (dryrun && !cmd) {
                if (inputfile) {
-                       ret = vtysh_read_config(inputfile);
+                       ret = vtysh_read_config(inputfile, dryrun);
                } else {
-                       ret = vtysh_read_config(frr_config);
+                       ret = vtysh_read_config(frr_config, dryrun);
                }
 
                exit(ret);
@@ -561,7 +561,7 @@ int main(int argc, char **argv, char **env)
 
        if (inputfile) {
                vtysh_flock_config(inputfile);
-               ret = vtysh_read_config(inputfile);
+               ret = vtysh_read_config(inputfile, dryrun);
                vtysh_unflock_config();
                exit(ret);
        }
@@ -670,7 +670,7 @@ int main(int argc, char **argv, char **env)
        /* Boot startup configuration file. */
        if (boot_flag) {
                vtysh_flock_config(frr_config);
-               ret = vtysh_read_config(frr_config);
+               ret = vtysh_read_config(frr_config, dryrun);
                vtysh_unflock_config();
                if (ret) {
                        fprintf(stderr,