%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/cloudinit/__pycache__/dmi.cpython-312.pyc

�

���f!���ddlZddlZddlZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
eje�ZdZedgd��Zd	ej&_id
eddd��d
eddd��deddd��deddd��deddd��deddd��deddd��ded d!d��d"ed#d$d��d%ed&d'd(��d)ed*d+d,��d-ed.d/d��d0ed1d2d(��d3ed4d5d6��d7ed8d9d,��d:ed;d<d,��d=ed>d?d��Zd@edAeefdB�Zd@edAeefdC�Zd@edAeefdD�Zd@edEedAeefdF�Zd@edAeefdG�ZdHedAefdI�Zy)J�N)�
namedtuple)�Optional)�subp)�is_container�is_DragonFlyBSD�
is_FreeBSD�
is_OpenBSDz/sys/class/dmi/id�KernelNames)�linux�freebsd�openbsd)NNNzbaseboard-asset-tag�board_asset_tagzsmbios.planar.tagzbaseboard-manufacturer�board_vendorzsmbios.planar.makerzbaseboard-product-name�
board_namezsmbios.planar.productzbaseboard-serial-number�board_serialzsmbios.planar.serialzbaseboard-version�
board_versionzsmbios.planar.versionzbios-release-date�	bios_datezsmbios.bios.reldatezbios-vendor�bios_vendorzsmbios.bios.vendorzbios-version�bios_versionzsmbios.bios.versionzchassis-asset-tag�chassis_asset_tagzsmbios.chassis.tagzchassis-manufacturer�chassis_vendorzsmbios.chassis.makerz	hw.vendorzchassis-serial-number�chassis_serialzsmbios.chassis.serialzhw.uuidzchassis-version�chassis_versionzsmbios.chassis.versionzsystem-manufacturer�
sys_vendorzsmbios.system.makerzsystem-product-name�product_namezsmbios.system.productz
hw.productzsystem-serial-number�product_serialzsmbios.system.serialzsystem-uuid�product_uuidzsmbios.system.uuidzsystem-version�product_versionzsmbios.system.version�key�returnc��tj|�}|�|j�ydjt|j�}t
j
d|�tjj|�st
j
d|�y	t|d�5}|j�}ddd�dt|�dz
zd	zk(rd
}	|jd�j�S#1swY�BxYw#t$rt
j
d|�YywxYw#t $r"}t
j#d|||�Yd}~yd}~wwxYw)
z/
    Reads dmi data from /sys/class/dmi/id
    Nz{0}/{1}�querying dmi data %szdid not find %s�rbzCould not read %s����
��utf8z-utf-8 decode of content (%s) in %s failed: %s)�DMIDECODE_TO_KERNEL�getr�format�DMI_SYS_PATH�LOG�debug�os�path�exists�open�read�PermissionError�len�decode�strip�UnicodeDecodeError�error)r�kmap�dmi_key_path�fp�key_data�es      �//usr/lib/python3/dist-packages/cloudinit/dmi.py�_read_dmi_syspathr@Ps/���"�"�3�'�D��|�t�z�z�)���#�#�L�$�*�*�=�L��I�I�$�l�3�
�7�7�>�>�,�'��	�	�#�\�2���
�,��
%�	!���w�w�y�H�	!��7�c�(�m�a�/�0�5�8�8���
����v�&�,�,�.�.�	!�	!�����	�	�%�|�4�����
��	�	�;���
�		
�	
���
�sB�C<�C0�/C<�D!�0C9�5C<�<D�D�!	E�*E�Ec��tj|�}|�|j�ytj	d|j�	dd|jg}tj
|�jj�}tj	d||j�|S#t
j$r!}tj	d|�Yd}~yd}~wwxYw)z/
    Reads dmi data from FreeBSD's kenv(1)
    Nr"�kenvz-qzkenv returned '%s' for '%s'zfailed kenv cmd: %s
%s)	r)r*rr-r.r�stdoutr7�ProcessExecutionError�rr:�cmd�resultr>s     r?�
_read_kenvrHvs����"�"�3�'�D��|�t�|�|�+���I�I�$�d�l�l�3�5��t�T�\�\�*�����3��&�&�,�,�.���	�	�/�����F��
���%�%�5��	�	�+�S�!�4�4���5���AB%�%C�8C�Cc��tj|�}|�|j�ytj	d|j�	dd|jg}tj
|�jj�}tj	d||j�|S#t
j$r!}tj	d|�Yd}~yd}~wwxYw)z1
    Reads dmi data from OpenBSD's sysctl(8)
    Nr"�sysctlz-qnzsysctl returned '%s' for '%s'zfailed sysctl cmd: %s
%s)	r)r*r
r-r.rrCr7rDrEs     r?�_read_sysctlrL�s����"�"�3�'�D��|�t�|�|�+���I�I�$�d�l�l�3�7������-�����3��&�&�,�,�.���	�	�1�6�4�<�<�H��
���%�%�7��	�	�-�s�A�6�6���7�rI�dmidecode_pathc�4�	|d|g}tj|�jj�}tj	d||�|jdd�dk(ry|S#tj$r!}tj	d|�Yd}~yd}~wwxYw)z
    Calls out to dmidecode to get the data out. This is mostly for supporting
    OS's without /sys/class/dmi/id support.
    z--stringz dmidecode returned '%s' for '%s'�.�zfailed dmidecode cmd: %s
%sN)rrCr7r-r.�replacerD)rrMrFrGr>s     r?�_call_dmidecoderR�s���
	��z�3�/�����3��&�&�,�,�.���	�	�4�f�c�B��>�>�#�r�"�b�(���
���%�%���	�	�0�#�q�9����s�AA#�!A#�#B�6B�Bc��t�ryt�s
t�rt|�St	�rt|�St
|�}|�|Sd�}tj�d}||�s|dvstjd|�ytjd�}|rt||�Stjdt�y)a�
    Wrapper for reading DMI data.

    If running in a container return None.  This is because DMI data is
    assumed to be not useful in a container as it does not represent the
    container but rather the host.

    This will do the following (returning the first that produces a
    result):
        1) Use a mapping to translate `key` from dmidecode naming to
           sysfs naming and look in /sys/class/dmi/... for a value.
        2) Use `key` as a sysfs key directly and look in /sys/class/dmi/...
        3) Fall-back to passing `key` to `dmidecode --string`.

    If all of the above fail to find a value, None will be returned.
    Nc�4�|dk(xs|ddk(xr|dddk(S)N�x86_64r�i��86�)�archs r?�is_x86zread_dmi_data.<locals>.is_x86�s*���x��H�D��G�s�N�$G�t�A�B�x�4�7G�Hr'�)�aarch64�amd64zdmidata is not supported on %s�	dmidecodez0did not find either path %s or dmidecode command)rrrrHr	rLr@r/�unamer-r.r�whichrRr,)r�
syspath_valuer[�
uname_archrMs     r?�
read_dmi_datard�s���$�~���|��(��#����|��C� � �%�c�*�M�� ���I�����A��J��:��*�0D�"D��	�	�2�J�?���Z�Z��,�N���s�N�3�3��I�I�@�,�O�r'�srcc�$�d|vr|Stj�}tjd|�D]\}||vrtjd|||�� t
|�}|sd}tjd|||�|jd|�d�|�}�^|S)zBReplace __dmi.VARNAME__ with DMI values from either sysfs or kenv.�__z__dmi\.([^_]+)__z7Ignoring invalid __dmi.%s__ in %s. Expected one of: %s.rPz'Replacing __dmi.%s__ in '%s' with '%s'.z__dmi.)	r)�keys�re�findallr-�warningrdr.rQ)re�valid_dmi_keys�match�	dmi_values    r?�sub_dmi_varsro�s����3���
�(�-�-�/�N����/��5�9����&��K�K�I����	
�
�!�%�(�	���I��	�	�5����		
��k�k�F�5�'��,�i�8��%9�&�Jr')�loggingr/ri�collectionsr�typingr�	cloudinitr�cloudinit.utilrrrr	�	getLogger�__name__r-r,r
�__new__�__defaults__r)�strr@rHrLrRrdrorYr'r?�<module>rzs����	�	�"������g����!��#����(G�H��#5���� �.��;��.���.��k��-�t��	.��k��-�t��.��{��.�� �.����0�$��.� ��[�2G��N�!.�"�;�}�.B�D�I�#.�$�K��0E�t�L�%.�&���1�4��'.�,�K��0�+��-.�2�[��1�9��3.�8�{��3�T��9.�>�;��+�[��?.�D�;��/���E.�J�K��0�)��K.�P�;��,�i��Q.�V�k��2�D��W.��b#�3�#�8�C�=�#�L�C��H�S�M��*�c��h�s�m��*���c��h�s�m��"-�s�-�x��}�-�`�c��c�r'

Zerion Mini Shell 1.0