HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/kmod.cpython-310.pyc
o

�N�g�!�@s,dZdd�Zdd�Zddd�Zd
d
d�ZdS)ae
Loading and unloading of kernel modules
=======================================

The Kernel modules on a system can be managed cleanly with the kmod state
module:

.. code-block:: yaml

    add_kvm:
      kmod.present:
        - name: kvm_amd
    remove_beep:
      kmod.absent:
        - name: pcspkr

Multiple modules can be specified for both kmod.present and kmod.absent.

.. code-block:: yaml

    add_sound:
      kmod.present:
        - mods:
          - snd_hda_codec_hdmi
          - snd_hda_codec
          - snd_hwdep
          - snd_hda_core
          - snd_pcm
          - snd_timer
          - snd
cCsdtvrdSdS)z?
    Only load if the kmod module is available in __salt__
    �kmod.availableT)Fzkmod module could not be loaded)�__salt__�rr�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/kmod.py�__virtual__"srcCs0|dr|d��d||d<|S||d<|S)z2
    append ``comment`` to ``ret['comment']``
    �comment�
)�rstrip)�retrrrr�_append_comment+s
�r
FNcCsbt|ttf�s
|g}|didd�}td�}|r(tdd�}tt|�t|�@�}tt|�t|�@�}t|�dkrFd|d�d�}t||�nt|�dkrYd	�d
�|��}t||�t|�t|�krc|Stt|�t|��}t	dr�d|d
<|dr�|dd7<t|�dkr�d|d�d�}nd�d
�|��}t||�|Stt|�ttd���}	|	r�t|	�dkr�d|	d�d�}nd�d
�|	��}t||�d|d
<tt|�t|	��}
gggd�}g}|
D][}
|
|vr�|d�
|
�q�td|
|�}t|ttf��r0t|�dk�r$|D]}d|d|<||
k�r|�
|��q|d�
|
�q�d|d
<|d�
|
�q�d|d
<|d�
|
|g�q�t|d�dk�rTt|d�|dd��nt|d�dk�rjt|d�d
�|d���t|d�dk�rt|d�|dd��t|d�dk�r�t|d �d
�|d���|d�r�|dD]\}
}t|d!|
�d"|����q�|S)#a
    Ensure that the specified kernel module is loaded

    name
        The name of the kernel module to verify is loaded

    persist
        Also add module to ``/etc/modules`` (or
        ``/etc/modules-load.d/salt_managed.conf`` if the ``systemd`` key is
        present in Grains.

    mods
        A list of modules to verify are loaded.  If this argument is used, the
        ``name`` argument, although still required, is not used, and becomes a
        placeholder

        .. versionadded:: 2016.3.0
    T���name�result�changesr�
kmod.mod_list��Kernel module �z is already presentz%Kernel modules {} are already present�, �testNrrrz is set to be loadedz&Kernel modules {} are set to be loadedrz is unavailablez!Kernel modules {} are unavailableF��yes�no�failedrz	kmod.load�loadedrrrzLoaded kernel module {}zLoaded kernel modules {}zFailed to load kernel module {}z Failed to load kernel modules {}zFailed to load kernel module �: )�
isinstance�list�tupler�set�lenr
�format�join�__opts__�append)r
�persist�modsr	�loaded_mods�persist_modsZalready_loadedrZ
not_loadedZunavailableZ	availablerZloaded_by_dependency�modZload_result�module�msgrrr�present7s�
�
�



���
r,Tc
Cs|t|ttf�s
|g}|didd�}td�}|r(tdd�}tt|�t|�B�}tt|�t|�@�}|�rtdrcd|d<t|�dkrPt|d	|d
�d��|St|�dkrat|d�d
�	|���|Sgggd�}|D]C}	td|	||�}
t|
ttf�r�t|
�d
kr�|
D]}d|d|<q�|d�
|	�qkd|d<|d�
|	�qkd|d<|d�
|	|
g�qkt|d�dkr�t|d�|dd
��nt|d�dkr�t|d�d
�	|d���t|d�dkr�t|d�|dd
��t|d�dk�rt|d�d
�	|d���|d�r|dD]\}	}t|d|	�d|����q|St|�dk�r2d	|d
�d�|d<|Sd�d
�	|��|d<|S)a[
    Verify that the named kernel module is not loaded

    name
        The name of the kernel module to verify is not loaded

    persist
        Remove module from ``/etc/modules`` (or
        ``/etc/modules-load.d/salt_managed.conf`` if the ``systemd`` key is
        present in Grains.

    comment
        Comment out module in ``/etc/modules`` rather than remove it

    mods
        A list of modules to verify are unloaded.  If this argument is used,
        the ``name`` argument, although still required, is not used, and
        becomes a placeholder

        .. versionadded:: 2016.3.0
    TrrrrNrrrrz is set to be removedz'Kernel modules {} are set to be removedrrzkmod.removeZremovedrrFrrzRemoved kernel module {}zRemoved kernel modules {}z!Failed to remove kernel module {}z"Failed to remove kernel modules {}zFailed to remove kernel module rz is already removedrz%Kernel modules {} are already removed)rrrrrr#r r
r!r"r$)
r
r%rr&r	r'r(Z	to_unloadZunloadedr)Z
unload_resultr*r+rrr�absent�s|
�
������
��r-)FN)FTN)�__doc__rr
r,r-rrrr�<module>s
!	
r