HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3.9/site-packages/tuned/units/__pycache__/manager.cpython-39.pyc
a

Y��d��@s�ddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ej��ZdgZGdd�de�ZdS)�N)�GlobalConfig)�commands�Managercs�eZdZdZd�fdd�	Zedd��Zedd��Zed	d
��Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zejfdd�Z�ZS) rz?
	Manager creates plugin instances and keeps a track of them.
	NcsJtt|���||_||_||_||_g|_g|_|p:t	�|_
t�|_dS�N)
�superr�__init__�_plugins_repository�_monitors_repository�_def_instance_priority�_hardware_inventory�
_instances�_pluginsr�_configr�_cmd)�self�plugins_repositoryZmonitors_repositoryZdef_instance_priorityZhardware_inventoryZconfig��	__class__��7/usr/lib/python3.9/site-packages/tuned/units/manager.pyrszManager.__init__cCs|jSr)r
�rrrr�plugins!szManager.pluginscCs|jSr)rrrrr�	instances%szManager.instancescCs|jSr)rrrrrr)szManager.plugins_repositorycCsF|jdurdS|j�tj�}|dur0|j�d�}t�|j|tj	�duS)NTz
/proc/cpuinfo)
Z
cpuinfo_regexr�get�constsZCFG_CPUINFO_STRINGrZ	read_file�re�search�	MULTILINE)r�unitZcpuinfo_stringrrr�_unit_matches_cpuinfo-s

��zManager._unit_matches_cpuinfocCsH|jdurdS|j�tj�}|dur2d�t���}t�	|j|tj
�duS)NT� )Zuname_regexrrrZCFG_UNAME_STRING�join�os�unamerrr)rrZuname_stringrrr�_unit_matches_uname6s

��zManager._unit_matches_unamec
Cs*g}t|���D]�\}}|js.t�d|�q|�|�sHt�d|�q|�|�sbt�d|�q|j�d|j	�t
|jd�|jd<|�|�q|jdd�d�t
��}|D]}|j�d�d||j<q�t|���D]�\}}z$|j�|�}|||<|j�|�Wq�tjjj�y.t�d|�Yq�Yq�t�yv}	z0t�d	|�t�|	�WYd}	~	q�WYd}	~	q�d}	~	00q�g}
|D]^}||j}|du�r��q�t�d
|j|jf�|�|j|j|j|j |j!|j�}|
�|��q�|
D](}|j"�#�|j"�$|�|j"�%|��q�|j&�'�|j(�)|
�dS)Nzskipping disabled instance '%s'z.skipping instance '%s', cpuinfo does not matchz,skipping instance '%s', uname does not match�prioritycSs
|jdS)Nr%)�options)�xrrr�<lambda>P�z Manager.create.<locals>.<lambda>)�keyz2skipping plugin '%s', not supported on your systemzfailed to initialize plugin %szcreating '%s' (%s))*�list�itemsZenabled�log�debugrr$r&�
setdefaultr
�int�append�sort�collections�OrderedDict�pop�typer�creater
�tunedr�
exceptionsZNotSupportedPluginException�info�	Exception�error�	exception�nameZcreate_instanceZdevicesZdevices_udev_regexZ
script_preZscript_post�pluginZinit_devicesZassign_free_devicesZinitialize_instancerZstart_processing_eventsr�extend)
rZinstances_configZinstance_info_listZ
instance_nameZ
instance_infoZplugins_by_nameZplugin_nameZnoner?�erZnew_instance�instancerrrr7?s^


$

�

zManager.createc
Osfz||i|��WSty`}z8t��}t�d|t|�f�t�|�|WYd}~Sd}~00dS)Nz"BUG: Unhandled exception in %s: %s)r;�	traceback�
format_excr-r<�str)rZcallerZexc_ret�f�args�kwargsrAZtracerrr�	_try_callus
�
zManager._try_callcCsx|jD](}t�d|j�|�dd|jj|�q|jD]$}t�d|j�|�dd|j�q6|jdd�=|jdd�=dS)Nzdestroying instance %s�destroy_allzcleaning plugin '%s')	rr-r.r>rIr?Zdestroy_instancer
Zcleanup)rrBr?rrrrJs
�
zManager.destroy_allcCs0|jjD]"}t�d|�|�dd|j�qdS)Nzupdating monitor %s�update_monitors)r	Zmonitorsr-r.rI�update)rZmonitorrrrrK�szManager.update_monitorscCs |jD]}|�dd|j�qdS)N�start_tuning)rrIZapply_tuning�rrBrrrrM�s
�zManager.start_tuningcCs2d}|jD]"}|�dd|j|�}|dkr
d}q
|S)NT�
verify_tuningF)rrIrO)rZignore_missing�retrB�resrrrrO�s
�zManager.verify_tuningcCs |jD]}|�dd|j�qdS)N�
update_tuning)rrIrRrNrrrrR�s
�zManager.update_tuningcCs0|j��t|j�D]}|�dd|j|�qdS)N�stop_tuning)rZstop_processing_events�reversedrrIZunapply_tuning)rZrollbackrBrrrrS�s

�zManager.stop_tuning)N)�__name__�
__module__�__qualname__�__doc__r�propertyrrrrr$r7rIrJrKrMrOrRrZ
ROLLBACK_SOFTrS�
__classcell__rrrrrs&�


		6

	
)r3r"rrCZtuned.exceptionsr8Z
tuned.logsZtuned.plugins.exceptionsZtuned.constsrZtuned.utils.global_configrZtuned.utils.commandsrZlogsrr-�__all__�objectrrrrr�<module>s