summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-03-24 18:08:16 +0000
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-03-24 18:08:16 +0000
commit09f8e57535849aab83df6947fbe94a0e7228ed40 (patch)
treedcf9cf17bdc9a663f22846a749a4e423c8f69480 /python
parentdbaaa56c53ce9af73601b54351d97ebce21a9df7 (diff)
downloadvyos-1x-09f8e57535849aab83df6947fbe94a0e7228ed40.tar.gz
vyos-1x-09f8e57535849aab83df6947fbe94a0e7228ed40.zip
ifconfig: T2057: small cleanup VLANIf
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/vlan.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/python/vyos/ifconfig/vlan.py b/python/vyos/ifconfig/vlan.py
index 4e0db83c7..607e9aeaf 100644
--- a/python/vyos/ifconfig/vlan.py
+++ b/python/vyos/ifconfig/vlan.py
@@ -41,13 +41,15 @@ class VLANIf(Interface):
>>> i = Interface('eth0')
>>> i.remove()
"""
+ ifname = self.config['ifname']
+
# Do we have sub interfaces (VLANs)? We apply a regex matching
# subinterfaces (indicated by a .) of a parent interface.
#
# As interfaces need to be deleted "in order" starting from Q-in-Q
# we delete them first.
vlan_ifs = [f for f in os.listdir(r'/sys/class/net')
- if re.match(self.config['ifname'] + r'(?:\.\d+)(?:\.\d+)', f)]
+ if re.match(ifname + r'(?:\.\d+)(?:\.\d+)', f)]
for vlan in vlan_ifs:
Interface(vlan).remove()
@@ -56,7 +58,7 @@ class VLANIf(Interface):
# which probably acted as parent to Q-in-Q or have been regular 802.1q
# interface.
vlan_ifs = [f for f in os.listdir(r'/sys/class/net')
- if re.match(self.config['ifname'] + r'(?:\.\d+)', f)]
+ if re.match(ifname + r'(?:\.\d+)', f)]
for vlan in vlan_ifs:
Interface(vlan).remove()
@@ -90,7 +92,7 @@ class VLANIf(Interface):
>>> i.add_vlan(10)
"""
vlan_ifname = self.config['ifname'] + '.' + str(vlan_id)
- if not os.path.exists('/sys/class/net/{}'.format(vlan_ifname)):
+ if not os.path.exists(f'/sys/class/net/{vlan_ifname}'):
self._vlan_id = int(vlan_id)
if ethertype: