File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/devinfo.cpython-310.pyc
Back
o ;j8$ � @ sv d Z ddlZe�e�ZddiZdd� Zdd� Zdd d�Zd d� Z dd � Z dd� Zdd� Zdd� Z dd� Zddd�ZdS )z� Module for devinfo :maintainer: Alberto Planas <aplanas@suse.com> :maturity: new :depends: None :platform: Linux � N�filter_�filterc C sP |� d�\}}}|s| S t| t�sdS |s| �|�� d�S t| �|�� i �|�S )z� Return the value for a udev key. The `key` parameter is a lower case text joined by dots. For example, 'e.id_bus' will represent the key for `udev_info['E']['ID_BUS']`. �.zn/a)� partition� isinstance�dict�get�upper�_udev)� udev_info�key�k�_�r� r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/devinfo.pyr s r c C sx d}|� � D ]3\}}t| |�}t|t�rt�d|� qt|t�r$t|�n|h}t|t�r0t|�n|h}|o8||@ }q|S )zG Check if `udev_info` match the information from `match_info`. TzDThe key %s for the udev information dictionary is not a leaf element)�itemsr r r �log�warning�list�set)r Z match_info�resr �valueZ udev_valuer r r �_match% s �r c sb �r�ni �� r � ni � t d }dd� |D ����fdd�|D �}� �fdd�|D �}t|| �S )a$ Returns a list of devices, filtered under udev keys. udev_in A dictionary of key:values that are expected in the device udev information udev_ex A dictionary of key:values that are not expected in the device udev information (excluded) The key is a lower case string, joined by dots, that represent a path in the udev information dictionary. For example, 'e.id_bus' will represent the udev entry `udev['E']['ID_BUS']` If the udev entry is a list, the algorithm will check that at least one item match one item of the value of the parameters. Returns list of devices that match `udev_in` and do not match `udev_ex`. CLI Example: .. code-block:: bash salt '*' devinfo.filter udev_in='{"e.id_bus": "ata"}' Zdisksc S s i | ] }|t d |��qS )z udev.info)�__salt__��.0�dr r r � <dictcomp>a s zfilter_.<locals>.<dictcomp>c s h | ]}t �| � �r|�qS r �r r )�udev_inr r r � <setcomp>c s zfilter_.<locals>.<setcomp>c s"