HEX
Server: Apache
System: Linux nc-ph-4101.simplemoneygoals.com 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 12 09:45:05 EST 2025 x86_64
User: dailygoldindex (1004)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_modules.cpython-39.pyc
a

,�g7�@slddlZddlZddlmZddlTddlZddlTddl	m
Z
ddlmZej
��ZGdd�dej�ZdS)�N�)�base)�*)�commandscsfeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ejfdd�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.
	cs(tt|�j|i|��d|_t�|_dS)NT)�superr�__init__Z_has_dynamic_optionsr�_cmd)�self�args�kwargs��	__class__��@/usr/lib/python3.9/site-packages/tuned/plugins/plugin_modules.pyr3szModulesPlugin.__init__cCsd|_d|_|j|_dS)NFT)Z_has_dynamic_tuningZ_has_static_tuning�options�_modules�r
�instancerrr�_instance_init8szModulesPlugin._instance_initcCsdS�Nrrrrr�_instance_cleanup=szModulesPlugin._instance_cleanupcCs�|D]�}|j�dd|g�\}}|dkr6t�d�dS|dkrTt�d||��f�|j�d|g�\}}|dkrt�d||��f�qdS)NZmodprobez-rrzN'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�outrrr�_reload_modules@s
zModulesPlugin._reload_modulescCsN|��d}d}d}g}t|j���D]�\}}|j�|�}|j�|�}	|s�|j�d|g�\}}
|dkrvd}t�	d�n|dkr�t�
d|�|s�|dkr&t|	�dkr�|	dd	�d
kr�t�
dd|	�}	|�|�t|	�dkr�|d|d
|	d7}q&t�d|�q&|j�tj|�t|�}|dk�rJ|�|�t|j�|k�rJt�tj�dS)N�rFZmodinfoTz8'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	rrr�error�len�re�sub�appendr�
write_to_file�consts�MODULES_FILEr!�infoZSTR_HINT_REBOOT)r
r�srZ
skip_checkZreload_list�option�valuer�vr �lrrr�_instance_apply_staticLs8


z$ModulesPlugin._instance_apply_staticcCst|��dd�S)N�/r")�str�replace)r
�pathrrr�
_unquote_pathkszModulesPlugin._unquote_pathcCsd}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
�ddd�|�dkr�d}q�q |S)NTz\s+r$r"z/sys/module/%sFzmodule '%s' is not loadedzmodule '%s' is loaded�=rr#z.unrecognized module option for module '%s': %srz/parameters/)Zerr_ret�no_error)r.�compiler(rr)r*r+r/�osr>�existsrr,r2ZSTR_VERIFY_PROFILE_FAILr4ZSTR_VERIFY_PROFILE_OK�splitr-rZ
_verify_valuer	�	read_filer?)r
rZignore_missingZdevices�ret�rr6r7rr8Zmpathr9�item�argrrr�_instance_verify_staticns2

"��z%ModulesPlugin._instance_verify_staticcCs|tjkr|��dSr)r2Z
ROLLBACK_FULLr')r
rZrollbackrrr�_instance_unapply_static�s
z&ModulesPlugin._instance_unapply_staticcCs�|jjtjdd�}|�d�}d}}t|�}t�d�}||krb|�||�durX|}|}|d7}q6d�	|d|��}t|�dkr�|d7}|j�
tj|�dS)NT)rAr&rz^\s*#r)r	rFr2r3rEr-r.rB�search�joinr1)r
r5r9�i�jZllrHrrrr'�s


z"ModulesPlugin._clear_modprobe_file)�__name__�
__module__�__qualname__�__doc__rrrr!r:r?rKr2Z
ROLLBACK_SOFTrLr'�
__classcell__rrr
rrs&r)r.Zos.pathrCr"rZ
decoratorsZ
tuned.logsZtuned�
subprocessZtuned.utils.commandsrZtuned.constsr2Zlogs�getrZPluginrrrrr�<module>s