a ”ˆ«hã@s@ddlmZddlmZddlZej ¡ZGdd„dej ƒZ dS)é)ÚbaseéNcs”eZdZdZ‡fdd„Z‡fdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Z‡ZS) ÚPluginz: Base class for plugins with device hotpluging support. cstt|ƒj|i|¤ŽdS©N)ÚsuperrÚ__init__)ÚselfÚargsÚkwargs©Ú __class__©ú9/usr/lib/python3.9/site-packages/tuned/plugins/hotplug.pyr szPlugin.__init__cs| ¡tt|ƒ ¡dSr)Ú_hardware_events_cleanuprrÚcleanup©rr r rrszPlugin.cleanupcCsdSrr rr r rÚ_hardware_events_initszPlugin._hardware_events_initcCsdSrr rr r rrszPlugin._hardware_events_cleanupcCs | ¡dSr)rrr r rÚ _init_devicesszPlugin._init_devicescCst|dkr&t d|j¡| |j¡nJ|dkrLt d|j¡| |j¡n$|dkrpt d|j¡| |j¡dS)NÚaddzdevice '%s', add eventÚremovezdevice '%s', remove eventÚmovez-device: '%s', rename event, reported new name)ÚlogÚinfoZsys_nameÚ _add_deviceÚ_remove_deviceÚ _move_device)rZeventZdevicer r rÚ_hardware_events_callbacksz Plugin._hardware_events_callbackcCsdt d|j|f¡|j |¡| ||jd|g¡| ||¡| ||jd|g¡|j  |¡dS)Nz!instance %s: adding new device %sZapply) rrÚnameÚ_assigned_devicesrÚ_call_device_scriptÚ script_preÚ_added_device_apply_tuningÚ script_postÚprocessed_devices©rÚinstanceÚ device_namer r rÚ_add_device_process's   zPlugin._add_device_processcCs~||j|jBvr"t d|¡dSt|j ¡ƒD].\}}t| ||g¡ƒdkr0|  ||¡qzq0t d|¡|j  |¡dS)Nz%device: '%s' already exists, ignoringrzno instance wants %s) rÚ _free_devicesrÚdebugÚlistÚ _instancesÚitemsÚlenZ_get_matching_devicesr'r)rr&Z instance_namer%r r rr/s zPlugin._add_devicecCs4|D]}| ||¡qt|jƒt|jƒdk|_dS)zN Add devices specified by the set to the instance, no check is performed. rN)r'r-r#Úassigned_devicesÚactive©rr%Z device_namesÚdevr r rÚ_add_devices_nocheck<sÿÿzPlugin._add_devices_nocheckcCsx||jvrt| ||jd|g¡| ||¡| ||jd|g¡|j |¡t|jƒt|jƒdk|_|j  |¡dSdS)NZunapplyrTF) r#rr"Ú_removed_device_unapply_tuningr rr-r.r/rr$r r rÚ_remove_device_processGs   ÿÿ zPlugin._remove_device_processcCsdS)aeRename device in the instance, this probably applies only to network interfaces. The udev device environment is mostly unchanged (except the name) and the old device name isn't announced, thus the rename functionality is plugin dependant and has to be implemented in the child plugin class. Parameters: device_name -- new name of the device Nr )rr&r r rrUs zPlugin._move_devicecCs|||j|jBvr"t d|¡dSt|j ¡ƒD]}| ||¡r0qxq0z|j |¡Wn t yvt d|¡Yn0dS)zVRemove device from the instance Parameters: device_name -- name of the device z$device: '%s' doesn't exist, ignoringNz/device: '%s' isn't initialized, not removing it) rr(rr)r*r+Úvaluesr4rÚKeyError)rr&r%r r rrbs  zPlugin._remove_devicecCs|D]}| ||¡qdS)zS Remove devices specified by the set from the instance, no check is performed. N)r4r0r r rÚ_remove_devices_nocheckvszPlugin._remove_devices_nocheckcCs6| ||g¡|jr2|j tjtj¡r2| ||¡dSr)Z_execute_all_device_commandsÚhas_dynamic_tuningÚ _global_cfgÚgetÚconstsÚCFG_DYNAMIC_TUNINGÚCFG_DEF_DYNAMIC_TUNINGZ_instance_apply_dynamicr$r r rr!}sz!Plugin._added_device_apply_tuningcCs:|jr$|j tjtj¡r$| ||¡|j||gdddS)NT)r)r8r9r:r;r<r=Z_instance_unapply_dynamicZ_cleanup_all_device_commandsr$r r rr3‚s z%Plugin._removed_device_unapply_tuning)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrr'rr2r4rrr7r!r3Ú __classcell__r r r rrs       r) ÚrZ tuned.constsr;Z tuned.logsZtunedZlogsr:rrr r r rÚs