JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_modules.cpython-39.pyc

a

���h7�@slddlZddlZddlmZddlTddlZddlTddl	m
Z
ddlmZej
��ZGdd�dej�ZdS)�N�)�base)�*)�commandscsfeZdZdZ�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.
	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_modulescCsN|��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_pathcCsd}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
rrs&r)r.Zos.pathrCr"rZ
decoratorsZ
tuned.logsZtuned�
subprocessZtuned.utils.commandsrZtuned.constsr2Zlogs�getrZPluginrrrrr�<module>s

Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!}Q~+yԏz|@T20S~Kek *zFf^2X*(@8r?CIuI|֓>^ExLgNUY+{.RѪ τV׸YTD I62'8Y27'\TP.6d&˦@Vqi|8-OΕ]ʔ U=TL8=;6c| !qfF3aů&~$l}'NWUs$Uk^SV:U# 6w++s&r+nڐ{@29 gL u"TÙM=6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