3 À<×eQ ã@sjddlZddlmZddlTddlZddljZddlm Z ddl Z ddl Z ej j ƒ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„Zeddd�dd „ƒZedƒd$d"d#„ƒZ‡ZS)%ÚSCSIHostPluginaä `scsi_host`:: 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 three values: `min_power`, `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=min_power ---- ==== cstt|ƒj||Žtƒ|_dS)N)ÚsuperrÚ__init__rÚ_cmd)ÚselfÚargsÚkwargs)Ú __class__©ú&/usr/lib/python3.6/plugin_scsi_host.pyr"szSCSIHostPlugin.__init__csVtt|ƒjƒd|_tƒ|_x,|jjdƒD]}|j|ƒr*|jj |j ƒq*Wtƒ|_ dS)NTÚscsi) rrÚ _init_devicesZ_devices_supportedÚsetZ _free_devicesÚ_hardware_inventoryZ get_devicesÚ_device_is_supportedÚaddZsys_nameZ_assigned_devices)r Údevice)r rrr's zSCSIHostPlugin._init_devicescs‡fdd„|DƒS)Ncsg|]}ˆjjd|ƒ‘qS)r)rZ get_device)Ú.0Úx)r rrú 2sz6SCSIHostPlugin._get_device_objects..r)r Zdevicesr)r rÚ_get_device_objects1sz"SCSIHostPlugin._get_device_objectscCs |jdkS)NZ scsi_host)Z device_type)Úclsrrrrr4sz#SCSIHostPlugin._device_is_supportedcCs|jj|d|jƒdS)Nr)rZ subscribeÚ_hardware_events_callback)r rrrÚ_hardware_events_init8sz$SCSIHostPlugin._hardware_events_initcCs|jj|ƒdS)N)rZ unsubscribe)r rrrÚ_hardware_events_cleanup;sz'SCSIHostPlugin._hardware_events_cleanupcs |j|ƒrtt|ƒj||ƒdS)N)rrrr)r Zeventr)r rrr>s z(SCSIHostPlugin._hardware_events_callbackcstt|ƒj||ƒdS)N)rrÚ_added_device_apply_tuning)r ÚinstanceÚ device_name)r rrrBsz)SCSIHostPlugin._added_device_apply_tuningcstt|ƒj||ƒdS)N)rrÚ_removed_device_unapply_tuning)r r r!)r rrr"Esz-SCSIHostPlugin._removed_device_unapply_tuningcCsddiS)NÚalpmr)rrrrÚ_get_config_optionsHsz"SCSIHostPlugin._get_config_optionscCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning)r r rrrÚ_instance_initNszSCSIHostPlugin._instance_initcCsdS)Nr)r r rrrÚ_instance_cleanupRsz SCSIHostPlugin._instance_cleanupcCstjjdt|ƒdƒS)Nz/sys/class/scsi_host/Zlink_power_management_policy)ÚosÚpathÚjoinÚstr)r rrrrÚ_get_alpm_policy_fileUsz$SCSIHostPlugin._get_alpm_policy_filer#T)Z per_devicecCsd|dkr dS|j|ƒ}|s`tjj|ƒrF|jj|||rs