File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_systemd.cpython-39.pyc
a
�Գf4 � @ sp d dl mZ d dlT ddlZd dl mZ ddlmZ ddlm Z ddl
Z
ddlZej�
� ZG dd� dej�ZdS ) � )�base)�*� N)�
exceptions)�commandsc s� e Zd ZdZ� fdd�Zdd� Zdd� Zedd � �Zd
d� Z dd
� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zejfdd�Zdd� Zeddd�dd � �Z� ZS )!�
SystemdPlugina<
`systemd`::
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.
c s@ t j�tj�st�dtj ��tt| �j |i |�� t
� | _d S )NzERequired systemd '%s' configuration file not found, disabling plugin.)�os�path�isfile�consts�SYSTEMD_SYSTEM_CONF_FILEr ZNotSupportedPluginException�superr �__init__r �_cmd)�self�args�kwargs�� __class__� �@/usr/lib/python3.9/site-packages/tuned/plugins/plugin_systemd.pyr $ s zSystemdPlugin.__init__c C s d|_ d|_d S )NFT)Z_has_dynamic_tuningZ_has_static_tuning�r �instancer r r �_instance_init* s zSystemdPlugin._instance_initc C s d S �Nr r r r r �_instance_cleanup. s zSystemdPlugin._instance_cleanupc C s dd iS )N�cpu_affinityr )�clsr r r �_get_config_options1 s �z!SystemdPlugin._get_config_optionsc C sB |d ur>t jd| d |t jd�}|d ur>|jdkr>|�d�S d S )N�^\s*z\s*=\s*(.*)$��flagsr )�re�search� MULTILINE� lastindex�group)r �conf�key�mor r r �_get_keyval7 s
zSystemdPlugin._get_keyvalc C s| t jd| d dt|� |t jd�\}}|dk rxz|d dkrF|d7 }W n tyZ Y n0 ||d t|� d 7 }|S |S ) Nz^(\s*z\s*=).*$z\g<1>r r ����
�=)r"