diff options
Diffstat (limited to 'src/conf_mode/protocols_bgp.py')
-rwxr-xr-x | src/conf_mode/protocols_bgp.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py index 79d97860b..fb4a0488c 100755 --- a/src/conf_mode/protocols_bgp.py +++ b/src/conf_mode/protocols_bgp.py @@ -27,7 +27,7 @@ from vyos.configverify import verify_vrf from vyos.template import is_ip from vyos.template import is_interface from vyos.template import render_to_string -from vyos.util import dict_search +from vyos.utils.dict import dict_search from vyos.utils.network import get_interface_vrf from vyos.validate import is_addr_assigned from vyos import ConfigError @@ -242,9 +242,14 @@ def verify(bgp): # Verify vrf on interface and bgp section if 'interface' in bgp: for interface in bgp['interface']: + error_msg = f'Interface "{interface}" belongs to different VRF instance' tmp = get_interface_vrf(interface) - if ('vrf' in bgp and bgp['vrf'] != tmp) or tmp != 'default': - raise ConfigError(f'Interface "{interface}" belongs to different VRF instance!') + if 'vrf' in bgp: + if bgp['vrf'] != tmp: + vrf = bgp['vrf'] + raise ConfigError(f'{error_msg} "{vrf}"!') + elif tmp != 'default': + raise ConfigError(f'{error_msg} "{tmp}"!') # Common verification for both peer-group and neighbor statements for neighbor in ['neighbor', 'peer_group']: |