File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/qemu_img.cpython-310.pyc
o
�N�g � @ s0 d Z ddlZddlZdd� Zdd� Zdd� ZdS ) z
Qemu-img Command Wrapper
========================
The qemu img command is wrapped for specific functions
:depends: qemu-img
� Nc C s t jj�d�r dS dS )z,
Only load if qemu-img is installed
�qemu-imgZqemu_img)FzWThe qemu_img execution module cannot be loaded: the qemu-img binary is not in the path.)�salt�utils�path�which� r r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/qemu_img.py�__virtual__ s r c C sT t j�| �sdS t j�t j�| ��sdS td d|� d| � d|� d�dd�s(| S dS )a?
Create a blank virtual machine image file of the specified size in
megabytes. The image can be created in any format supported by qemu
CLI Example:
.. code-block:: bash
salt '*' qemu_img.make_image /tmp/image.qcow 2048 qcow2
salt '*' qemu_img.make_image /tmp/image.raw 10240 raw
� zcmd.retcodezqemu-img create -f � �MF�Zpython_shell)�osr �isabs�isdir�dirname�__salt__)�location�size�fmtr r r �
make_image s �r c C s8 ddd|| |f}t d |dd�}|d dkrd S |d
S )z�
Convert an existing disk image to another format using qemu-img
CLI Example:
.. code-block:: bash
salt '*' qemu_img.convert /path/to/original.img /path/to/new.img qcow2
r �convertz-Ozcmd.run_allFr
�retcoder T�stderr)r )�orig�destr �cmd�retr r r r 4 s
r )�__doc__r Zsalt.utils.pathr r r r r r r r �<module> s