summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-22 16:33:12 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-22 19:37:26 +0100
commit93c0416efc685424a0750fe9cb9728d5e6450073 (patch)
treecdff65606afa62536f2aa04d2f2c3f8e05c894f7 /src/conf_mode
parent0ddd684ff12b297313331a1c87f36d8308eade8d (diff)
downloadvyos-1x-93c0416efc685424a0750fe9cb9728d5e6450073.tar.gz
vyos-1x-93c0416efc685424a0750fe9cb9728d5e6450073.zip
ospf: T3236: support processing by vyos-configd
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/protocols_ospf.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py
index fc66a884c..f47b21498 100755
--- a/src/conf_mode/protocols_ospf.py
+++ b/src/conf_mode/protocols_ospf.py
@@ -31,6 +31,7 @@ from vyos import airbag
airbag.enable()
config_file = r'/tmp/ospf.frr'
+frr_daemon = 'ospfd'
DEBUG = os.path.exists('/tmp/ospf.debug')
if DEBUG:
@@ -40,8 +41,11 @@ if DEBUG:
ch = logging.StreamHandler()
lg.addHandler(ch)
-def get_config():
- conf = Config()
+def get_config(config=None):
+ if config:
+ conf = config
+ else:
+ conf = Config()
base = ['protocols', 'ospf']
ospf = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True)
@@ -90,8 +94,9 @@ def generate(ospf):
def apply(ospf):
# Save original configuration prior to starting any commit actions
frr_cfg = frr.FRRConfig()
- frr_cfg.load_configuration(daemon='ospfd')
- frr_cfg.modify_section(f'router ospf', '')
+ frr_cfg.load_configuration(frr_daemon)
+ frr_cfg.modify_section('router ospf', '')
+ frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', ospf['new_frr_config'])
# Debugging
if DEBUG:
@@ -107,13 +112,13 @@ def apply(ospf):
print(f'Modified config:\n')
print(f'{frr_cfg}')
- frr_cfg.commit_configuration(daemon='ospfd')
+ frr_cfg.commit_configuration(frr_daemon)
# If FRR config is blank, rerun the blank commit x times due to frr-reload
# behavior/bug not properly clearing out on one commit.
if ospf['new_frr_config'] == '':
for a in range(5):
- frr_cfg.commit_configuration(daemon='ospfd')
+ frr_cfg.commit_configuration(frr_daemon)
return None