From 9b6b9f6cdfa7b911b79a312c4bdca0562f79b6f9 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 24 Jan 2021 15:38:38 +0100 Subject: ospf(v3): T3236: T3244: add verify() for used route-map existence --- src/conf_mode/protocols_ospf.py | 2 ++ src/conf_mode/protocols_ospfv3.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'src/conf_mode') diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py index f43929b46..9842d26cd 100755 --- a/src/conf_mode/protocols_ospf.py +++ b/src/conf_mode/protocols_ospf.py @@ -20,6 +20,7 @@ from sys import exit from vyos.config import Config from vyos.configdict import dict_merge +from vyos.configverify import verify_route_maps from vyos.template import render from vyos.template import render_to_string from vyos.util import call @@ -99,6 +100,7 @@ def verify(ospf): if not ospf: return None + verify_route_maps(ospf) return None def generate(ospf): diff --git a/src/conf_mode/protocols_ospfv3.py b/src/conf_mode/protocols_ospfv3.py index f514641ef..2fb600056 100755 --- a/src/conf_mode/protocols_ospfv3.py +++ b/src/conf_mode/protocols_ospfv3.py @@ -20,6 +20,7 @@ from sys import exit from vyos.config import Config from vyos.configdict import dict_merge +from vyos.configverify import verify_route_maps from vyos.template import render from vyos.template import render_to_string from vyos.util import call @@ -48,12 +49,25 @@ def get_config(config=None): conf = Config() base = ['protocols', 'ospfv3'] ospfv3 = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True) + + # Bail out early if configuration tree does not exist + if not conf.exists(base): + return ospfv3 + + # We also need some additional information from the config, prefix-lists + # and route-maps for instance. They will be used in verify() + base = ['policy'] + tmp = conf.get_config_dict(base, key_mangling=('-', '_')) + # Merge policy dict into OSPF dict + ospfv3 = dict_merge(tmp, ospfv3) + return ospfv3 def verify(ospfv3): if not ospfv3: return None + verify_route_maps(ospfv3) return None def generate(ospfv3): -- cgit v1.2.3