lop-devops / tests

Test Suite
GNU General Public License v3.0
4 stars 41 forks source link

NIC: inputfile create fails due to hard link issue #309

Closed abdhaleegit closed 1 year ago

abdhaleegit commented 1 year ago

while creating inputfile for network devices the script fails at get_interfaces_in_pci_address() to fetch pci interface name with below error

File "/root/tests/lib/pci.py", line 331, in if pci_address in os.readlink(os.path.join(pci_class_path, OSError: [Errno 22] Invalid argument: '/sys/class/net/bonding_masters'

This patch make sures the hardlinks are ignored and only the symlinks are checked for pci address

abdhaleegit commented 1 year ago

Before fix

for all NIC devices, this command fails

$ ./pci_info.py --pci-address "4004:01:00.0" --create-config
Traceback (most recent call last):
  File "./pci_info.py", line 182, in <module>
    pci_details = pci.pci_info(args.pci_addr, pci_type=args.pci_type, pci_blocklist=args.pci_addr_blocklist, type_blocklist=args.type_blocklist)
  File "/root/sriov/tests/lib/pci.py", line 698, in pci_info
    pci_dic['interfaces'].extend(get_interfaces_in_pci_address(fun, pci_dic['class']))
  File "/root/sriov/tests/lib/pci.py", line 330, in get_interfaces_in_pci_address
    return [interface for interface in os.listdir(pci_class_path)
  File "/root/sriov/tests/lib/pci.py", line 332, in <listcomp>
    interface))]
OSError: [Errno 22] Invalid argument: '/sys/class/net/bonding_masters'

After fix

$ ./pci_info.py --pci-address "4004:01:00.0" --create-config
23:41:32 INFO    : python avocado-setup.py --run-suite host_io_network_4004_01_00_fvt --input-file io_input.txt
[root@ltc# cat io_input.txt
[io_network_4004_01_00_fvt]
interface = "enP16388p1s0"
host_interfaces = "enP16388p1s0"
.
.