%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.9/site-packages/tuned/plugins/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_scsi_host.cpython-39.pyc

a

���h��@slddlZddlmZddlTddlZddlmZddlm	Z	ddl
Z
ddlZej�
�ZGdd�dej�ZdS)�N�)�hotplug)�*)�commandscs�eZdZdZ�fdd�Z�fdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
�fdd�Z�fdd�Z�fdd�Z
edd��Zdd�Zdd�Zdd�Zdd�Zdd�Zed d!d"�d#d$��Zed �d(d&d'��Z�ZS))�SCSIHostPlugina�
	Tunes options for SCSI hosts.

	The plug-in sets Aggressive Link Power Management (ALPM) to the value specified
	by the [option]`alpm` option. The option takes one of four values:
	`min_power`, `med_power_with_dipm`, `medium_power` and `max_performance`.

	NOTE: ALPM is only available on SATA controllers that use the Advanced
	Host Controller Interface (AHCI).

	.ALPM setting when extended periods of idle time are expected
	====
	----
	[scsi_host]
	alpm=med_power_with_dipm
	----
	====
	cs"tt|�j|i|��t�|_dS�N)�superr�__init__r�_cmd)�self�args�kwargs��	__class__��B/usr/lib/python3.9/site-packages/tuned/plugins/plugin_scsi_host.pyr	 szSCSIHostPlugin.__init__csRtt|���d|_t�|_|j�d�D]}|�|�r(|j�	|j
�q(t�|_dS)NT�scsi)rr�
_init_devicesZ_devices_supported�setZ
_free_devices�_hardware_inventoryZget_devices�_device_is_supported�addZsys_nameZ_assigned_devices�r�devicerrrr%s
zSCSIHostPlugin._init_devicescs�fdd�|D�S)Ncsg|]}�j�d|��qS)r)rZ
get_device)�.0�x�rrr�
<listcomp>0�z6SCSIHostPlugin._get_device_objects.<locals>.<listcomp>r)rZdevicesrrr�_get_device_objects/sz"SCSIHostPlugin._get_device_objectscCs
|jdkS)NZ	scsi_host)Zdevice_type)�clsrrrrr2sz#SCSIHostPlugin._device_is_supportedcCs|j�|d|j�dS)Nr)rZ	subscribe�_hardware_events_callbackrrrr�_hardware_events_init6sz$SCSIHostPlugin._hardware_events_initcCs|j�|�dSr)rZunsubscriberrrr�_hardware_events_cleanup9sz'SCSIHostPlugin._hardware_events_cleanupcs |�|�rtt|��||�dSr)rrrr!)rZeventrrrrr!<s
z(SCSIHostPlugin._hardware_events_callbackcstt|��||�dSr)rr�_added_device_apply_tuning�r�instanceZdevice_namerrrr$@sz)SCSIHostPlugin._added_device_apply_tuningcstt|��||�dSr)rr�_removed_device_unapply_tuningr%rrrr'Csz-SCSIHostPlugin._removed_device_unapply_tuningcCsddiS)N�alpmr)r rrr�_get_config_optionsFs�z"SCSIHostPlugin._get_config_optionscCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning�rr&rrr�_instance_initLszSCSIHostPlugin._instance_initcCsdSrrr*rrr�_instance_cleanupPsz SCSIHostPlugin._instance_cleanupcCstj�dt|�d�S)N�/sys/class/scsi_host/Zlink_power_management_policy��os�path�join�strrrrr�_get_alpm_policy_fileSsz$SCSIHostPlugin._get_alpm_policy_filecCstj�dt|�d�S)Nr-Z
ahci_port_cmdr.rrrr�_get_ahci_port_cmd_fileVsz&SCSIHostPlugin._get_ahci_port_cmd_filecCs8|�|�}tj�|�sdSt|j�|�d�}|d@dkS)NF�i$r)r4r/r0�isfile�intr
�	read_file)rrZ
port_cmd_fileZport_cmdrrr�_is_external_sata_portYs

z%SCSIHostPlugin._is_external_sata_portr(T)Z
per_devicecCs�|durdS|�|�r,t�dt|��dS|�|�}|s�tj�|�rf|jj	|||r\t
jgndd�nt�d|t|�f�dS|S)NzUDevice '%s' is an external SATA controller, skipping ALPM setting to support hot plugF�Zno_errorzBALPM control file ('%s') not found, skipping ALPM setting for '%s')r9�log�infor2r3r/r0�existsr
Z
write_to_file�errno�ENOENT)r�policyrr&Zsim�remove�policy_filerrr�	_set_alpmbs


�zSCSIHostPlugin._set_alpmFcCs.|�|�}|jj|dd���}|dkr*|SdS)NTr:�)r3r
r8�strip)rrr&Zignore_missingrBr@rrr�	_get_alpmus
zSCSIHostPlugin._get_alpm)F)�__name__�
__module__�__qualname__�__doc__r	rr�classmethodrr"r#r!r$r'r)r+r,r3r4r9Zcommand_setrCZcommand_getrF�
__classcell__rrrrrs,


	

r)r>rDrZ
decoratorsZ
tuned.logsZtunedZtuned.constsZconstsZtuned.utils.commandsrr/�reZlogs�getr;ZPluginrrrrr�<module>s


Zerion Mini Shell 1.0