From d9d923ea4e0bbe0cc154dc2fbdd626585b5d7449 Mon Sep 17 00:00:00 2001 From: sever-sever Date: Fri, 2 Apr 2021 20:20:54 +0000 Subject: frr: T3217: Abbility to save routing configs --- python/vyos/frr.py | 25 ++++++------------------- src/conf_mode/protocols_bgp.py | 4 ++-- src/conf_mode/protocols_isis.py | 4 ++-- src/conf_mode/protocols_ospf.py | 4 ++-- src/conf_mode/protocols_ospfv3.py | 4 ++-- src/conf_mode/protocols_rip.py | 4 ++-- src/conf_mode/protocols_ripng.py | 4 ++-- src/conf_mode/protocols_static.py | 4 ++-- 8 files changed, 20 insertions(+), 33 deletions(-) diff --git a/python/vyos/frr.py b/python/vyos/frr.py index 668489636..de3dbe6e9 100644 --- a/python/vyos/frr.py +++ b/python/vyos/frr.py @@ -69,6 +69,7 @@ import tempfile import re from vyos import util from vyos.util import chown +from vyos.util import cmd import logging from logging.handlers import SysLogHandler import os @@ -209,28 +210,14 @@ 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. +def save_configuration(): + """Save FRR configuration to /run/frr/config/frr.conf + It save configuration on each commit. T3217 """ - 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) - daemon_conf = f'{path_config}/{daemon}.conf' + cmd(f'{path_vtysh} -n -w') - with open(daemon_conf, "w") as f: - f.write(output) - # Set permissions (frr:frr) for /run/frr/{daemon}.conf - if os.path.exists(daemon_conf): - chown(daemon_conf, 'frr', 'frr') - config = output - - return config + return def execute(command): diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py index 6770865ff..73cfa9b83 100755 --- a/src/conf_mode/protocols_bgp.py +++ b/src/conf_mode/protocols_bgp.py @@ -213,8 +213,8 @@ def apply(bgp): for a in range(5): frr_cfg.commit_configuration(frr_daemon) - # Save configuration to /run/frr/{daemon}.conf - frr.save_configuration(frr_daemon) + # Save configuration to /run/frr/config/frr.conf + frr.save_configuration() return None diff --git a/src/conf_mode/protocols_isis.py b/src/conf_mode/protocols_isis.py index 02cf9970c..571520cfe 100755 --- a/src/conf_mode/protocols_isis.py +++ b/src/conf_mode/protocols_isis.py @@ -209,8 +209,8 @@ def apply(isis): for a in range(5): frr_cfg.commit_configuration(frr_daemon) - # Save configuration to /run/frr/{daemon}.conf - frr.save_configuration(frr_daemon) + # Save configuration to /run/frr/config/frr.conf + frr.save_configuration() return None diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py index b4ee8659a..30cc33dcf 100755 --- a/src/conf_mode/protocols_ospf.py +++ b/src/conf_mode/protocols_ospf.py @@ -200,8 +200,8 @@ def apply(ospf): for a in range(5): frr_cfg.commit_configuration(frr_daemon) - # Save configuration to /run/frr/{daemon}.conf - frr.save_configuration(frr_daemon) + # Save configuration to /run/frr/config/frr.conf + frr.save_configuration() return None diff --git a/src/conf_mode/protocols_ospfv3.py b/src/conf_mode/protocols_ospfv3.py index f3beab204..42b6462e3 100755 --- a/src/conf_mode/protocols_ospfv3.py +++ b/src/conf_mode/protocols_ospfv3.py @@ -91,8 +91,8 @@ def apply(ospfv3): for a in range(5): frr_cfg.commit_configuration(frr_daemon) - # Save configuration to /run/frr/{daemon}.conf - frr.save_configuration(frr_daemon) + # Save configuration to /run/frr/config/frr.conf + frr.save_configuration() return None diff --git a/src/conf_mode/protocols_rip.py b/src/conf_mode/protocols_rip.py index 34d42d630..e7eafd059 100755 --- a/src/conf_mode/protocols_rip.py +++ b/src/conf_mode/protocols_rip.py @@ -116,8 +116,8 @@ def apply(rip): for a in range(5): frr_cfg.commit_configuration(frr_daemon) - # Save configuration to /run/frr/{daemon}.conf - frr.save_configuration(frr_daemon) + # Save configuration to /run/frr/config/frr.conf + frr.save_configuration() return None diff --git a/src/conf_mode/protocols_ripng.py b/src/conf_mode/protocols_ripng.py index eff4297f9..140133bd0 100755 --- a/src/conf_mode/protocols_ripng.py +++ b/src/conf_mode/protocols_ripng.py @@ -115,8 +115,8 @@ def apply(ripng): for a in range(5): frr_cfg.commit_configuration(frr_daemon) - # Save configuration to /run/frr/{daemon}.conf - frr.save_configuration(frr_daemon) + # Save configuration to /run/frr/config/frr.conf + frr.save_configuration() return None diff --git a/src/conf_mode/protocols_static.py b/src/conf_mode/protocols_static.py index 0de073a6d..7ae952af8 100755 --- a/src/conf_mode/protocols_static.py +++ b/src/conf_mode/protocols_static.py @@ -97,8 +97,8 @@ def apply(static): for a in range(5): frr_cfg.commit_configuration(frr_daemon) - # Save configuration to /run/frr/{daemon}.conf - frr.save_configuration(frr_daemon) + # Save configuration to /run/frr/config/frr.conf + frr.save_configuration() return None -- cgit v1.2.3