/usr/share/netplan/netplan/cli/__pycache__
Edit: /usr/share/netplan/netplan/cli/__pycache__/sriov.cpython-38.pyc (12226B)
U
)/b N @ s d dl Z d dlZd dlZd dlZd dlmZ d dlm mZ d dl m
Z
d dlmZ d dl
Z
G dd deZeje dddZeje eje d d
dZdd
Zdd Zdd Zdd Zdd ZdddZdddZdS ) N)defaultdict)ConfigurationErrorc @ s e Zd ZdZedddZeedddZeeddd Zeed
ddZ eedd
dZ
eedddZeedddZ
eedddZeedddZeedddZeeedddZedddZdS ) PCIDevicez.Helper class for interaction with a PCI devicepci_addrc C s
|| _ dS )znInitialise a new PCI device handler
:param pci_addr: PCI address of device
:type: str
Nr )selfr r '/usr/share/netplan/netplan/cli/sriov.py__init__' s zPCIDevice.__init__)returnc C s dS )zusysfs path (can be overridden for testing)
:return: full path to /sys filesystem
:rtype: str
z/sysr r r r r sys. s z
PCIDevice.sysc C s t j| jd| jS )zq/sys path for PCI device
:return: full path to PCI device in /sys filesystem
:rtype: str
zbus/pci/devices)ospathjoinr
r r r r r r 6 s zPCIDevice.path)subpathr c C s t j| j|S )z/sys subpath helper for PCI device
:param subpath: subpath to construct path for
:type: str
:return: self.path + subpath
:rtype: str
)r r r )r r r r r r > s zPCIDevice.subpathc C s2 d}t j| dr.t jt | d}|S )zjKernel driver for PCI device
:return: kernel driver in use for device
:rtype: str
driver)r r existsr basenamereadlink)r r r r r r G s zPCIDevice.driverc C s t j| dS )zDetermine if device is bound to a kernel driver
:return: whether device is bound to a kernel driver
:rtype: bool
r r r r r r r r r boundR s zPCIDevice.boundc C s t j| dS )zwDetermine if device is a SR-IOV Physical Function
:return: whether device is a PF
:rtype: bool
sriov_numvfsr r r r r is_pfZ s zPCIDevice.is_pfc C s t j| dS )zvDetermine if device is a SR-IOV Virtual Function
:return: whether device is a VF
:rtype: bool
Zphysfnr r r r r is_vfb s zPCIDevice.is_vfc C sX g }d}z(| tjt| d| W n tk
rH Y qTY nX |d7 }q|S )zList Virtual Function addresses associated with a Physical Function
:return: List of PCI addresses of Virtual Functions
:rtype: list[str]
r zvirtfn{} )appendr r r r r formatFileNotFoundError)r vf_addrsir r r r j s
zPCIDevice.vf_addrsc C s dd | j D S )zList Virtual Function associated with a Physical Function
:return: List of PCI devices of Virtual Functions
:rtype: list[PCIDevice]
c S s g | ]}t |qS r )r ).0addrr r r