Current File : //usr/lib/python3/dist-packages/landscape/lib/__pycache__/vm_info.cpython-312.pyc
�

�~�ev��T�dZddlZddlmZddlmZdZdd�Zd
d�Zd�Zd	�Z	d
�Z
d�Zy)zG
Network introspection utilities using ioctl and the /proc filesystem.
�N)�read_binary_file)�read_text_file)�
sys_vendor�chassis_vendor�bios_vendor�product_namec�@�t|�ryt|�rytjj	|d�}t
D]S}tjj	||�}tjj
|�s�Ct|�}|s�Q|cSt|�S)a
    Return a bytestring with the virtualization type if it's known, an empty
    bytestring otherwise.

    It loops through some possible configurations and return a bytestring with
    the name of the technology being used or None if there's no match
    sopenvzsxenzsys/class/dmi/id)	�
_is_vm_openvz�
_is_vm_xen�os�path�join�	DMI_FILES�exists�_get_vm_by_vendor�_get_vm_legacy)�	root_path�
dmi_info_path�
dmi_info_file�dmi_vendor_path�vendors     �7/usr/lib/python3/dist-packages/landscape/lib/vm_info.py�get_vm_infor
s����Y����)����G�G�L�L��,>�?�M�"��
��'�'�,�,�}�m�D���w�w�~�~�o�.��"�?�3����M�
��)�$�$�c���dD]\}tjj||�}tjj|�s�Ct	|�j�cSy)zu
    Return a string with the type of container the client is running in, if
    any, an empty string otherwise.
    )�container_typezsystemd/container�)rr
rrr�strip)�run_path�filenamer
s   r�get_container_infor!(sP��
<�0���w�w�|�|�H�h�/��
�7�7�>�>�$��!�$�'�-�-�/�/�0�rc��tjj|d�}tjj|�xrtj|�S)z*Check if the host is virtualized with Xen.zsys/bus/xen/devices)rr
r�isdir�listdir)r�sys_xen_paths  rrr4s8���7�7�<�<�	�+@�A�L�
�7�7�=�=��&�C�2�:�:�l�+C�Crc�|�tjjtjj|d��S)z-Check if the host is virtualized with OpenVZ.zproc/vz)rr
rr)rs rr
r
;s$��
�7�7�>�>�"�'�'�,�,�y�)�<�=�=rc�b�t|d��j�}d}|D]
\}}||vs�|cSy)zDReturn the VM type byte string (possibly empty) based on the vendor.i)�limit)
)s
amazon ec2�kvm)sbochsr))sdigitaloceanr))sgooglesgce)sinnoteks
virtualbox)s	microsoftshyperv)snutanixr))s	openstackr))sqemur))r)r))�vmwarer*)srhevr))s	parallelsr)r)r�lower)�sys_vendor_pathr�content_vendors_map�name�vm_types     rrr@sG���o�T�
:�
@�
@�
B�F���-��
��g��6�>��N��rc��	ttjj|d��}d|vryy#t$rYywxYw)zBCheck if the host is virtualized looking at /proc/cpuinfo content.zproc/cpuinfor�qemur))rrr
r�OSError)r�cpuinfos  rrr\sD��� ������i��!H�I��������
����s�)1�	=�=)�/)z/run)�__doc__r�landscape.lib.fsrrrrr!rr
rr�rr�<module>r8s<���
�-�+�
L�	�%�6	�D�>�
�8
r