summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/configd-include.json1
-rwxr-xr-xsrc/conf_mode/protocols_ospf.py17
2 files changed, 12 insertions, 6 deletions
diff --git a/data/configd-include.json b/data/configd-include.json
index 8369f0e13..318ab0e14 100644
--- a/data/configd-include.json
+++ b/data/configd-include.json
@@ -34,6 +34,7 @@
"protocols_igmp.py",
"protocols_isis.py",
"protocols_mpls.py",
+"protocols_ospf.py",
"protocols_pim.py",
"protocols_rip.py",
"protocols_static_multicast.py",
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