File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/qemu_nbd.cpython-310.pyc
Back
o ;j� � @ sv d Z ddlZddlZddlZddlZddlZddlZddlZe� e �Zdd� Zdd� Z d dd�Zd d d �Zdd� ZdS )z� Qemu Command Wrapper The qemu system comes with powerful tools, such as qemu-img and qemu-nbd which are used here to build up kvm images. � Nc C s t jj�d�r dS dS )z: Only load if qemu-img and qemu-nbd are installed zqemu-nbdZqemu_nbd)FzWThe qemu_nbd execution module cannot be loaded: the qemu-nbd binary is not in the path.)�salt�utils�path�which� r r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/qemu_nbd.py�__virtual__ s r c C s� t j�| �st�d| � dS tjj�d�rd}nd}td d� t � d�D ]-}td |� d |� ��rR td d|� d | � �d d� td |� d |� ��sQ | S q3q%t�d| � dS )z� Activate nbd for an image file. CLI Example: .. code-block:: bash salt '*' qemu_nbd.connect /tmp/image.raw z*Could not connect image: %s does not exist� Zsfdiskz sfdisk -dzfdisk -l�cmd.runzmodprobe nbd max_part=63z /dev/nbd?zcmd.retcode� Tzqemu-nbd -c F�Zpython_shellzCould not connect image: %s) �osr �isfile�log�warningr r r �__salt__�glob)�imageZfdisk�nbdr r r �connect"