summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-06 20:03:36 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-06 20:03:36 +0100
commit752d656424afc908f87b2b0daf9bf3bd7e7f092b (patch)
treed728b9464a9661ee7fd718135690087a984d816a /src/conf_mode
parent6d403e5d3831fcb1944992e70f0bfa74e1477c74 (diff)
downloadvyos-1x-752d656424afc908f87b2b0daf9bf3bd7e7f092b.tar.gz
vyos-1x-752d656424afc908f87b2b0daf9bf3bd7e7f092b.zip
vrf: T31: enable vrf support for bonding interface
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/interfaces-bonding.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/conf_mode/interfaces-bonding.py b/src/conf_mode/interfaces-bonding.py
index dcb0b59ed..617506c06 100755
--- a/src/conf_mode/interfaces-bonding.py
+++ b/src/conf_mode/interfaces-bonding.py
@@ -58,7 +58,8 @@ default_config_data = {
'vif_s': [],
'vif_s_remove': [],
'vif': [],
- 'vif_remove': []
+ 'vif_remove': [],
+ 'vrf': ''
}
@@ -221,8 +222,10 @@ def get_config():
if conf.exists('primary'):
bond['primary'] = conf.return_value('primary')
- # re-set configuration level to parse new nodes
- conf.set_level(cfg_base)
+ # retrieve VRF instance
+ if conf.exists('vrf'):
+ bond['vrf'] = conf.return_value('vrf')
+
# get vif-s interfaces (currently effective) - to determine which vif-s
# interface is no longer present and needs to be removed
eff_intf = conf.list_effective_nodes('vif-s')
@@ -265,6 +268,9 @@ def verify(bond):
raise ConfigError('Interface "{}" is not part of the bond' \
.format(bond['primary']))
+ vrf_name = bond['vrf']
+ if vrf_name and vrf_name not in interfaces():
+ raise ConfigError(f'VRF "{vrf_name}" does not exist')
# DHCPv6 parameters-only and temporary address are mutually exclusive
for vif_s in bond['vif_s']:
@@ -472,6 +478,12 @@ def apply(bond):
for addr in bond['address']:
b.add_addr(addr)
+ # assign to VRF
+ if bond['vrf']:
+ b.add_vrf(bond['vrf'])
+ else:
+ b.del_vrf(bond['vrf'])
+
# remove no longer required service VLAN interfaces (vif-s)
for vif_s in bond['vif_s_remove']:
b.del_vlan(vif_s)