diff options
author | Christian Breunig <christian@breunig.cc> | 2024-04-01 20:40:16 +0200 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2024-04-01 21:26:16 +0200 |
commit | e5af1f0905991103b12302892e6f0070bbb7b770 (patch) | |
tree | 6167a7c3aaa92f75f91788855fd10d294b04c89c /python/vyos | |
parent | 5bb27f0c6220fd940b63cdd37a60c312c0ac3efd (diff) | |
download | vyos-1x-e5af1f0905991103b12302892e6f0070bbb7b770.tar.gz vyos-1x-e5af1f0905991103b12302892e6f0070bbb7b770.zip |
ssh: T6192: allow binding to multiple VRF instances
Currently VyOS only supports binding a service to one individual VRF. It might
become handy to have the services (initially it will be VRF, NTP and SNMP) be
bound to multiple VRFs.
Changed VRF from leafNode to multi leafNode with defaultValue: default - which
is the name of the default VRF.
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/configverify.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index 894dc3286..651036bad 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -99,10 +99,17 @@ def verify_vrf(config): Common helper function used by interface implementations to perform recurring validation of VRF configuration. """ - from netifaces import interfaces - if 'vrf' in config and config['vrf'] != 'default': - if config['vrf'] not in interfaces(): - raise ConfigError('VRF "{vrf}" does not exist'.format(**config)) + from vyos.utils.network import interface_exists + if 'vrf' in config: + vrfs = config['vrf'] + if isinstance(vrfs, str): + vrfs = [vrfs] + + for vrf in vrfs: + if vrf == 'default': + continue + if not interface_exists(vrf): + raise ConfigError(f'VRF "{vrf}" does not exist!') if 'is_bridge_member' in config: raise ConfigError( |