관리-도구
편집 파일: hotplug.cpython-39.pyc
a ����,�g�����������������������@���s@���d�dl�mZ�ddlmZ�ddlZej���ZG�dd��dej �Z dS�)����)�base�����Nc�����������������������s����e�Zd�ZdZ��fdd�Z��fdd�Zdd��Zdd ��Zd d��Zdd ��Z dd��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zdd��Zdd��Z���ZS�) �Pluginz: Base class for plugins with device hotpluging support. c��������������������s���t�t|��j|i�|���d�S��N)�superr����__init__)�self�args�kwargs�� __class__���9/usr/lib/python3.9/site-packages/tuned/plugins/hotplug.pyr������s����zPlugin.__init__c��������������������s���t�t|������|�����d�S�r���)r���r����cleanup�_hardware_events_cleanup�r���r���r ���r���r������s����zPlugin.cleanupc�����������������C���s���d�S�r���r ���r���r ���r ���r����_hardware_events_init���s����zPlugin._hardware_events_initc�����������������C���s���d�S�r���r ���r���r ���r ���r���r������s����zPlugin._hardware_events_cleanupc�����������������C���s���|������d�S�r���)r���r���r ���r ���r���� _init_devices���s����zPlugin._init_devicesc�����������������C���st���|dkr&t��d|j���|��|j��nJ|dkrLt��d|j���|��|j��n$|dkrpt��d|j���|��|j��d�S�)N�addzdevice '%s', add event�removezdevice '%s', remove event�movez-device: '%s', rename event, reported new name)�log�infoZsys_name�_add_device�_remove_device�_move_device)r���ZeventZdevicer ���r ���r����_hardware_events_callback���s����z Plugin._hardware_events_callbackc�����������������C���sd���t��d|j|f���|�j�|��|��||jd|g��|��||��|��||jd|g��|j �|��d�S�)Nz!instance %s: adding new device %sZapply) r���r����name�_assigned_devicesr����_call_device_script� script_pre�_added_device_apply_tuning�script_post�processed_devices�r����instance�device_namer ���r ���r����_add_device_process'���s����zPlugin._add_device_processc�����������������C���sp���||�j�|�jB�v�rd�S�t|�j����D�].\}}t|��||g��dkr"|��||���qlq"t� d|���|�j� |��d�S�)Nr���zno instance wants %s)r���� _free_devices�list� _instances�items�lenZ_get_matching_devicesr'���r����debugr���)r���r&���Z instance_namer%���r ���r ���r���r���/���s����zPlugin._add_devicec�����������������C���s4���|D�]}|���||��qt|j�t|j��dk|_dS�)zN Add devices specified by the set to the instance, no check is performed. r���N)r'���r,���r#����assigned_devices�active�r���r%���Zdevice_names�devr ���r ���r����_add_devices_nocheck;���s������zPlugin._add_devices_nocheckc�����������������C���sx���||j�v�rt|��||jd|g��|��||��|��||jd|g��|j��|��t|j��t|j��dk|_|�j �|��dS�dS�)NZunapplyr���TF) r#���r���r"����_removed_device_unapply_tuningr ���r���r,���r.���r/���r���r$���r ���r ���r����_remove_device_processF���s���� ��zPlugin._remove_device_processc�����������������C���s���dS�)ae��Rename device in the instance, this probably applies only to network interfaces. The udev device environment is mostly unchanged (except the name) and the old device name isn't announced, thus the rename functionality is plugin dependant and has to be implemented in the child plugin class. Parameters: device_name -- new name of the device Nr ���)r���r&���r ���r ���r���r���T���s����zPlugin._move_devicec�����������������C���sH���||�j�|�jB�vrdS�t|�j����D�]}|��||�r"�qDq"|�j�|��dS�)zVRemove device from the instance Parameters: device_name -- name of the device N)r���r(���r)���r*����valuesr4���r���)r���r&���r%���r ���r ���r���r���a���s����zPlugin._remove_devicec�����������������C���s���|D�]}|���||��qdS�)zS Remove devices specified by the set from the instance, no check is performed. N)r4���r0���r ���r ���r����_remove_devices_nocheckq���s����zPlugin._remove_devices_nocheckc�����������������C���s6���|���||g��|jr2|�j�tjtj�r2|��||��d�S�r���)Z_execute_all_device_commands�has_dynamic_tuning�_global_cfg�get�consts�CFG_DYNAMIC_TUNING�CFG_DEF_DYNAMIC_TUNINGZ_instance_apply_dynamicr$���r ���r ���r���r!���x���s����z!Plugin._added_device_apply_tuningc�����������������C���s:���|j�r$|�j�tjtj�r$|��||��|�j||gdd��d�S�)NT)r���)r7���r8���r9���r:���r;���r<���Z_instance_unapply_dynamicZ_cleanup_all_device_commandsr$���r ���r ���r���r3���}���s����z%Plugin._removed_device_unapply_tuning)�__name__� __module__�__qualname__�__doc__r���r���r���r���r���r���r'���r���r2���r4���r���r���r6���r!���r3���� __classcell__r ���r ���r���r���r������s ��� r���) ��r���Ztuned.constsr:���Z tuned.logsZtunedZlogsr9���r���r���r ���r ���r ���r����<module>���s���