| Server IP : 198.38.94.13 / Your IP : 216.73.217.33 Web Server : Apache System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64 User : revivere ( 1140) PHP Version : 8.2.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/ |
Upload File : |
o
;j` � @ sj d Z ddlZddlZddlZddlZddlZddlZddlm Z e�
e�Zdd� Z
ddd�Zdd d
�ZdS )
zO
Interact with virtual machine images via libguestfs
:depends: - libguestfs
� N)�DEFAULT_HASH_TYPEc C s t jj�d�r dS dS )z?
Only load if libguestfs python bindings are installed
Z
guestmountZguestfs)FzMThe guestfs execution module cannot be loaded: guestmount binary not in path.)�salt�utils�path�which� r r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/guestfs.py�__virtual__ s r �rwc C s4 |du rt j�t�� d| �t j��dd��}t� d|� t j�
|�s3zt �|� W n ty2 Y nw t �
|�r�ttt�dt��}|t �d���� }t j�t�� d| �t j��dd�| �}t� d |� t j�
|�s�zt �|� W n ty� t�d
|� Y nw nnq4d| � d|� d
|� �}td |dd� |S )zz
Mount an image
CLI Example:
.. code-block:: bash
salt '*' guest.mount /srv/images/fedora.qcow
NZguest�/�.z
Using root %sT� hash_type� zEstablishing new root as %szPath already existing: %szguestmount -i -a z --� �cmd.runF)Zpython_shell)�osr �join�tempfileZ
gettempdir�lstrip�sep�replace�log�debug�isdir�makedirs�OSError�listdir�getattr�hashlibZ__opts__�getr �urandom� hexdigest�info�__salt__)�location�access�rootr
Zrand�cmdr r r �mount sB
��
����r( c C s� d| � �}t d |� d}|durF|dk rJtt d d|� ���� �dkrL|d }t�d� |durH|dk rNtt d d|� ���� �dks$dS dS dS dS dS dS )z�
Unmount an image
CLI Example:
.. code-block:: bash
salt '*' guestfs.umount /mountpoint disk=/srv/images/fedora.qcow
zguestunmount -q r r N� zlsof � )r# �len�
splitlines�time�sleep)�nameZdiskr'