summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-11-24 20:35:31 +0100
committerChristian Poessinger <christian@poessinger.com>2022-11-24 20:35:31 +0100
commitf9a5286f163b27b51eb5e9a801c5d646c07a7990 (patch)
tree70acf89e4db741e7e9c0dc8b18e49dacfac49a6f /src/conf_mode
parent1e6710d8e193cb919b50da336a27378e130c54b0 (diff)
downloadvyos-1x-f9a5286f163b27b51eb5e9a801c5d646c07a7990.tar.gz
vyos-1x-f9a5286f163b27b51eb5e9a801c5d646c07a7990.zip
veth: T4825: minor improvements on XML peer-name handling
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/interfaces-virtual-ethernet.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/conf_mode/interfaces-virtual-ethernet.py b/src/conf_mode/interfaces-virtual-ethernet.py
index 91609ded9..b1819233c 100755
--- a/src/conf_mode/interfaces-virtual-ethernet.py
+++ b/src/conf_mode/interfaces-virtual-ethernet.py
@@ -28,7 +28,6 @@ from vyos.ifconfig import VethIf
airbag.enable()
-
def get_config(config=None):
"""
Retrive CLI config as dictionary. Dictionary can never be empty, as at
@@ -41,10 +40,12 @@ def get_config(config=None):
base = ['interfaces', 'virtual-ethernet']
ifname, veth = get_interface_dict(conf, base)
- veth_dict = conf.get_config_dict(base, key_mangling=('-', '_'),
- get_first_key=True,
- no_tag_node_value_mangle=True)
- veth['config_dict'] = veth_dict
+ # We need to know all other veth related interfaces as veth requires a 1:1
+ # mapping for the peer-names. The Linux kernel automatically creates both
+ # interfaces, the local one and the peer-name, but VyOS also needs a peer
+ # interfaces configrued on the CLI so we can assign proper IP addresses etc.
+ veth['other_interfaces'] = conf.get_config_dict(base, key_mangling=('-', '_'),
+ get_first_key=True, no_tag_node_value_mangle=True)
return veth
@@ -58,12 +59,13 @@ def verify(veth):
verify_address(veth)
if 'peer_name' not in veth:
- raise ConfigError(
- f'Remote peer name must be set for \"{veth["ifname"]}\"!')
+ raise ConfigError(f'Remote peer name must be set for "{veth["ifname"]}"!')
- if veth['peer_name'] not in veth['config_dict'].keys():
- raise ConfigError(
- f'Interface \"{veth["peer_name"]}\" is not configured!')
+ if veth['peer_name'] not in veth['other_interfaces']:
+ peer_name = veth['peer_name']
+ ifname = veth['ifname']
+ raise ConfigError(f'Used peer-name "{peer_name}" on interface "{ifname}" ' \
+ 'is not configured!')
return None
@@ -71,7 +73,6 @@ def verify(veth):
def generate(peth):
return None
-
def apply(veth):
# Check if the Veth interface already exists
if 'rebuild_required' in veth or 'deleted' in veth: