diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-03-04 21:53:48 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-03-04 21:53:48 +0100 |
commit | 153d1535d954f59cc48ed26f6cc552703b8cbd73 (patch) | |
tree | 7dd2204308e90b25cf83075f3f4e6f7d2325899f | |
parent | 94527843ecbf92d48e367b6b5e255da4e958d0be (diff) | |
download | vyos-1x-153d1535d954f59cc48ed26f6cc552703b8cbd73.tar.gz vyos-1x-153d1535d954f59cc48ed26f6cc552703b8cbd73.zip |
vrf: T31: enable vrf support for dummy interface
-rw-r--r-- | interface-definitions/interfaces-dummy.xml.in | 1 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-dummy.py | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/interface-definitions/interfaces-dummy.xml.in b/interface-definitions/interfaces-dummy.xml.in index 39809a610..5229e602a 100644 --- a/interface-definitions/interfaces-dummy.xml.in +++ b/interface-definitions/interfaces-dummy.xml.in @@ -19,6 +19,7 @@ #include <include/address-ipv4-ipv6.xml.i> #include <include/interface-description.xml.i> #include <include/interface-disable.xml.i> + #include <include/interface-vrf.xml.i> </children> </tagNode> </children> 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') |