%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddl	Z
ddlZ
ddlm
Z
ddlmZeje�Zejdjd��Zejdjd��Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Ze d�Z!d�Z"dde$ddd�Z%ddddddddde dd�Z&dddddde d�Z'e dd�Z(dS(uX
Support for VirtualBox using the VBoxManage command

.. versionadded:: 2016.3.0

If the ``vboxdrv`` kernel module is not loaded, this module can automatically
load it by configuring ``autoload_vboxdrv`` in ``/etc/salt/minion``:

.. code-block: yaml

    autoload_vboxdrv: True

The default for this setting is ``False``.

:depends: virtualbox
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionError(tsixu[^{0}]ua-zA-Z0-9._-cC@sSt�rItjdt�tkrEtdd�sEtdd�qEntStdfS(u9
    Only load the module if VBoxManage is installed
    uautoload_vboxdrvukmod.is_loadeduvboxdrvu	kmod.loaduMThe vboxmanaged execution module failed to load: VBoxManage is not installed.(tvboxcmdt__opts__tgettFalsetTruet__salt__(((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pyt__virtual__'s	cC@stjjjd�S(u�
    Return the location of the VBoxManage command

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.vboxcmd
    u
VBoxManage(tsalttutilstpathtwhich(((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pyR3s
cC@stdtd�S(u{
    List the available OS Types

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.list_ostypes
    uostypesuID(t
list_itemsR	(((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytlist_ostypes@s
cC@s�i}djt��}xatjjj|�j�D]D}|j�sLq4n|j�}|dj	dd�}t
||<q4W|S(u�
    Return a list of registered VMs, with minimal information

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.list_nodes_min
    u{0} list vmsiu"u(tformatRRtmodulestcmdmodtrunt
splitlineststriptsplittreplaceR	(trettcmdtlinetcompstname((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytlist_nodes_minMs
"cC@stdtd�S(u�
    Return a list of registered VMs, with detailed information

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.list_nodes_full
    uvmsuName(RR	(((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytlist_nodes_fullbs
cC@s�i}t�}x�|D]|}i||dd6||dd6||dd6dd6gd6gd	6||<d
j||d||d�||d
<qW|S(u}
    Return a list of registered VMs

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.list_nodes
    uUUIDuiduGuest OSuimageuNameunameustateuprivate_ipsu
public_ipsu{0} RAM, {1} CPUuMemory sizeuNumber of CPUsusizeN(R tNoneR(Rtnodestnode((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pyt
list_nodesos
	
cC@s:i}djt�|�}tjjj|�j�}|S(ui
    Start a VM

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.start my_vm
    u{0} startvm {1}(RRRRRRR(RRR((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytstart�s
cC@s4djt�|�}tjjj|�j�}|S(ug
    Stop a VM

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.stop my_vm
    u{0} controlvm {1} poweroff(RRRRRRR(RRR((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytstop�s
cC@sptjj|�s*tdj|���ndjt�|�}tjjj	|�}|ddkrht
S|dS(ux
    Register a VM

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.register my_vm_filename
    u,The specified filename ({0}) does not exist.u{0} registervm {1}uretcodeiustderr(tosRtisfileRRRRRRtrun_allR	(tfilenameRR((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytregister�s
cC@s�t�}||kr-tdj|���ndjt�|�}|tkr[|d7}ntjjj|�}|ddkr�tS|dS(u|
    Unregister a VM

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.unregister my_vm_filename
    u)The specified VM ({0}) is not registered.u{0} unregistervm {1}u	 --deleteuretcodeiustderr(	RRRRR	RRRR)(RtdeleteR"RR((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pyt
unregister�s
	
cC@s
t|t�S(u|
    Unregister and destroy a VM

    CLI Example:

    .. code-block:: bash

        salt '*' vboxmanage.destroy my_vm
    (R-R	(R((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytdestroy�s
cK@s�t�}||kr-tdj|���nd}|rmtj|�rWtd��n|dj|�7}n|r�t|tj�r�|g}nt|t�r�|djdj	|��7}q�td��nt
�}	||	kr�tdj|���n|d	|7}|tkr"|d
7}n|rhtj
j|�sRtdj|���n|dj|�7}n|r�tj|�r�td
��n|dj|�7}ndjt�|�}
tjjj|
�}|ddkr�tS|dS(uy
    Create a new VM

    CLI Example:

    .. code-block:: bash

        salt 'hypervisor' vboxmanage.create <name>
    u-The specified VM ({0}) is already registered.uu'New VM name contains invalid charactersu --name {0}u
 --groups {0}u,u3groups must be either a string or a list of stringsu-The specified OS type ({0}) is not available.u
 --ostype u --registerubasefolder {0} was not foundu --basefolder {0}u$New UUID contains invalid charactersu --uuid {0}u{0} create {1}uretcodeiustderr(RRRtNAME_REtsearcht
isinstanceRtstring_typestlisttjoinRR	R'RtexistsRRRRR)(RtgroupstostypeR+t
basefoldertnew_uuidtkwargsR"tparamstostypesRR((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytcreate�sH		
umachinec
K@s]|r|s|r)|r)td��nd}t�}
tdtd�j�}|r�||
krztdj|���n|d|7}n;|r�||kr�tdj|���n|d|7}n|r�|r�td��n|rtj|�rtd��n|d	j|�7}n:|rUtj|�r?td��n|d	j|�7}nd$}|r�||kr�td
jdj	|����n|d|7}d%}|r�||kr�tdjdj	|����n|d|7}|rtj|�rtd��n|dj|�7}n|
r~t
|
tj�rA|
g}
nt
|
t
�ro|djdj	|
��7}q~td��n|r�tjj|�s�tdj|���n|dj|�7}n|r�tj|�r�td��n|dj|�7}n|	tkr|d7}nd jt�|�}tjjj|�}|d!d"krUtS|d#S(&u�
    Clone a new VM from an existing VM

    CLI Example:

    .. code-block:: bash

        salt 'hypervisor' vboxmanage.clonevm <name> <new_name>
    u8Either a name or a uuid must be specified, but not both.uuvmsuUUIDu)The specified VM ({0}) is not registered.u uHEither a snapshot_name or a snapshot_uuid may be specified, but not bothu)Snapshot name contains invalid charactersu --snapshot {0}umachineumachineandchildrenuallu,Mode must be one of: {0} (default "machine")u, u --mode ulinkukeepallmacsukeepnatmacsu
keepdisknamesu)If specified, options must be one of: {0}u --options u$New name contains invalid charactersu --name {0}u
 --groups {0}u,u3groups must be either a string or a list of stringsubasefolder {0} was not foundu --basefolder {0}u$New UUID contains invalid charactersu --uuid {0}u --registeru{0} clonevm {1}uretcodeiustderr(umachineumachineandchildrenuall(ulinkukeepallmacsukeepnatmacsu
keepdisknames(RRRR	tkeysRR/R0tUUID_RER4R1RR2R3R'RR5RRRRR)(Rtuuidtnew_namet
snapshot_uuidt
snapshot_nametmodetoptionsR8R9R+R6R:R;tnodes_namestnodes_uuidstvalid_modest
valid_optionsRR((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytclonevm)s~	
cK@s�d}	d#}
||
kr%|	|7}	ntdjdj|
����|rO|s]|rl|rltd��n|r�|dkr�d}n*|dkr�d	}n|dkr�d
}nt|�}||kr�tdj|���n|	d|7}	nA|r3tjj|�s"td
j|���n|	d|7}	n|r?|sM|r\|r\td��n|rs|	d|7}	nm|r�y;tjj	j
|d�j�tj|�|	d|7}	Wq�t
k
r�tdj|���q�Xn|r*d$}
||
krtdjdj|
����q*|	d|7}	nd%}|r�||kr�tjj|�sutdjdj|����q�|	d|7}	n|r�|	d7}	ndjt�|	�}tjjj|�}|d d!kr�tS|d"S(&u�
    Clone a new VM from an existing VM

    CLI Example:

    .. code-block:: bash

        salt 'hypervisor' vboxmanage.clonemedium <name> <new_name>
    uudiskudvdufloppyuMedium must be one of: {0}.u, u5Either uuid_in or file_in must be used, but not both.uhddsudvdsufloppiesuUUID {0} was not foundu uFile {0} was not foundu7Either uuid_out or file_out must be used, but not both.uwu{0} is not a valid filenameuVDIuVMDKuVHDuRAWu)If specified, mformat must be one of: {0}u
 --format uStandarduFixeduSplit2GuStreamuESXu)If specified, variant must be one of: {0}u --variant u --existingu{0} clonemedium {1}uretcodeiustderr(udiskudvdufloppy(uVDIuVMDKuVHDuRAW(uStandarduFixeduSplit2GuStreamuESX(RRR4RR'RR5RR
tfilestfopentclosetunlinktOSErrorRRRR)R	(tmediumtuuid_intfile_intuuid_outtfile_outtmformattvarianttexistingR:R;t
valid_mediumstitemtitemst
valid_mformatt
valid_variantRR((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pytclonemedium�sn
			


uUUIDcC@s:d }||kr3tdjdj|����nd}|tkrNd}ni}d!}i}djt�||�}x�tjjj	|�j
�D]�}	|	j�s�q�n|	jd�}
t
|
�dkr�q�n|d!k	r�|||<ndj|
d�j�}|
d|kr$|}i}n|||
d<q�W|S("u�
    Return a list of a specific type of item. The following items are available:

        vms
        runningvms
        ostypes
        hostdvds
        hostfloppies
        intnets
        bridgedifs
        hostonlyifs
        natnets
        dhcpservers
        hostinfo
        hostcpuids
        hddbackends
        hdds
        dvds
        floppies
        usbhost
        usbfilters
        systemproperties
        extpacks
        groups
        webcams
        screenshotformats

    CLI Example:

    .. code-block:: bash

        salt 'hypervisor' vboxmanage.items <item>
        salt 'hypervisor' vboxmanage.items <item> details=True
        salt 'hypervisor' vboxmanage.items <item> details=True group_by=Name

    Some items do not display well, or at all, unless ``details`` is set to
    ``True``. By default, items are grouped by the ``UUID`` field, but not all
    items contain that field. In those cases, another field must be specified.
    uvmsu
runningvmsuostypesuhostdvdsuhostfloppiesuintnetsu
bridgedifsuhostonlyifsunatnetsudhcpserversuhostinfou
hostcpuidsuhddbackendsuhddsudvdsufloppiesuusbhostu
usbfiltersusystempropertiesuextpacksugroupsuwebcamsuscreenshotformatsuItem must be one of: {0}.u, uu -lu{0} list{1} {2}u:ii(uvmsu
runningvmsuostypesuhostdvdsuhostfloppiesuintnetsu
bridgedifsuhostonlyifsunatnetsudhcpserversuhostinfou
hostcpuidsuhddbackendsuhddsudvdsufloppiesuusbhostu
usbfiltersusystempropertiesuextpacksugroupsuwebcamsuscreenshotformatsN(RRR4R	R!RRRRRRRRtlen(RYtdetailstgroup_byttypestflagRttmp_idttmp_dictRRRtline_val((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pyR�s:)	"
	()t__doc__t
__future__RRRtretos.pathR'tloggingtsalt.utils.filesRtsalt.utils.pathtsalt.exceptionsRtsalt.extRt	getLoggert__name__tLOGtcompileRR?R/RRRRR R$R%R&R+RR-R.R!R	R=RJR]R(((s;/usr/lib/python2.7/site-packages/salt/modules/vboxmanage.pyt<module>s\		
	
		
					>bV

Zerion Mini Shell 1.0