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__/smbios.cpython-310.pyc
o

�N�g(�@s�dZddlZddlZddlZddlZddlZe�e�Z	dd�Z
ddd�Zddd	�Zdd
d�Z
dd
�Zddd�Zdd�Zddd�ZdS)a!
Interface to SMBIOS/DMI

(Parsing through dmidecode)

External References
-------------------
| `Desktop Management Interface (DMI) <http://www.dmtf.org/standards/dmi>`_
| `System Management BIOS <http://www.dmtf.org/standards/smbios>`_
| `DMIdecode <http://www.nongnu.org/dmidecode/>`_

�NcCsttjj�ddg��dfS)z0
    Only work when dmidecode is installed.
    �	dmidecode�smbioszUThe smbios execution module failed to load: neither dmidecode nor smbios in the path.)�bool�salt�utils�path�	which_bin�r	r	�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/smbios.py�__virtual__s�rTcCsLtd|�����}d�dd�|�d�D��}|�d�s"|r$t||�s$d}|S)a]
    Get an individual DMI string from SMBIOS info

    string
        The string to fetch. DMIdecode supports:
          - ``bios-vendor``
          - ``bios-version``
          - ``bios-release-date``
          - ``system-manufacturer``
          - ``system-product-name``
          - ``system-version``
          - ``system-serial-number``
          - ``system-uuid``
          - ``baseboard-manufacturer``
          - ``baseboard-product-name``
          - ``baseboard-version``
          - ``baseboard-serial-number``
          - ``baseboard-asset-tag``
          - ``chassis-manufacturer``
          - ``chassis-type``
          - ``chassis-version``
          - ``chassis-serial-number``
          - ``chassis-asset-tag``
          - ``processor-family``
          - ``processor-manufacturer``
          - ``processor-version``
          - ``processor-frequency``

    clean
      | Don't return well-known false information
      | (invalid UUID's, serial 000000000's, etcetera)
      | Defaults to ``True``

    CLI Example:

    .. code-block:: bash

        salt '*' smbios.get system-uuid clean=False
    z-s �
cSsg|]	}|�d�s|�qS)�#)�
startswith)�.0�vr	r	r
�
<listcomp>Qszget.<locals>.<listcomp>z/dev/memN)�_dmidecoder�strip�join�splitr�_dmi_isclean)�string�clean�valr	r	r
�get%s
)rcCs4|dur
tt�||�}|Sttd|���||�}|S)a
    Return DMI records from SMBIOS

    type
        Return only records of type(s)
        The SMBIOS specification defines the following DMI types:

        ====  ======================================
        Type  Information
        ====  ======================================
         0    BIOS
         1    System
         2    Baseboard
         3    Chassis
         4    Processor
         5    Memory Controller
         6    Memory Module
         7    Cache
         8    Port Connector
         9    System Slots
        10    On Board Devices
        11    OEM Strings
        12    System Configuration Options
        13    BIOS Language
        14    Group Associations
        15    System Event Log
        16    Physical Memory Array
        17    Memory Device
        18    32-bit Memory Error
        19    Memory Array Mapped Address
        20    Memory Device Mapped Address
        21    Built-in Pointing Device
        22    Portable Battery
        23    System Reset
        24    Hardware Security
        25    System Power Controls
        26    Voltage Probe
        27    Cooling Device
        28    Temperature Probe
        29    Electrical Current Probe
        30    Out-of-band Remote Access
        31    Boot Integrity Services
        32    System Boot
        33    64-bit Memory Error
        34    Management Device
        35    Management Device Component
        36    Management Device Threshold Data
        37    Memory Channel
        38    IPMI Device
        39    Power Supply
        40    Additional Information
        41    Onboard Devices Extended Information
        42    Management Controller Host Interface
        ====  ======================================

    clean
      | Don't return well-known false information
      | (invalid UUID's, serial 000000000's, etcetera)
      | Defaults to ``True``

    CLI Example:

    .. code-block:: bash

        salt '*' smbios.records clean=False
        salt '*' smbios.records 14
        salt '*' smbios.records 4 core_count,thread_count,current_speed

    Nz-t )�
_dmi_parser)Zrec_type�fieldsrrr	r	r
�recordsXs
F�rc
Cs�g}t�dtjtj�}tt�||�dd��}t||�D]O\}}dd�|�d�D�dd�\}}|�d	�}t�d
|�||�	d��
�t|�d�}|sS|sR|�|�qt
|||�}	|	re|	|d<|�|�q|sl|�|�q|S)
zg
    Structurize DMI records into a nice list
    Optionally trash bogus entries and filter output
    z(handle [0-9]x[0-9a-f]+[^
]+)
�NcSsg|]}|��d�qS)���)r)rZhliner	r	r
r�sz_dmi_parse.<locals>.<listcomp>�,r�rzParsing handle %s)�handle�description�type�data)�re�compile�	MULTILINE�
IGNORECASE�iterr�zip�log�debug�popr�int�append�	_dmi_data)
r%rrZdmiZ	dmi_split�dmi_rawr"Zhtype�record�dmi_datar	r	r
r�s2� 
�

�rc
Csi}d}dgg}|D]s}t�d|�r_|dur3|\}}|r+|dur&|�d|�|||<n|dur3|||<|�dd�\}}	|�����dd�}|rK|dksQ|rT||vrTd}q
t||	��|�gg}q
|durdq
t�d	|�r}t||��|�}	|	dur}|d�|	�q
|S)
zP
    Parse the raw DMIdecode output of a single handle
    into a nice dict
    Nz\t[^\s]+r�:r� �_Zheader_and_dataz
\t\t[^\s]+)	r&�match�insertrr�lower�replace�	_dmi_castr0)
r2rrr4�keyZkey_data�line�valueZvlistrr	r	r
r1�s6
�r1cCsl|r	t||�s	dStjd|tjd�s4d|vr"dd�|�d�D�}|Szt|�}W|Sty3Y|Sw|S)zX
    Simple caster thingy for trying to fish out at least ints & lists from strings
    Nzserial|part|asset|product��flagsr cSsg|]}|���qSr	)r)r�elr	r	r
rsz_dmi_cast.<locals>.<listcomp>)rr&r8r)rr/�	Exception)r=rrr	r	r
r<s�
��r<c	Cs�|rtjd|tjd�r
dSd|vr:tdd�D]}ztj||d�WdSty,Yqwt�d	||�	d
d��dSt�
d|�rXt�d
|�oWt�d|�oWtj
d|tjd�St�
d|�rhtj
d|tjd�Stj
d|tjd�o{tj
d|tjd�S)z+
    Clean out well-known bogus values
    Znoner@F�uuidr�)�versionTz"DMI %s value %s is an invalid UUIDrr6zserial|part|versionz^[0]+$z[0]?1234567[8]?[9]?[0]?z2sernum|part[_-]?number|specified|filled|applicablezasset|manufacturerz3manufacturer|to be filled|available|asset|^no(ne|t)zto be filledzRun(known|specified)|no(t|ne)? (asset|provided|defined|available|present|specified))r&r8r)�rangerDZUUID�
ValueErrorr,Ztracer;�search)r=rZuuidverr	r	r
rsJ����	����rcCsDtjj�ddg�}|stjj�|�}|Stjj�|�d|���}|S)z
    Call DMIdecode
    rrr6)rrrr�modulesZcmdmodZ
_run_quiet)�argsZ
dmidecoder�outr	r	r
rHs�r)T)NNT)TN)N)�__doc__�loggingr&rDZsalt.modules.cmdmodrZsalt.utils.path�	getLogger�__name__r,rrrrr1r<rrr	r	r	r
�<module>s



3
N*
33