summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-05-06 08:02:42 +0200
committerGitHub <noreply@github.com>2023-05-06 08:02:42 +0200
commit5518738952cda46cff5c8bda7dd896871691b001 (patch)
treeee17860e82bfa355ddd8acd759372f158cd042d1 /python
parent2c5307d42e0d4cc1a81210c76a63271d66f2888b (diff)
parent3c98ddfa180a464683b841c4af97ec4c185e3e29 (diff)
downloadvyos-1x-5518738952cda46cff5c8bda7dd896871691b001.tar.gz
vyos-1x-5518738952cda46cff5c8bda7dd896871691b001.zip
Merge pull request #1981 from c-po/equuleus
vyos.ifconfig: T2104: support adding and removing VLANs in one call.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/interface.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 7dbedea45..634060c4b 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -1549,6 +1549,14 @@ class VLANIf(Interface):
if self.exists(f'{self.ifname}'):
return
+ # If source_interface or vlan_id was not explicitly defined (e.g. when
+ # calling VLANIf('eth0.1').remove() we can define source_interface and
+ # vlan_id here, as it's quiet obvious that it would be eth0 in that case.
+ if 'source_interface' not in self.config:
+ self.config['source_interface'] = '.'.join(self.ifname.split('.')[:-1])
+ if 'vlan_id' not in self.config:
+ self.config['vlan_id'] = self.ifname.split('.')[-1]
+
cmd = 'ip link add link {source_interface} name {ifname} type vlan id {vlan_id}'
if 'protocol' in self.config:
cmd += ' protocol {protocol}'