diff options
author | Russ White <russ@riw.us> | 2020-01-28 17:31:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 17:31:25 +0100 |
commit | 1746db70adeca9daa1e39da0031dab061089cb69 (patch) | |
tree | bf03f07721b520b79a39f950f615186caebb9cc6 | |
parent | Merge pull request #5706 from mjstapp/fix_nh_debug_show (diff) | |
parent | vtysh: add a cli that reads a file into running-config (diff) | |
download | frr-1746db70adeca9daa1e39da0031dab061089cb69.tar.xz frr-1746db70adeca9daa1e39da0031dab061089cb69.zip |
Merge pull request #5721 from mjstapp/vty_copy_to_runn
vtysh: add a cli that reads a file into running-config
-rw-r--r-- | doc/user/vtysh.rst | 8 | ||||
-rw-r--r-- | vtysh/vtysh.c | 19 |
2 files changed, 27 insertions, 0 deletions
diff --git a/doc/user/vtysh.rst b/doc/user/vtysh.rst index 6d569f5fb..dd754a92e 100644 --- a/doc/user/vtysh.rst +++ b/doc/user/vtysh.rst @@ -22,6 +22,14 @@ administrator with an external editor. have effect for vtysh) need to be manually updated in :file:`vtysh.conf`. +.. index:: copy FILENAME running-config +.. clicmd:: copy FILENAME running-config + + Process and load a configuration file manually; each line in the + file is read and processed as if it were being typed (or piped) to + vtysh. + + Pager usage =========== diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index b7d35caa3..238b1d905 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -3058,6 +3058,24 @@ DEFUN (vtysh_copy_running_config, return vtysh_write_memory(self, vty, argc, argv); } +DEFUN (vtysh_copy_to_running, + vtysh_copy_to_running_cmd, + "copy FILENAME running-config", + "Apply a configuration file\n" + "Configuration file to read\n" + "Apply to current configuration\n") +{ + int ret; + const char *fname = argv[1]->arg; + + ret = vtysh_read_config(fname); + + /* Return to enable mode - the 'read_config' api leaves us up a level */ + vtysh_execute_no_pager("enable"); + + return ret; +} + DEFUN (vtysh_terminal_paginate, vtysh_terminal_paginate_cmd, "[no] terminal paginate", @@ -4024,6 +4042,7 @@ void vtysh_init_vty(void) install_element(INTERFACE_NODE, &vtysh_link_params_cmd); install_element(ENABLE_NODE, &vtysh_show_running_config_cmd); install_element(ENABLE_NODE, &vtysh_copy_running_config_cmd); + install_element(ENABLE_NODE, &vtysh_copy_to_running_cmd); install_element(CONFIG_NODE, &vtysh_vrf_cmd); install_element(VRF_NODE, &vtysh_vrf_netns_cmd); |