diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-03-04 22:02:26 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-03-04 22:02:26 +0100 |
commit | 10ef1bb6c4a8e02081660eddf5918c92151382b7 (patch) | |
tree | 31885f0a2b32b0db18f9e44b634e9176c5de54f0 /src/conf_mode/interfaces-dummy.py | |
parent | 1257c0126bdc10bba605652f624815b2e0350ca2 (diff) | |
parent | 153d1535d954f59cc48ed26f6cc552703b8cbd73 (diff) | |
download | vyos-1x-10ef1bb6c4a8e02081660eddf5918c92151382b7.tar.gz vyos-1x-10ef1bb6c4a8e02081660eddf5918c92151382b7.zip |
Merge branch 't31-vrf' of github.com:c-po/vyos-1x into current
* 't31-vrf' of github.com:c-po/vyos-1x:
vrf: T31: enable vrf support for dummy interface
templates: T2099: make op-mode path completion helper working
vrf: T31: reorder routing table lookups
vrf: T31: adding unreachable routes to the routing tables
vrf: T31: prior to the v4.8 kernel iif and oif rules are needed
vrf: T31: create iproute2 table to name mapping reference
vrf: T31: rename 'vrf disable-bind-to-all ipv4' to 'vrf bind-to-all'
vrf: T31: support add/remove of interfaces from vrf
vrf: T31: remove superfluous vyos.vrf library functions
vrf: T31: reduce script complexity
vrf: T31: no need to use sudo calls in vrf.py
vrf: T31: make 'show vrf' command behave like other 'show interface commands'
xml: include: description: adjust help message
vrf: T31: improve help for routing table
vrf: T31: reuse interface-description.xml.i for instance description
vrf: T31: use embedded regex on 'vrf name' instead of python script
vrf: T31: initial support for a VRF backend in XML/Python
ifconfig: T2057: generic interface option setting
Diffstat (limited to 'src/conf_mode/interfaces-dummy.py')
-rwxr-xr-x | src/conf_mode/interfaces-dummy.py | 18 |
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') |