관리-도구
편집 파일: plugin_modules.cpython-39.pyc
a ����,�g7����������������������@���sl���d�dl�Z�d�dlZddlmZ�ddlT�d�dlZd�dlT�d�dl m Z �d�dlmZ�ej ���ZG�dd��dej�ZdS�)�����N����)�base)�*)�commandsc�����������������������sf���e�Zd�ZdZ��fdd�Zdd��Zdd��Zdd ��Zd d��Zdd ��Z dd��Z ejfdd�Z dd��Z���ZS�)� ModulesPlugina�� Plug-in for applying custom kernel modules options. This plug-in can set parameters to kernel modules. It creates `/etc/modprobe.d/tuned.conf` file. The syntax is `_module_=_option1=value1 option2=value2..._` where `_module_` is the module name and `_optionx=valuex_` are module options which may or may not be present. .Load module `netrom` with module parameter `nr_ndevs=2` ==== ---- [modules] netrom=nr_ndevs=2 ---- ==== Modules can also be forced to load/reload by using an additional `+r` option prefix. .(Re)load module `netrom` with module parameter `nr_ndevs=2` ==== ---- [modules] netrom=+r nr_ndevs=2 ---- ==== The `+r` switch will also cause *TuneD* to try and remove `netrom` module (if loaded) and try and (re)insert it with the specified parameters. The `+r` can be followed by an optional comma (`+r,`) for better readability. When using `+r` the module will be loaded immediately by the *TuneD* daemon itself rather than waiting for the OS to load it with the specified parameters. c��������������������s(���t�t|��j|i�|���d|�_t��|�_d�S�)NT)�superr����__init__Z_has_dynamic_optionsr����_cmd)�self�args�kwargs�� __class__���@/usr/lib/python3.9/site-packages/tuned/plugins/plugin_modules.pyr���3���s����zModulesPlugin.__init__c�����������������C���s���d|_�d|_|j|_d�S�)NFT)Z_has_dynamic_tuningZ_has_static_tuning�options�_modules�r ����instancer���r���r����_instance_init8���s����zModulesPlugin._instance_initc�����������������C���s���d�S��Nr���r���r���r���r����_instance_cleanup=���s����zModulesPlugin._instance_cleanupc�����������������C���s����|D�]�}|�j��dd|g�\}}|dk�r6t�d���d�S�|dkrTt�d||���f���|�j��d|g�\}}|dkrt�d||���f���qd�S�)NZmodprobez-rr���zN'modprobe' command not found, cannot reload kernel modules, reboot is requiredz$cannot remove kernel module '%s': %sz:cannot insert/reinsert module '%s', reboot is required: %s)r ����execute�log�warning�debug�strip)r ����modules�module�retcode�outr���r���r����_reload_modules@���s���� zModulesPlugin._reload_modulesc�����������������C���sN��|������d}d}d}g�}t|j����D�]�\}}|�j�|�}|�j�|�} |s�|�j�d|g�\}} |dk�rvd}t� d��n|dkr�t� d|���|s�|dkr&t| �dkr�| dd ��d kr�t� dd| �} |�|��t| �dkr�|d|�d �| �d�7�}q&t�d|���q&|�j�tj|��t|�}|dk�rJ|��|��t|j�|k�rJt�tj��d�S�)N��r���FZmodinfoTz8'modinfo' command not found, not checking kernel modulesz)kernel module '%s' not found, skipping itr�������z+r�^\s*\+r\s*,?\s*zoptions � � zKmodule '%s' doesn't have any option specified, not writing it to modprobe.d)�_clear_modprobe_file�listr����items� _variables�expandr ���r���r���r����error�len�re�sub�appendr���� write_to_file�consts�MODULES_FILEr!����infoZSTR_HINT_REBOOT)r ���r����sr���Z skip_checkZreload_list�option�valuer����vr ����lr���r���r����_instance_apply_staticL���s8���� z$ModulesPlugin._instance_apply_staticc�����������������C���s���t�|��dd�S�)N�/r"���)�str�replace)r ����pathr���r���r���� _unquote_pathk���s����zModulesPlugin._unquote_pathc�����������������C���s��d}d}t��d�}t|j����D�]�\}}|�j�|�}|�j�|�} t��dd| �} d|�} tj � | �s|d}t�t jd�|���q t�t jd�|���|�| �}|D�]p}|�d d �} t| �dkr�t�d||f���q�|��| d �| d �|�jj| d�|��| d ���d�dd�|�dkr�d}q�q |S�)NTz\s+r$���r"���z/sys/module/%sFzmodule '%s' is not loadedzmodule '%s' is loaded�=r���r#���z.unrecognized module option for module '%s': %sr���z/parameters/)Zerr_ret�no_error)r.����compiler(���r���r)���r*���r+���r/����osr>����existsr���r,���r2���ZSTR_VERIFY_PROFILE_FAILr4���ZSTR_VERIFY_PROFILE_OK�splitr-���r���Z _verify_valuer ���� read_filer?���)r ���r���Zignore_missingZdevices�ret�rr6���r7���r���r8���Zmpathr9����item�argr���r���r����_instance_verify_staticn���s2���� "��z%ModulesPlugin._instance_verify_staticc�����������������C���s���|t�jkr|�����d�S�r���)r2���Z ROLLBACK_FULLr'���)r ���r���Zrollbackr���r���r����_instance_unapply_static����s���� z&ModulesPlugin._instance_unapply_staticc�����������������C���s����|�j�jtjdd�}|�d�}d�}}t|�}t�d�}||k�rb|�||��d�u�rX|}|}|d7�}q6d� |d|���}t|�dkr�|d7�}|�j�� tj|��d�S�)NT)rA���r&���r���z^\s*#r���)r ���rF���r2���r3���rE���r-���r.���rB����search�joinr1���)r ���r5���r9����i�jZllrH���r���r���r���r'�������s���� z"ModulesPlugin._clear_modprobe_file)�__name__� __module__�__qualname__�__doc__r���r���r���r!���r:���r?���rK���r2���Z ROLLBACK_SOFTrL���r'���� __classcell__r���r���r ���r���r������s���&r���)r.���Zos.pathrC���r"���r���Z decoratorsZ tuned.logsZtuned� subprocessZtuned.utils.commandsr���Ztuned.constsr2���Zlogs�getr���ZPluginr���r���r���r���r����<module>���s���