o
    VAf^  ã                   @   sV   d dl mZ d dl mZ G dd„ deƒZedkr)eƒ Zedejƒ edej	ƒ dS dS )	é   )Ú	_fireinfo)Úsystemc                   @   sh   e Zd Zdd„ Zedd„ ƒZedd„ ƒZedd„ ƒZd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )Ú
Hypervisorc                 C   s   t  ¡ | _d S )N)r   Zdetect_hypervisorÚ_Hypervisor__hypervisor©Úself© r   ú8/usr/lib/python3.10/site-packages/fireinfo/hypervisor.pyÚ__init__   ó   zHypervisor.__init__c                 C   s   t  ¡ S )z…
			Return the current instance of the System class.

			We need to do that as a property because otherwise
			we get a recursion.
		)r   ZSystemr   r   r   r	   r      s   zHypervisor.systemc                 C   sr   | j dkr| jjdkrdS | j r| j S |  ¡ rdS |  ¡ rdS |  ¡ r%dS |  ¡ r+dS |  ¡ r1dS |  ¡ r7dS dS )z1
			Returns the name of the hypervisor vendor.
		Z	MicrosoftÚXenÚBochsZQemuZ
VirtualBoxZVMWareN)	r   r   Zbios_vendorÚ_Hypervisor__bios_is_bochsÚ_Hypervisor__bios_is_microsoftÚ_Hypervisor__bios_is_qemuÚ_Hypervisor__bios_is_virtualboxÚ_Hypervisor__bios_is_vmwareÚ_Hypervisor__bios_is_xenr   r   r   r	   Úvendor&   s"   ÿzHypervisor.vendorc                 C   s   | j rdS dS )zY
			Returns true if the host is running in a virtual environment.
			Otherwise: false.
		TF)r   r   r   r   r	   ÚvirtualB   s   zHypervisor.virtualc                 C   ó   | j j d¡S )z 
			Check for Bochs emulator.
		r   ©r   ZbiosZcheck_vendorr   r   r   r	   Z__bios_is_bochsM   ó   zHypervisor.__bios_is_bochsc                 C   r   )z&
			Check for Microsoft hypervisor.
		zMicrosoft Corporationr   r   r   r   r	   Z__bios_is_microsoftS   r   zHypervisor.__bios_is_microsoftc                 C   r   )z
			Check for qemu emulator.
		ZQEMUr   r   r   r   r	   Z__bios_is_qemuY   r   zHypervisor.__bios_is_qemuc                 C   r   )z`
			Check for virtualbox hypervisor by comparing the bios vendor string
			to "innotek GmbH".
		zinnotek GmbHr   r   r   r   r	   Z__bios_is_virtualbox_   s   zHypervisor.__bios_is_virtualboxc                 C   s(   | j j d¡r	dS | j j d¡rdS dS )NzVMware-TZVMWFr   r   r   r   r	   Z__bios_is_vmwaref   s
   zHypervisor.__bios_is_vmwarec                 C   r   )Nr   r   r   r   r   r	   Z__bios_is_xenn   r   zHypervisor.__bios_is_xenN)Ú__name__Ú
__module__Ú__qualname__r
   Úpropertyr   r   r   r   r   r   r   r   r   r   r   r   r	   r      s    
	


r   Ú__main__zVendor:zVirtual:N)
Ú r   r   Úobjectr   r   ÚhÚprintr   r   r   r   r   r	   Ú<module>   s   Zü