summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-04 21:53:48 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-04 21:53:48 +0100
commit153d1535d954f59cc48ed26f6cc552703b8cbd73 (patch)
tree7dd2204308e90b25cf83075f3f4e6f7d2325899f /src
parent94527843ecbf92d48e367b6b5e255da4e958d0be (diff)
downloadvyos-1x-153d1535d954f59cc48ed26f6cc552703b8cbd73.tar.gz
vyos-1x-153d1535d954f59cc48ed26f6cc552703b8cbd73.zip
vrf: T31: enable vrf support for dummy interface
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interfaces-dummy.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/conf_mode/interfaces-dummy.py b/src/conf_mode/interfaces-dummy.py
index e79e6222d..10cae5d7d 100755
--- a/src/conf_mode/interfaces-dummy.py
+++ b/src/conf_mode/interfaces-dummy.py
@@ -18,6 +18,7 @@ import os
from copy import deepcopy
from sys import exit
+from netifaces import interfaces
from vyos.ifconfig import DummyIf
from vyos.configdict import list_diff
@@ -30,7 +31,8 @@ default_config_data = {
'deleted': False,
'description': '',
'disable': False,
- 'intf': ''
+ 'intf': '',
+ 'vrf': ''
}
def get_config():
@@ -69,9 +71,17 @@ def get_config():
act_addr = conf.return_values('address')
dummy['address_remove'] = list_diff(eff_addr, act_addr)
+ # retrieve VRF instance
+ if conf.exists('vrf'):
+ dummy['vrf'] = conf.return_value('vrf')
+
return dummy
def verify(dummy):
+ vrf_name = dummy['vrf']
+ if vrf_name and vrf_name not in interfaces():
+ raise ConfigError(f'VRF "{vrf_name}" does not exist')
+
return None
def generate(dummy):
@@ -95,6 +105,12 @@ def apply(dummy):
for addr in dummy['address']:
d.add_addr(addr)
+ # assign to VRF
+ if dummy['vrf']:
+ d.add_vrf(dummy['vrf'])
+ else:
+ d.del_vrf(dummy['vrf'])
+
# disable interface on demand
if dummy['disable']:
d.set_state('down')