From b8f055425075c5404350547ea4fc898e53adc1a5 Mon Sep 17 00:00:00 2001 From: Petr Stodulka Date: Wed, 21 Feb 2024 20:55:54 +0100 Subject: [PATCH 1/2] Correct scanning of non-PCI network devices Non-PCI network devices (present usually on IBM Z architecture) does not have ID_VENDOR_ID attribute and also there is nothing we could put into Interface.pci_info about them. For such devices, set empty string for Interface.vendor field and None value for pci_info. The Interface model has been updated, allowing None value for pci_info field. --- .../system_upgrade/common/libraries/persistentnetnames.py | 8 ++++++-- .../common/models/persistentnetnamesfacts.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/repos/system_upgrade/common/libraries/persistentnetnames.py b/repos/system_upgrade/common/libraries/persistentnetnames.py index 8769712c28..0d4e1101e9 100644 --- a/repos/system_upgrade/common/libraries/persistentnetnames.py +++ b/repos/system_upgrade/common/libraries/persistentnetnames.py @@ -42,9 +42,13 @@ def interfaces(): attrs['name'] = dev.sys_name attrs['devpath'] = dev.device_path attrs['driver'] = dev['ID_NET_DRIVER'] - attrs['vendor'] = dev['ID_VENDOR_ID'] - attrs['pci_info'] = PCIAddress(**pci_info(dev['ID_PATH'])) attrs['mac'] = dev.attributes.get('address') + attrs['vendor'] = dev.get('ID_VENDOR_ID', '') + if not attrs['vendor']: + attrs['pci_info'] = PCIAddress(**pci_info(dev['ID_PATH'])) + else: + # non-PCI + attrs['pci_info'] = None if isinstance(attrs['mac'], bytes): attrs['mac'] = attrs['mac'].decode() except Exception as e: # pylint: disable=broad-except diff --git a/repos/system_upgrade/common/models/persistentnetnamesfacts.py b/repos/system_upgrade/common/models/persistentnetnamesfacts.py index 395b26f0f2..7a388dc33f 100644 --- a/repos/system_upgrade/common/models/persistentnetnamesfacts.py +++ b/repos/system_upgrade/common/models/persistentnetnamesfacts.py @@ -24,7 +24,7 @@ class Interface(Model): devpath = fields.String() driver = fields.String() vendor = fields.String() - pci_info = fields.Model(PCIAddress) + pci_info = fields.Nullable(fields.Model(PCIAddress)) mac = fields.String() From 1f5fb284a579b0408f8d5de9028fb96847d3f9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Stod=C5=AFlka?= Date: Wed, 28 Feb 2024 13:11:59 +0100 Subject: [PATCH 2/2] Update repos/system_upgrade/common/libraries/persistentnetnames.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michal Hečko --- repos/system_upgrade/common/libraries/persistentnetnames.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/system_upgrade/common/libraries/persistentnetnames.py b/repos/system_upgrade/common/libraries/persistentnetnames.py index 0d4e1101e9..ad0733973b 100644 --- a/repos/system_upgrade/common/libraries/persistentnetnames.py +++ b/repos/system_upgrade/common/libraries/persistentnetnames.py @@ -44,7 +44,7 @@ def interfaces(): attrs['driver'] = dev['ID_NET_DRIVER'] attrs['mac'] = dev.attributes.get('address') attrs['vendor'] = dev.get('ID_VENDOR_ID', '') - if not attrs['vendor']: + if attrs['vendor']: attrs['pci_info'] = PCIAddress(**pci_info(dev['ID_PATH'])) else: # non-PCI