HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/devinfo.cpython-310.pyc
o

�N�g8$�@svdZddlZe�e�ZddiZdd�Zdd�Zdd	d�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zddd�ZdS)z�
Module for devinfo
:maintainer:    Alberto Planas <aplanas@suse.com>
:maturity:      new
:depends:       None
:platform:      Linux
�N�filter_�filtercCsP|�d�\}}}|s|St|t�sdS|s|�|��d�St|�|��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
cCsxd}|��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
rr�log�warning�list�set)rZ
match_info�resr�valueZ
udev_valuerrr�_match%s

�rcsb�r�ni��r
�ni�td}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"}'

    ZdiskscSsi|]	}|td|��qS)z	udev.info)�__salt__��.0�drrr�
<dictcomp>aszfilter_.<locals>.<dictcomp>csh|]}t�|��r|�qSr�rr)�udev_inrrr�	<setcomp>cszfilter_.<locals>.<setcomp>cs"h|]
}t�|��r�r|�qSrrr)�udev_exrrrr!ds���)�
__grains__�sorted)r r"Zall_devicesZdevices_udev_key_inZdevices_udev_key_exr)r"r rrr=s�cCs�i}i}d}|����D]F}|�d�r |}|d7}|��||<q|�d�r6|���dd�\}}|��||<q|�d�rL|dd�}i}|||<|}d}qt�d	|�q|S)
�2Parse the output of hwinfo and return a dictionaryrz    ��  � �:N���z%Error parsing hwinfo short output: %s)�strip�
splitlines�
startswith�split�endswithr�error)�report�resultZcurrent_resultZkey_counter�linerrrrr�_hwinfo_parse_shortks&


r4c
Cs~i}g}d}|����D�]/}|�d�}||kst|�|kr&|d|�}|}|��}|s-q|dkrW|�dd�\}}i}|||<|���dd�\}}|||<|�|�|d7}q|�d�s`d|vrt|d}|�d�sk|n|dd�|d	<q|�dd�\}}|��|��}}|d}|�r|�d
��s|dk�r|dkr�d
}n9|dkr�tdd�|�d�D��}n(|dvr�|�dd��d�}n|dvr�dd�|�d�D�}n|�d�r�|dd�}||vr�||}	t	|	�t
ur�|	g}	||	vr�|	�|�t|	�dkr�|	d}n|	}|||<q|�d
��rd|i}n!|dk�r-|�d�}|d��dd|dv�r(dndd�}ni}|||<|�|�|d7}q|S)r%rr'Nr)r&z: �[r*ZNote�#zEl Torito infozI/O Portz	I/O Portsz
Config Statuscss�|]}|�d�VqdS)�=N)r.)r�itemrrr�	<genexpr>�s�z%_hwinfo_parse_full.<locals>.<genexpr>z, )ZDriverzDriver Modules�"�)ZTagszDevice FilesZFeaturescSsg|]}|���qSr)r+)r�vrrr�
<listcomp>�sz&_hwinfo_parse_full.<locals>.<listcomp>�,�Handle�not�noZyes)�platformZbootable)r+r,�count�lenr.�appendr-r�replace�typer)
r1r2Zresult_stack�levelr3Z
current_levelrrZ
sub_resultZ
current_valuerrr�_hwinfo_parse_full�sx








�

rIcCs|rt|�St|�S)r%)r4rI)r1�shortrrr�
_hwinfo_parse�srKcCstdtdd�S)zReturn information about EFI�efi�efi-secure-boot)rLrM�r#rrrr�_hwinfo_efi�s�rOcCsdtdiS)z#Return information about the memoryZ	mem_totalrNrrrr�_hwinfo_memory�s�rPcCs&tdtdd�}|std|d<|S)zReturn network information�fqdn�
ip_interfaces)rQrRZdnsrN)rJ�inforrr�_hwinfo_network�s�rTTFc	Cs�i}|sgd�}t|ttf�s|g}|sg}|r"t|ttf�s"|g}dg}|D]
}|�d|���q'|r9|�d�|r@|�d�|D]
}|�d|���qBtd|�}t||�|d<d|vrct�|d	<d
|vrlt�|d<d|vrvt|�|d
<|S)a]
    Probe for hardware

    items
        List of hardware items to inspect. Default ['bios', 'cpu', 'disk',
        'memory', 'network', 'partition']

    short
        Show only a summary. Default True.

    listmd
        Report RAID devices. Default False.

    devices
        List of devices to show information from. Default None.

    CLI Example:

    .. code-block:: bash

       salt '*' devinfo.hwinfo
       salt '*' devinfo.hwinfo items='["disk"]' short=no
       salt '*' devinfo.hwinfo items='["disk"]' short=no devices='["/dev/sda"]'
       salt '*' devinfo.hwinfo devices=/dev/sda

    )�biosZcpuZdisk�memory�networkr�hwinfoz--z--shortz--listmdz--only zcmd.run_stdoutrUzbios grainsrVz
memory grainsrWznetwork grains)	rr�tuplerErrKrOrPrT)	rrJZlistmdZdevicesr2�cmdr8Zdevice�outrrrrX�s6



rX)NN)NTFN)�__doc__�logging�	getLogger�__name__rZ__func_alias__r
rrr4rIrKrOrPrTrXrrrr�<module>s
�
.W