HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/guestfs.cpython-310.pyc
o

�N�g`	�@sjdZddlZddlZddlZddlZddlZddlZddlm	Z	e�
e�Zdd�Z
ddd�Zdd	d
�ZdS)
zO
Interact with virtual machine images via libguestfs

:depends:   - libguestfs
�N)�DEFAULT_HASH_TYPEcCstjj�d�r	dSdS)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�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/guestfs.py�__virtual__sr	�rwcCs4|durtj�t��d|�tj��dd��}t�	d|�tj�
|�s3zt�|�Wn	ty2Ynw	t�
|�r�ttt�dt��}|t�d����}tj�t��d|�tj��dd�|�}t�	d	|�tj�
|�s�zt�|�Wnty�t�d
|�Ynwnnq4d|�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)Zpython_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�cmdrrr�mountsB
��
����r(cCs�d|��}td|�d}|durF|dkrJttdd|������dkrL|d}t�d�|durH|dkrNttdd|������dks$dSdSdSdSdSdS)z�
    Unmount an image

    CLI Example:

    .. code-block:: bash

        salt '*' guestfs.umount /mountpoint disk=/srv/images/fedora.qcow
    zguestunmount -q rrN�zlsof �)r#�len�
splitlines�time�sleep)�nameZdiskr'Zloopsrrr�umountKs


�"��r0)r
N)N)�__doc__r�loggingrrr-Zsalt.utils.pathrZsalt.configr�	getLogger�__name__rr	r(r0rrrr�<module>s

,