summaryrefslogtreecommitdiff
path: root/python/vyos/configdict.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-04-21 21:43:22 +0200
committerChristian Poessinger <christian@poessinger.com>2022-04-21 21:43:47 +0200
commita9764320d00a8540d8fb1f7ee67b774306389afc (patch)
tree9723cb8d09cf4dac3fe82a8adf36d02c8d5baf0d /python/vyos/configdict.py
parent6ae413b2ca10413b393a1343cbfb23126fa99a50 (diff)
downloadvyos-1x-a9764320d00a8540d8fb1f7ee67b774306389afc.tar.gz
vyos-1x-a9764320d00a8540d8fb1f7ee67b774306389afc.zip
vyos.ifconfig: T4384: get_interface_dict() should provide "ifname" key for VIFs
Diffstat (limited to 'python/vyos/configdict.py')
-rw-r--r--python/vyos/configdict.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py
index 4a7a3a886..df4c80f23 100644
--- a/python/vyos/configdict.py
+++ b/python/vyos/configdict.py
@@ -383,7 +383,6 @@ def get_interface_dict(config, base, ifname=''):
Return a dictionary with the necessary interface config keys.
"""
-
if not ifname:
from vyos import ConfigError
# determine tagNode instance
@@ -484,6 +483,9 @@ def get_interface_dict(config, base, ifname=''):
# identical for all types of VLAN interfaces as they all include the same
# XML definitions which hold the defaults.
for vif, vif_config in dict.get('vif', {}).items():
+ # Add subinterface name to dictionary
+ dict['vif'][vif].update({'ifname' : f'{ifname}.{vif}'})
+
default_vif_values = defaults(base + ['vif'])
# XXX: T2665: When there is no DHCPv6-PD configuration given, we can safely
# remove the default values from the dict.
@@ -515,6 +517,9 @@ def get_interface_dict(config, base, ifname=''):
if dhcp: dict['vif'][vif].update({'dhcp_options_changed' : ''})
for vif_s, vif_s_config in dict.get('vif_s', {}).items():
+ # Add subinterface name to dictionary
+ dict['vif_s'][vif_s].update({'ifname' : f'{ifname}.{vif_s}'})
+
default_vif_s_values = defaults(base + ['vif-s'])
# XXX: T2665: we only wan't the vif-s defaults - do not care about vif-c
if 'vif_c' in default_vif_s_values: del default_vif_s_values['vif_c']
@@ -551,6 +556,9 @@ def get_interface_dict(config, base, ifname=''):
if dhcp: dict['vif_s'][vif_s].update({'dhcp_options_changed' : ''})
for vif_c, vif_c_config in vif_s_config.get('vif_c', {}).items():
+ # Add subinterface name to dictionary
+ dict['vif_s'][vif_s]['vif_c'][vif_c].update({'ifname' : f'{ifname}.{vif_s}.{vif_c}'})
+
default_vif_c_values = defaults(base + ['vif-s', 'vif-c'])
# XXX: T2665: When there is no DHCPv6-PD configuration given, we can safely