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_systemd.cpython-39.opt-1.pyc
a

,�gG�@spddlmZddlTddlZddlmZddlmZddlm	Z	ddl
Z
ddlZej�
�ZGdd�dej�ZdS)	�)�base)�*�N)�
exceptions)�commandscs�eZdZdZ�fdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zejfdd�Zdd�Zeddd�dd ��Z�ZS)!�
SystemdPlugina'
	Plug-in for tuning systemd options.

	The [option]`cpu_affinity` option allows setting CPUAffinity in
	`/etc/systemd/system.conf`. This configures the CPU affinity for the
	service manager as well as the default CPU affinity for all forked
	off processes. The option takes a comma-separated list of CPUs with
	optional CPU ranges specified by the minus sign (`-`).

	.Set the CPUAffinity for `systemd` to `0 1 2 3`
	====
	----
	[systemd]
	cpu_affinity=0-3
	----
	====

	NOTE: These tunings are unloaded only on profile change followed by a reboot.
	cs@tj�tj�st�dtj��tt|�j	|i|��t
�|_dS)NzERequired systemd '%s' configuration file not found, disabling plugin.)�os�path�isfile�consts�SYSTEMD_SYSTEM_CONF_FILErZNotSupportedPluginException�superr�__init__r�_cmd)�self�args�kwargs��	__class__��@/usr/lib/python3.9/site-packages/tuned/plugins/plugin_systemd.pyr"szSystemdPlugin.__init__cCsd|_d|_dS)NFT)Z_has_dynamic_tuningZ_has_static_tuning�r�instancerrr�_instance_init(szSystemdPlugin._instance_initcCsdS�Nrrrrr�_instance_cleanup,szSystemdPlugin._instance_cleanupcCsddiS)N�cpu_affinityr)�clsrrr�_get_config_options/s�z!SystemdPlugin._get_config_optionscCsB|dur>tjd|d|tjd�}|dur>|jdkr>|�d�SdS)N�^\s*z\s*=\s*(.*)$��flagsr)�re�search�	MULTILINE�	lastindex�group)r�conf�key�morrr�_get_keyval5s

zSystemdPlugin._get_keyvalcCs|tjd|ddt|�|tjd�\}}|dkrxz|ddkrF|d7}WntyZYn0||dt|�d7}|S|S)	Nz^(\s*z\s*=).*$z\g<1>r r����
�=)r"�subn�strr$�
IndexError)rr'r(�valZconf_newZnsubsrrr�_add_keyval=s(zSystemdPlugin._add_keyvalcCstjd|dd|tjd�S)Nrz\s*=.*\n�r )r"�subr$)rr'r(rrr�_del_keyIszSystemdPlugin._del_keycCs,|jjtjdd�}|dur(t�d�dS|S)N)�err_retz(error reading systemd configuration file)r�	read_filerr�log�error)rZsystemd_system_confrrr�_read_systemd_system_confLs

z'SystemdPlugin._read_systemd_system_confcCsptjtj}|j�||�s8t�d�|jj|dd�dS|j�|tj�slt�dtj�|jj|dd�dSdS)Nz(error writing systemd configuration fileT)�no_errorFz/error replacing systemd configuration file '%s')	rrZTMP_FILE_SUFFIXr�
write_to_filer8r9�unlink�rename)rr'Ztmpfilerrr�_write_systemd_system_confSs
z(SystemdPlugin._write_systemd_system_confcCstj�tj|j�Sr)rr	�joinrZPERSISTENT_STORAGE_DIR�name)rrrr�_get_storage_filenameasz#SystemdPlugin._get_storage_filenamecCsl|��}|durh|��}|jj|ddd�}|j�|�|durN|�|tj�}n|�|tj|�}|�	|�dS)NT�r6r;)
r:rBrr7r=r5r�SYSTEMD_CPUAFFINITY_VARr2r?)rr'�fname�cpu_affinity_savedrrr�_remove_systemd_tuningdsz$SystemdPlugin._remove_systemd_tuningcCs0|tjkr,t�dtj�|��t�d�dS)Nz6removing '%s' systemd tuning previously added by TuneDz[you may need to manualy run 'dracut -f' to update the systemd configuration in initrd image)rZ
ROLLBACK_FULLr8�inforDrGZconsole)rrZrollbackrrr�_instance_unapply_staticps
z&SystemdPlugin._instance_unapply_staticcCs<|durdSd�dd�|j�t�ddt�dd|���D��S)Nr3� css|]}t|�VqdSr�r/��.0�vrrr�	<genexpr>z�z8SystemdPlugin._cpulist_convert_unpack.<locals>.<genexpr>z\s+�,z,\s+)r@r�cpulist_unpackr"r4)rZcpulistrrr�_cpulist_convert_unpackwsz%SystemdPlugin._cpulist_convert_unpackrF)Z
per_devicec
Cs�d}d}|j�|j�|j�|���}d�dd�|j�|�D��}	|��}
|
durh|�|
t	j
�}|�|�}|r||�d|	||�S|r�|�
�}|jj|ddd�}|dur�|dur�|	|kr�|jj||dd�t�dt	j
|	t	jf�|�|�|
t	j
|	��dSdS)	NrJcss|]}t|�VqdSrrKrLrrrrO�rPz)SystemdPlugin._cmdline.<locals>.<genexpr>rTrC)Zmakedirz setting '%s' to '%s' in the '%s')rZunescapeZ
_variables�expand�unquoter@rRr:r*rrDrSZ
_verify_valuerBr7r<r8rHrr?r2)
rZenabling�valueZverifyZignore_missingrZ
conf_affinityZconf_affinity_unpackedrNZ
v_unpackedr'rErFrrr�_cmdline|s&
zSystemdPlugin._cmdline)�__name__�
__module__�__qualname__�__doc__rrr�classmethodrr*r2r5r:r?rBrGrZ
ROLLBACK_SOFTrIrSZcommand_customrW�
__classcell__rrrrr
s"

r)r3rZ
decoratorsZ
tuned.logsZtunedrZtuned.utils.commandsrZtuned.constsrrr"Zlogs�getr8ZPluginrrrrr�<module>s