File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/virtualbox.cpython-310.pyc
o
�N�g�Y � @ s� d Z ddlZddlZddlZddlZddlZddlmZ e� e
�ZdZzddl
Z
dZW n ey; dZe�d� Y nw da g d�g d�d �Zd
Zg d�Zee�Z eee��Zdd
� Zdd� Zdd� Zd?dd�Z d@dd�ZdAdd�ZdBdd�ZdCdd�Z dd� Z!dDd d!�Z"dEd#d$�Z#d%d&� Z$dFd'd(�Z%dFd)d*�Z&dFd+d,�Z' d@d-d.�Z(d/d0� Z)d1d2� Z*d3d4� Z+d5d6� Z,d7d8� Z-d9d:� Z.d;d<� Z/d=d>� Z0dS )Gz�
Utilities to help make requests to virtualbox
The virtualbox SDK reference can be found at http://download.virtualbox.org/virtualbox/SDKRef.pdf
This code assumes vboxapi.py from VirtualBox distribution
being in PYTHONPATH, or installed system-wide
� N)�wait_forFTzCouldn't import VirtualBox API)�id�nameZ
accessible�description�groups�
memorySizeZOSTypeId�state)ZadapterTypeZslot�enabledZ
MACAddressZbridgedInterfaceZhostOnlyInterfaceZinternalNetworkZ
NATNetworkZ
genericDriverZcableConnected� lineSpeedr
)�IMachine�INetworkAdapter)ZUnknownz*This state is unknown to us. Might be new?))ZNullz"Null value (never used by the API))Z
PoweredOffz}The machine is not running and has no saved execution state; it has either never been started or been shut down successfully.)ZSavedz�The machine is not currently running, but the execution state of the machine has been saved to an external file when it was running, from where it can be resumed.)Z
Teleportedz�The machine was teleported to a different host (or process) and then powered off. Take care when powering it on again may corrupt resources it shares with the teleportation target (e.g. disk and network).)ZAbortedz�The process running the machine has terminated abnormally. This may indicate a crash of the VM process in host execution context, or the VM process has been terminated externally.)ZRunningz(The machine is currently being executed.)ZPausedz)Execution of the machine has been paused.)ZStuckz}Execution of the machine has reached the 'Guru Meditation' condition. This indicates a severe error in the hypervisor itself.)ZTeleportingz�The machine is about to be teleported to a different host or process. It is possible to pause a machine in this state, but it will go to the TeleportingPausedVM state and it will not be possible to resume it again unless the teleportation fails.)ZLiveSnapshottinga! A live snapshot is being taken. The machine is running normally, but some of the runtime configuration options are inaccessible. Also, if paused while in this state it will transition to OnlineSnapshotting and it will not be resume the execution until the snapshot operation has completed.)ZStartingzJMachine is being started after powering it on from a zero execution state.)ZStoppingzkMachine is being normally stopped powering it off, or after the guest OS has initiated a shutdown sequence.)ZSavingz0Machine is saving its execution state to a file.)Z RestoringzqExecution state of the machine is being restored from a file after powering it on from the saved execution state.)ZTeleportingPausedVMz�The machine is being teleported to another host or process, but it is not running. This is the paused variant of the Teleporting state.)Z
TeleportingInz>Teleporting the machine state in from another host or process.)ZFaultTolerantSyncingzHThe machine is being synced with a fault tolerant VM running else-where.)ZDeletingSnapshotOnlinezkLike DeletingSnapshot , but the merging of media is ongoing in the background while the machine is running.)ZDeletingSnapshotPausedzlLike DeletingSnapshotOnline , but the machine was paused when the merging of differencing media was started.)ZOnlineSnapshottingzfLike LiveSnapshotting , but the machine was paused when the merging of differencing media was started.)ZRestoringSnapshotzHA machine snapshot is being restored; this typically does not take long.)ZDeletingSnapshotz�A machine snapshot is being deleted; this can take a long time since this may require merging differencing media. This value indicates that the machine is not running while the snapshot is being deleted.)Z SettingUpz'Lengthy setup operation is in progress.)ZSnapshottingzTaking an (offline) snapshot.)ZFirstOnlinezEPseudo-state: first online state (for use in relational expressions).)Z
LastOnlinezDPseudo-state: last online state (for use in relational expressions).)ZFirstTransientzHPseudo-state: first transient state (for use in relational expressions).)Z
LastTransientzGPseudo-state: last transient state (for use in relational expressions).c C s* t du rtrtjj�t� t�dd�a t S )z�
Creates a 'singleton' manager to communicate with a local virtualbox hypervisor.
@return:
@rtype: VirtualBoxManager
N)�_virtualboxManager�HAS_LIBS�salt�utils�compat�reload�vboxapi�VirtualBoxManager� r r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/virtualbox.py�vb_get_manager� s r c C s0 t � ztj} W | S ty t�� } Y | S w )zm
Needed for certain operations in the SDK e.g creating sessions
@return:
@rtype: IVirtualBox
)r r
�vbox�AttributeErrorZ
getVirtualBox)r r r r �
vb_get_box� s �
�r c s"