%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/vmctl.pyc

�
���^c
@@s�dZddlmZddlZddlZddlZddlmZm	Z	ddl
mZeje
�Zd�Zd�Zd�Zd	�Zd
�Zeeed�Zdddddedddd�	Zddd
�Zddd�ZdS(s
Manage vms running on the OpenBSD VMM hypervisor using vmctl(8).

.. versionadded:: 2019.2.0

:codeauthor: ``Jasper Lievisse Adriaanse <jasper@openbsd.org>``

.. note::

    This module requires the `vmd` service to be running on the OpenBSD
    target machine.
i(tabsolute_importN(tCommandExecutionErrortSaltInvocationError(tzipcC@s3tddkr)tjjjd�r)tStdfS(s6
    Only works on OpenBSD with vmctl(8) present.
    tostOpenBSDtvmctlsmThe vmm execution module cannot be loaded: either the system is not OpenBSD or the vmctl binary was not found(t
__grains__tsalttutilstpathtwhichtTruetFalse(((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pyt__virtual__s%cC@s+td|�}|ikrdS|dSdS(s2
    Lookup the name associated with a VM id.
    tidtnameN(tstatustNone(Rtvm((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pyt_id_to_name'scC@sxt}dj||�}td|dddt�}|ddkrMt}n'tdd	i|d
gd6|d6��|S(
s�
    Create a VMM disk with the specified `name` and `size`.

    size:
        Size in megabytes, or use a specifier such as M, G, T.

    CLI Example:

    .. code-block:: bash

        salt '*' vmctl.create_disk /path/to/disk.img size=10G
    svmctl create {0} -s {1}scmd.run_alltoutput_loglevelttracetpython_shelltretcodeis'Problem encountered creating disk imagetinfotstderrterrorstchanges(R
tformatt__salt__RR(Rtsizetrettcmdtresult((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pytcreate_disk2s

		cC@sut}dj|�}td|dddt�}|ddkrJt}n'tdd	i|d
gd6|d6��|S(
s�
    Load additional configuration from the specified file.

    path
        Path to the configuration file.

    CLI Example:

    .. code-block:: bash

        salt '*' vmctl.load path=/etc/vm.switches.conf
    svmctl load {0}scmd.run_allRRRRis!Problem encountered running vmctlRRRR(R
RRRR(R
R R!R"((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pytloadQs

		cC@slt}d}td|dddt�}|ddkrAt}n'tdd	i|d
gd6|d6��|S(
s�
    Remove all stopped VMs and reload configuration from the default configuration file.

    CLI Example:

    .. code-block:: bash

        salt '*' vmctl.reload
    svmctl reloadscmd.run_allRRRRis!Problem encountered running vmctlRRRR(R
RRR(R R!R"((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pytreloadns

		cC@s�t}ddg}|r(|jd�n,|r>|jd�n|rT|jd�ntd|ddd	t�}|d
dkr�t}n'tdd
i|dgd6|d6��|S(s
    Reset the running state of VMM or a subsystem.

    all:
        Reset the running state.

    switches:
        Reset the configured switches.

    vms:
        Reset and terminate all VMs.


    CLI Example:

    .. code-block:: bash

        salt '*' vmctl.reset all=True
    Rtresettalltvmstswitchesscmd.run_allRRRRis!Problem encountered running vmctlRRRR(R
tappendRRR(R'R(R)R R!R"((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pyR&�s"
		c	
C@soitd6dd6}	ddg}
|p)|s;td��n/|rQ|
j|�n|
j|�t|�}|dkr�|
jdj|��n|r�|
jd|g�n|r�|
jd	j|��n|r�|
jd
j|��n|r�|
jd�n|r,|r,t|�dkr,td��n|rH|
jd
|g�n|rzt|�dkrz|
jd�|D��nt|
�dkr�t|�}|r�d|	d<|	Snt	d|
dddt�}|ddkrDt
|	d<tjd|d�}
|
r|
j
�d|	d<qktjd|d�}
|
rkt|	d<qkn'tddi|dgd6|	d6��|	S(si
    Starts a VM defined by the specified parameters.
    When both a name and id are provided, the id is ignored.

    name:
        Name of the defined VM.

    id:
        VM id.

    bootpath:
        Path to a kernel or BIOS image to load.

    disk:
        Path to a single disk to use.

    disks:
        List of multiple disks to use.

    local_iface:
        Whether to add a local network interface. See "LOCAL INTERFACES"
        in the vmctl(8) manual page for more information.

    memory:
        Memory size of the VM specified in megabytes.

    switch:
        Add a network interface that is attached to the specified
        virtual switch on the host.

    CLI Example:

    .. code-block:: bash

        salt '*' vmctl.start 2   # start VM with id 2
        salt '*' vmctl.start name=web1 bootpath='/bsd.rd' nics=2 memory=512M disk='/disk.img'
    RtconsoleRtstarts"Must provide either "name" or "id"is-i {0}s-bs-m {0}s-n {0}s-Ls%Must provide either "disks" or "disk"s-dcs@s|]}d|gVqdS(s-dN((t.0tx((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pys	<genexpr>�sis)VM already exists and cannot be redefinedtcommentscmd.run_allRRRRs.*successfully, tty (\/dev.*)Rs .*Operation already in progress$s!Problem encountered running vmctlRRN(R
RRR*RRtextendtlenRRRtretmatchtgroupsR(RRtbootpathtdisktdiskstlocal_ifacetmemorytnicstswitchR R!tvmstateR"tm((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pyR,�sX'


	
cC@s�i}ddg}td|dddt�}|ddkrhtd	d
i|dgd6|d
6��n|dj�dj�}tg|D]}|j�^q��}x�|dj�dD]�}|j�}ttt||���}	|	j	d�}
|	ddkrd|	d<n1|
r<|ddkr<|d|	d<n
d|	d<|rmt
|	d�|krmi|	|
6S|r�|
|kr�i|	|
6S|	||
<q�W|s�|r�iS|S(sp
    List VMs running on the host, or only the VM specified by ``id``.  When
    both a name and id are provided, the id is ignored.

    name:
        Name of the defined VM.

    id:
        VM id.

    CLI Example:

    .. code-block:: bash

        salt '*' vmctl.status           # to list all VMs
        salt '*' vmctl.status name=web1 # to get a single VM
    RRscmd.run_allRRRRis!Problem encountered running vmctlRRterrorRtstdoutiRtpidt-tstoppedtstatei����i����trunningR(RR
Rt
splitlinestsplittlisttlowertdictRtpoptint(RRR R!R"theaderR.tlinetdataRtvmname((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pyRs8
	!%	

cC@s�i}ddg}|p|s-td��n#|rC|j|�n
|j|�td|dddt�}|dd	kr�tjd
|d�r�t|d<q�t|d<n'td
di|dgd6|d6��|S(s
    Stop (terminate) the VM identified by the given id or name.
    When both a name and id are provided, the id is ignored.

    name:
        Name of the defined VM.

    id:
        VM id.

    CLI Example:

    .. code-block:: bash

        salt '*' vmctl.stop name=alpine
    Rtstops"Must provide either "name" or "id"scmd.run_allRRRRis&^vmctl: sent request to terminate vm.*RRs!Problem encountered running vmctlRR(RR*RR
R2R3RR(RRR R!R"((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pyRPis$

	

(t__doc__t
__future__RtloggingR2tsalt.utils.pathRtsalt.exceptionsRRtsalt.ext.six.movesRt	getLoggert__name__tlogRRR#R$R%R
R&RR,RRP(((s6/usr/lib/python2.7/site-packages/salt/modules/vmctl.pyt<module>
s"	
				,iK

Zerion Mini Shell 1.0