summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-07-31 23:23:32 +0200
committerChristian Poessinger <christian@poessinger.com>2021-07-31 23:23:32 +0200
commitc7338eebe9b759885bb4fa8580c787382b20e29f (patch)
tree464e1e6ab3601279bbf371185a0f5db872c4d1b7 /src
parent58a77a7aea020d32fc4c90301b9937609fc8a0eb (diff)
downloadvyos-1x-c7338eebe9b759885bb4fa8580c787382b20e29f.tar.gz
vyos-1x-c7338eebe9b759885bb4fa8580c787382b20e29f.zip
bgp: vrf: T3694: cannot delete default BGP instance when VRF BGP instance exists
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/protocols_bgp.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index 1a2fabded..9ecfd07fe 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -57,6 +57,11 @@ def get_config(config=None):
if not conf.exists(base):
bgp.update({'deleted' : ''})
+ if not vrf:
+ # We are running in the default VRF context, thus we can not delete
+ # our main BGP instance if there are dependent BGP VRF instances.
+ bgp['dependent_vrfs'] = conf.get_config_dict(['vrf', 'name'],
+ key_mangling=('-', '_'), get_first_key=True, no_tag_node_value_mangle=True)
return bgp
# We also need some additional information from the config, prefix-lists
@@ -96,6 +101,11 @@ def verify_remote_as(peer_config, bgp_config):
def verify(bgp):
if not bgp or 'deleted' in bgp:
+ if 'dependent_vrfs' in bgp:
+ for vrf, vrf_options in bgp['dependent_vrfs'].items():
+ if dict_search('protocols.bgp', vrf_options) != None:
+ raise ConfigError('Cannot delete default BGP instance, ' \
+ 'dependent VRF instance(s) exist!')
return None
if 'local_as' not in bgp: