diff options
| author | Christian Breunig <christian@breunig.cc> | 2024-12-18 23:01:43 +0100 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2024-12-18 23:01:43 +0100 |
| commit | d2a7584a6d5cc3fcd01471b9cfd45735b5458724 (patch) | |
| tree | 3c648d102bd36576f18a02cdfc2de9cd4e7f00ba /python/vyos/ifconfig/interface.py | |
| parent | 77628e49379066e07b4046a00007187263e7206b (diff) | |
| download | veeos-1x-d2a7584a6d5cc3fcd01471b9cfd45735b5458724.tar.gz veeos-1x-d2a7584a6d5cc3fcd01471b9cfd45735b5458724.zip | |
ifconfig: fix AttributeError caused by internal race condition
File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 342
if not self.iftype:
^^^^^^^^^^^
AttributeError: 'Interface' object has no attribute 'iftype'
Diffstat (limited to 'python/vyos/ifconfig/interface.py')
| -rw-r--r-- | python/vyos/ifconfig/interface.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index cd562e1fe..eac9f61f5 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -26,8 +26,9 @@ from netifaces import ifaddresses # this is not the same as socket.AF_INET/INET6 from netifaces import AF_INET from netifaces import AF_INET6 +from netaddr import EUI +from netaddr import mac_unix_expanded -from vyos import ConfigError from vyos.configdict import list_diff from vyos.configdict import dict_merge from vyos.configdict import get_vlan_ids @@ -61,9 +62,7 @@ from vyos.ifconfig.control import Control from vyos.ifconfig.vrrp import VRRP from vyos.ifconfig.operational import Operational from vyos.ifconfig import Section - -from netaddr import EUI -from netaddr import mac_unix_expanded +from vyos import ConfigError link_local_prefix = 'fe80::/64' @@ -339,8 +338,8 @@ class Interface(Control): # Any instance of Interface, such as Interface('eth0') can be used # safely to access the generic function in this class as 'type' is # unset, the class can not be created - if not self.iftype: - raise Exception(f'interface "{ifname}" not found') + if not hasattr(self, 'iftype'): + raise ConfigError(f'Interface "{ifname}" has no "iftype" attribute defined!') self.config['type'] = self.iftype # Should an Instance of a child class (EthernetIf, DummyIf, ..) |
