HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/landscape/lib/__pycache__/vm_info.cpython-310.pyc
o

y)�]��@sXdZddlZddlmZmZdZddd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)zG
Network introspection utilities using ioctl and the /proc filesystem.
�N)�read_binary_file�read_text_file)�
sys_vendor�chassis_vendor�bios_vendor�product_name�/cCsht|�rdSt|�rdStj�|d�}tD]}tj�||�}tj�|�s%qt|�}|r/|Sqt|�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�vendor�r�7/usr/lib/python3/dist-packages/landscape/lib/vm_info.py�get_vm_infos�r�/runcCs8dD]}tj�||�}tj�|�rt|���SqdS)zu
    Return a string with the type of container the client is running in, if
    any, an empty string otherwise.
    )�container_typezsystemd/container�)rrr
rr�strip)�run_path�filenamerrrr�get_container_info's�r cCs$tj�|d�}tj�|�ot�|�S)z*Check if the host is virtualized with Xen.zsys/bus/xen/devices)rrr
�isdir�listdir)r�sys_xen_pathrrrr
3sr
cCstj�tj�|d��S)z-Check if the host is virtualized with OpenVZ.zproc/vz)rrrr
)rrrrr	:sr	cCs6t|dd���}d}|D]\}}||vr|SqdS)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&�)r�lower)�sys_vendor_pathr�content_vendors_map�name�vm_typerrrr?s
�rc	Cs@zttj�|d��}WnttfyYdSwd|vrdSdS)zBCheck if the host is virtualized looking at /proc/cpuinfo content.zproc/cpuinfor'�qemur%)rrrr
�IOError�OSError)r�cpuinforrrr\s�r)r)r)�__doc__r�landscape.lib.fsrrrrr r
r	rrrrrr�<module>s