From 4ae44c074e15fa102718d5a4512c23db447d6dc8 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 7 Sep 2019 14:24:30 +0200 Subject: Python/ifconfig: T1557: rename EthernetIf -> VLANIf An Ethernet Interface will provide additional functionality (link speed/duplex) which is not available for a Bond Interface, but both share the same VLAN capabilities. --- python/vyos/ifconfig.py | 15 +++++++++------ src/conf_mode/interface-bonding.py | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 750a7cc70..524c0f276 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -997,8 +997,11 @@ class BridgeIf(Interface): .format(self._ifname, interface), priority) -class EthernetIf(Interface): - +class VLANIf(Interface): + """ + This class handels the creation and removal of a VLAN interface. It serves + as base class for BondIf and EthernetIf. + """ def __init__(self, ifname, type=None): super().__init__(ifname, type) @@ -1012,7 +1015,7 @@ class EthernetIf(Interface): This function creates both 802.1q and 802.1ad (Q-in-Q) interfaces. Proto parameter is used to indicate VLAN type. - A new object of type EthernetIf is returned once the interface has been + A new object of type VLANIf is returned once the interface has been created. """ vlan_ifname = self._ifname + '.' + str(vlan_id) @@ -1031,7 +1034,7 @@ class EthernetIf(Interface): # return new object mapping to the newly created interface # we can now work on this object for e.g. IP address setting # or interface description and so on - return EthernetIf(vlan_ifname) + return VLANIf(vlan_ifname) def del_vlan(self, vlan_id): """ @@ -1040,11 +1043,11 @@ class EthernetIf(Interface): client processes. """ vlan_ifname = self._ifname + '.' + str(vlan_id) - tmp = EthernetIf(vlan_ifname) + tmp = VLANIf(vlan_ifname) tmp.remove() -class BondIf(EthernetIf): +class BondIf(VLANIf): """ The Linux bonding driver provides a method for aggregating multiple network diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py index ac3e1b867..0d5f9f6b7 100755 --- a/src/conf_mode/interface-bonding.py +++ b/src/conf_mode/interface-bonding.py @@ -22,7 +22,7 @@ from copy import deepcopy from sys import exit from netifaces import interfaces -from vyos.ifconfig import BondIf, EthernetIf +from vyos.ifconfig import BondIf, VLANIf from vyos.configdict import list_diff, vlan_to_dict from vyos.config import Config from vyos import ConfigError @@ -82,7 +82,7 @@ def apply_vlan_config(vlan, config): to a VLAN interface """ - if type(vlan) != type(EthernetIf("lo")): + if type(vlan) != type(VLANIf("lo")): raise TypeError() # update interface description used e.g. within SNMP -- cgit v1.2.3