File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/tuned.cpython-310.pyc
o
�N�gM � @ sL d Z ddlZddlZddiZdZdd� Zdd� Zd d
� Zdd� Z d
d� Z
dS )z�
Interface to Red Hat tuned-adm module
:maintainer: Syed Ali <alicsyed@gmail.com>
:maturity: new
:depends: tuned-adm
:platform: Linux
� N�list_�listZtunedc C s t jj�d�} | sdS tS )zF
Check to see if tuned-adm binary is installed on the system
z tuned-adm)FzSThe tuned execution module failed to load: the tuned-adm binary is not in the path.)�salt�utils�path�which�__virtualname__)Z tuned_adm� r �F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/tuned.py�__virtual__ s r c C sb t d d��� } | �d� z
| d| �d�d � } W n ty# Y nw | �� dd� | D �} | S ) zn
List the profiles available
CLI Example:
.. code-block:: bash
salt '*' tuned.list
zcmd.runztuned-adm listr Nz** COLLECTED WARNINGS **� c S s g | ]}|� d �d �� �qS )z- r )�split�strip)�.0�ir r r
�
<listcomp>; s zlist_.<locals>.<listcomp>)�__salt__�
splitlines�pop�index�
ValueError��resultr r r
r $ s
�c C sJ t d ddd�} | d dkrdS t�d�}t�|| d �}d
�|�d��S )zr
Return current active profile
CLI Example:
.. code-block:: bash
salt '*' tuned.active
zcmd.run_allztuned-adm activeT)Zignore_retcode�retcoder Znonez4(?P<stmt>Current active profile:) (?P<profile>\w+.*)�stdoutz{}�profile)r �re�compile�match�format�group)r �patternr r r r
�active? s
r"