File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/kmod.cpython-310.pyc
Back
o ;jn � @ s� d Z ddlZddlZddlZddlZddlZddlmZ e� e �Zdd� Zdd� Z dd � Zd d� Zdd � Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd$dd�Zd$dd�Zdd � Zd%d"d#�ZdS )&z' Module to manage Linux kernel modules � N)�CommandExecutionErrorc C s t d dkS )z$ Only runs on Linux systems Zkernel�Linux�� __grains__� r r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/kmod.py�__virtual__ s r c C sD t � }t � }| D ] }|�|d � q|D ] }|�|d � q|| S �zy Return a list of the new modules, pass an lsmod dict before running modprobe and one after modprobe has run �module��set�add��pre_mods� post_modsZpreZpost�modr r r � _new_mods � r c C sD t � }t � }| D ] }|�|d � q|D ] }|�|d � q|| S r r r r r r �_rm_mods% r r c C s dt v rdS dS )zK Return location of modules config file. Default: /etc/modules Zsystemdz%/etc/modules-load.d/salt_managed.confz/etc/modulesr r r r r �_get_modules_conf3 s r c C s | � � dkrdS | �� d S )z� Return module name and strip configuration. It is possible insert modules in this format: bonding mode=4 miimon=1000 This method return only 'bonding' � Fr )�strip�split�r r r r �_strip_module_name= s r c C s� t � }tj�|�std |� t| �}|r |td�v s |t� vr#t� S t � | �}td |d|� d�dd�r?td ||� |hS td || � |hS ) zj Add module to configuration file to make it persistent. If module is commented uncomment it. z file.touchTzfile.searchz^#[ ]*z[ ]*$)Z multilinezfile.uncommentzfile.append)r �os�path�exists�__salt__r �mod_list� availabler �re�escape)r �conf�mod_name� escape_modr r r �_set_persistent_moduleI s �r&