xcp.pci

class xcp.pci.PCI(addr)[source]

Bases: object

PCI address object for manipulation and comparison

classmethod is_valid(addr)[source]

Static method to assertain whether addr is a recognised PCI address or not

class xcp.pci.PCIDevices[source]

Bases: object

findByClass(cls: str | list[str], subcls: str | None = None) list[dict[str, str]][source]

return all devices that match either of:

class, subclass [class1, class2, … classN]

findRelatedFunctions(dev)[source]

return other devices that share the same bus & slot

class xcp.pci.PCIIds(fn)[source]

Bases: object

findDevice(vendor, device)[source]
findSubdevice(subvendor, subdevice)[source]
findVendor(vendor)[source]
lookupClass(cls_str)[source]
classmethod read()[source]
xcp.pci.pci_sbdfi_to_nic(sbdfi, nics)[source]

Return NIC for a given PCI SBDF identifier(optionally with a MAC address index)

Explanation of the PCI SBDF MAC address index implemented here: Support the use of an index after PCI bus location

Some NICs expose multiple ethernet devices for a single PCI location, meaning there is confusion about the physical names and no way to distinguish between them other than MAC address. Auditing a large environment to obtain MAC addresses to feed into the host installer (e.g. using map_netdev) is not viable, therefore this implements an index (ordered by MAC) to the PCI bus location to uniquely identify a NIC:

  • Match SBDF[index] input against a regular expression pattern to extract the SBDF identifier and the optional MAC index(the default value of the index is 0)

  • Filter the list of NICs to find those with a matching PCI SBDF identifier.

  • Sort matching NICs by MAC address (in case the passed MAC index is > 0)

The test tests/test_sbdfi_to_nic.py gives an easy overview how it is used. @param sbdfi: PCI SBDF identifier of the NIC, Optionally with an index @param nics: List of NIC objects @returns: NIC object at the given MAC index @raises: Exception if SBDF[index] is not found