diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-03-24 17:45:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 17:45:19 +0100 |
commit | 90ecb7ec0e75596d5ec69b119954313c0cb77a43 (patch) | |
tree | e8b4e34ff687c1df08b1f06ac75de196026d5402 /python/vyos/frr.py | |
parent | 00d0ca6f8aafe5be55624ccd1462d855565b124f (diff) | |
parent | c106aead9e297f973e91c3ea5371790040c05de3 (diff) | |
download | vyos-1x-90ecb7ec0e75596d5ec69b119954313c0cb77a43.tar.gz vyos-1x-90ecb7ec0e75596d5ec69b119954313c0cb77a43.zip |
Merge pull request #784 from sever-sever/T3217
routing: T3217: Save configs of daemon per commit
Diffstat (limited to 'python/vyos/frr.py')
-rw-r--r-- | python/vyos/frr.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/python/vyos/frr.py b/python/vyos/frr.py index 69c7a14ce..ec0bef37a 100644 --- a/python/vyos/frr.py +++ b/python/vyos/frr.py @@ -86,6 +86,7 @@ _frr_daemons = ['zebra', 'bgpd', 'fabricd', 'isisd', 'ospf6d', 'ospfd', 'pbrd', path_vtysh = '/usr/bin/vtysh' path_frr_reload = '/usr/lib/frr/frr-reload.py' +path_config = '/run/frr' class FrrError(Exception): @@ -207,6 +208,25 @@ def reload_configuration(config, daemon=None): return output +def save_configuration(daemon=None): + """Save FRR configuration to /run/frr/{daemon}.conf + It save configuration on each commit. + """ + if daemon and daemon not in _frr_daemons: + raise ValueError(f'The specified daemon type is not supported {repr(daemon)}') + + cmd = f"{path_vtysh} -d {daemon} -c 'show run no-header'" + output, code = util.popen(cmd, stderr=util.STDOUT) + if code: + raise OSError(code, output) + + with open(f"{path_config}/{daemon}.conf", "w") as f: + f.write(output) + config = output + + return config + + def execute(command): """ Run commands inside vtysh command: str containing commands to execute inside a vtysh session |