diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-01-16 15:18:31 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-01-16 15:31:33 +0100 |
commit | 8dab92c65127a629df6607e7b46504a115943f72 (patch) | |
tree | 27051631e139e33595ab742fe669e7119b7ec2ff /src/conf_mode/vrf.py | |
parent | 86d49dbd7167c261fc6072694db7ee38206f1d94 (diff) | |
download | vyos-1x-8dab92c65127a629df6607e7b46504a115943f72.tar.gz vyos-1x-8dab92c65127a629df6607e7b46504a115943f72.zip |
vrf: T31: add support for - and _ in VRF names
(cherry picked from commit 8953a14b01a4183ea890f1c3d569aae54e363614)
Diffstat (limited to 'src/conf_mode/vrf.py')
-rwxr-xr-x | src/conf_mode/vrf.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/conf_mode/vrf.py b/src/conf_mode/vrf.py index ebad7e246..6c6e219a5 100755 --- a/src/conf_mode/vrf.py +++ b/src/conf_mode/vrf.py @@ -74,18 +74,20 @@ def get_config(config=None): conf = Config() base = ['vrf'] - vrf = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True) + vrf = conf.get_config_dict(base, get_first_key=True) # determine which VRF has been removed - tmp = node_changed(conf, base + ['name']) - for name in tmp: - vrf.update({'vrf_remove' : { name : ''}}) + for name in node_changed(conf, base + ['name']): + if 'vrf_remove' not in vrf: + vrf.update({'vrf_remove' : {}}) + + vrf['vrf_remove'][name] = {} # get VRF bound interfaces interfaces = vrf_interfaces(conf, name) - if interfaces: vrf.update({'vrf_remove' : { name : {'interfaces' : ''}}}) + if interfaces: vrf['vrf_remove'][name]['interface'] = interfaces # get VRF bound routing instances routes = vrf_routing(conf, name) - if routes: vrf.update({'vrf_remove' : { name : {'routes' : routes}}}) + if routes: vrf['vrf_remove'][name]['route'] = routes return vrf @@ -93,10 +95,10 @@ def verify(vrf): # ensure VRF is not assigned to any interface if 'vrf_remove' in vrf: for name, config in vrf['vrf_remove'].items(): - if 'interfaces' in config: + if 'interface' in config: raise ConfigError(f'Can not remove VRF "{name}", it still has '\ f'member interfaces!') - if 'routes' in config: + if 'route' in config: raise ConfigError(f'Can not remove VRF "{name}", it still has '\ f'static routes installed!') |