%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/virt.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZyddlZeZ	Wne
k
rieZ	nXddlZ
ddlZ
ddlZ
ddlZ
ddlmZddlmZdZd�Zdd	�Zdddd
�Zdddd�Zdddd�Zdddddddddeeddedddddd
�Zddddd�Zdddd�Zd�Zdd�Z ded�Z!ddedddd�Z"ddddeedddd�	Z#dS(u�
Manage virt
===========

For the key certificate this state uses the external pillar in the master to call
for the generation and signing of certificates for systems running libvirt:

.. code-block:: yaml

    libvirt_keys:
      virt.keys
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionError(tsixuvirtcC@sdtkrtStS(u9
    Only if virt module is available.

    :return:
    uvirt.node_info(t__salt__t__virtualname__tFalse(((s4/usr/lib/python2.7/site-packages/salt/states/virt.pyt__virtual__'su/etc/pkic
K@s�i|d6id6td6dd6}i}x0tj|�D]\}}||dj|�<q8Wtdidd	6|�}itjj|d	d
d�d6tjj|d	d
�d6tjj|d	d
d�d6tjj|d	d�d6tjj|dd�d6}x�|D]�}dj|�}	|	|kr,qntjjtjj	||��sntj
tjj	||��ntjj||�r�tj
jj||d��=}
tj
jj|
j��||	kr�d|d|<nWdQXqd|d|<qW|dsd|d<n�tdr6d|d<d|d<i|d<nmx`|dD]T}tj
jj||d��0}
|
jtj
jj|dj|���WdQXqAWd|d<|S( u�
    Manage libvirt keys.

    name
        The name variable used to track the execution

    basepath
        Defaults to ``/etc/pki``, this is the root location used for libvirt
        keys on the hypervisor

    The following parameters are optional:

        country
            The country that the certificate should use.  Defaults to US.

        .. versionadded:: 2018.3.0

        state
            The state that the certificate should use.  Defaults to Utah.

        .. versionadded:: 2018.3.0

        locality
            The locality that the certificate should use.
            Defaults to Salt Lake City.

        .. versionadded:: 2018.3.0

        organization
            The organization that the certificate should use.
            Defaults to Salted.

        .. versionadded:: 2018.3.0

        expiration_days
            The number of days that the certificate should be valid for.
            Defaults to 365 days (1 year)

        .. versionadded:: 2018.3.0

    unameuchangesuresultuucommentuext_pillar_virt.{0}u
pillar.extu_ulibvirtuprivateu
serverkey.pemu	serverkeyuservercert.pemu
servercertu
clientkey.pemu	clientkeyuclientcert.pemu
clientcertuCAu
cacert.pemucacertulibvirt.{0}.pemuruupdateNunewuAll keys are correctutestu"Libvirt keys are set to be updateduw+uUpdated libvirt certs and keys(tTrueRt	iteritemstformatRtostpathtjointexiststdirnametmakedirstisfiletsalttutilstfilestfopentstringutilst
to_unicodetreadt__opts__tNonetwritetto_str(tnametbasepathtkwargstrett
pillar_kwargstkeytvaluetpillartpathstp_keytfp_((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytkeys3sN*"




" %





!
c
K@sZi|d6id6td6dd6}tjtd�|�}	t�}
t�}x�|	D]�}yitdj|�|d|d	|d
||�}
t|
t�r�|
d}
n|
ji|d6|
|6�WqTt	j
k
r�}|ji|d6tj|�d6�qTXqTW|
s;t
|d<d
|d<|rVi|d6|d<qVni|
|6|d<||d<|S(u�
    Helper to call the virt functions. Wildcards supported.

    :param domain:
    :param function:
    :param section:
    :param comment:
    :return:
    unameuchangesuresultuucommentuvirt.list_domainsuvirt.{0}t
connectiontusernametpasswordudomainuissueuNo changes had happeneduignored(R	tfnmatchtfilterRtlistRt
isinstancetdicttappendtlibvirttlibvirtErrorRt	text_typeR(tdomaintfunctiontsectiontcommentR*R+R,R R!ttargeted_domainstchanged_domainstignored_domainsttargeted_domaintresponseterr((s4/usr/lib/python2.7/site-packages/salt/states/virt.pyt
_virt_call�s0"		
	
,


cC@s%t|dddd|d|d|�S(u�
    Stops a VM by shutting it down nicely.

    .. versionadded:: 2016.3.0

    :param connection: libvirt connection URI, overriding defaults

        .. versionadded:: 2019.2.0
    :param username: username to connect with, overriding defaults

        .. versionadded:: 2019.2.0
    :param password: password to connect with, overriding defaults

        .. versionadded:: 2019.2.0

    .. code-block:: yaml

        domain_name:
          virt.stopped
    ushutdownustoppeduMachine has been shut downR*R+R,(R@(RR*R+R,((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytstopped�scC@s%t|dddd|d|d|�S(u�
    Stops a VM by power off.

    .. versionadded:: 2016.3.0

    :param connection: libvirt connection URI, overriding defaults

        .. versionadded:: 2019.2.0
    :param username: username to connect with, overriding defaults

        .. versionadded:: 2019.2.0
    :param password: password to connect with, overriding defaults

        .. versionadded:: 2019.2.0

    .. code-block:: yaml

        domain_name:
          virt.stopped
    ustopu	unpowereduMachine has been powered offR*R+R,(R@(RR*R+R,((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytpowered_off�sc&C@s�i|d6id6td6dj|�d6}y}y�td|�td|�dkrd}|r�td	|d
|d|d|d
|d|d|d|	dtd|d|d|�}|dr�d}q�ntd|�dj|�|d|<dj||�|d<n�|r�td	|d
|d|d|d
|d|d|d|	d|d|d|�
}||d|<|jdd-�r�dj|�|d<q�|ds�dj|�|d<q�dj|�|d<ndj|�|d<Wn�tk
r�|rtjj	j
dd�ntd |d
|d|d!|d"|d#|d$|d%|d
|d&|d|d|	d'|
d(|d)|d*|
d|d|d|�d+|d|<d,j|�|d<nXWn3tjk
r�}t
j|�|d<t|d<nX|S(.u�
    Starts an existing guest, or defines and starts a new VM with specified arguments.

    .. versionadded:: 2016.3.0

    :param name: name of the virtual machine to run
    :param cpu: number of CPUs for the virtual machine to create
    :param mem: amount of memory in MiB for the new virtual machine
    :param image: disk image to use for the first disk of the new VM

        .. deprecated:: 2019.2.0
    :param vm_type: force virtual machine type for the new VM. The default value is taken from
        the host capabilities. This could be useful for example to use ``'qemu'`` type instead
        of the ``'kvm'`` one.

        .. versionadded:: 2019.2.0
    :param disk_profile:
        Name of the disk profile to use for the new virtual machine

        .. versionadded:: 2019.2.0
    :param disks:
        List of disk to create for the new virtual machine.
        See :ref:`init-disk-def` for more details on the items on this list.

        .. versionadded:: 2019.2.0
    :param nic_profile:
        Name of the network interfaces profile to use for the new virtual machine

        .. versionadded:: 2019.2.0
    :param interfaces:
        List of network interfaces to create for the new virtual machine.
        See :ref:`init-nic-def` for more details on the items on this list.

        .. versionadded:: 2019.2.0
    :param graphics:
        Graphics device to create for the new virtual machine.
        See :ref:`init-graphics-def` for more details on this dictionary

        .. versionadded:: 2019.2.0
    :param saltenv:
        Fileserver environment (Default: ``'base'``).
        See :mod:`cp module for more details <salt.modules.cp>`

        .. versionadded:: 2019.2.0
    :param seed: ``True`` to seed the disk image. Only used when the ``image`` parameter is provided.
                 (Default: ``True``)

        .. versionadded:: 2019.2.0
    :param install: install salt minion if absent (Default: ``True``)

        .. versionadded:: 2019.2.0
    :param pub_key: public key to seed with (Default: ``None``)

        .. versionadded:: 2019.2.0
    :param priv_key: public key to seed with (Default: ``None``)

        .. versionadded:: 2019.2.0
    :param seed_cmd: Salt command to execute to seed the image. (Default: ``'seed.apply'``)

        .. versionadded:: 2019.2.0
    :param update: set to ``True`` to update a defined module. (Default: ``False``)

        .. versionadded:: 2019.2.0
    :param connection: libvirt connection URI, overriding defaults

        .. versionadded:: 2019.2.0
    :param username: username to connect with, overriding defaults

        .. versionadded:: 2019.2.0
    :param password: password to connect with, overriding defaults

        .. versionadded:: 2019.2.0
    :param os_type:
        type of virtualization as found in the ``//os/type`` element of the libvirt definition.
        The default value is taken from the host capabilities, with a preference for ``hvm``.
        Only used when creating a new virtual machine.

        .. versionadded:: Neon
    :param arch:
        architecture of the virtual machine. The default value is taken from the host capabilities,
        but ``x86_64`` is prefed over ``i686``. Only used when creating a new virtual machine.

        .. versionadded:: Neon

    .. rubric:: Example States

    Make sure an already-defined virtual machine called ``domain_name`` is running:

    .. code-block:: yaml

        domain_name:
          virt.running

    Do the same, but define the virtual machine if needed:

    .. code-block:: yaml

        domain_name:
          virt.running:
            - cpu: 2
            - mem: 2048
            - disk_profile: prod
            - disks:
              - name: system
                size: 8192
                overlay_image: True
                pool: default
                image: /path/to/image.qcow2
              - name: data
                size: 16834
            - nic_profile: prod
            - interfaces:
              - name: eth0
                mac: 01:23:45:67:89:AB
              - name: eth1
                type: network
                source: admin
            - graphics:
              - type: spice
                listen:
                  - type: address
                    address: 192.168.0.125

    unameuchangesuresultu{0} is runningucommentu
virt.vm_stateurunningustarteduvirt.updatetcputmemtdisk_profiletdiskstnic_profilet
interfacestgraphicstliveR*R+R,u
definitionuupdated and startedu
virt.startu
Domain {0}uDomain {0} {1}uerrorsu2Domain {0} updated, but some live update(s) failedu Domain {0} exists and is runningu6Domain {0} updated, restart to fully apply the changesuSodiumu�'image' parameter has been deprecated. Rather use the 'disks' parameter to override or define the image. 'image' will be removed in {version}.u	virt.inittos_typetarchtimaget
hypervisortdisktnictseedtinstalltpub_keytpriv_keyuDomain defined and starteduDomain {0} defined and startedN(R	RRRtgetRRRRtversionst
warn_untilR3R4RR5(RRCRDRMtvm_typeRERFRGRHRIRQRRRSRTtupdateR*R+R,RKRLR!t
action_msgtstatusR?((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytrunning�s��

	

	



c
C@s+t|dddd|d|d|d|�S(uR
    Takes a snapshot of a particular VM or by a UNIX-style wildcard.

    .. versionadded:: 2016.3.0

    :param connection: libvirt connection URI, overriding defaults

        .. versionadded:: 2019.2.0
    :param username: username to connect with, overriding defaults

        .. versionadded:: 2019.2.0
    :param password: password to connect with, overriding defaults

        .. versionadded:: 2019.2.0

    .. code-block:: yaml

        domain_name:
          virt.snapshot:
            - suffix: periodic

        domain*:
          virt.snapshot:
            - suffix: periodic
    usnapshotusaveduSnapshot has been takentsuffixR*R+R,(R@(RR]R*R+R,((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytsnapshot�scC@s%t|dddd|d|d|�S(u}
    Reboots VMs

    .. versionadded:: 2016.3.0

    :param name:

    :param connection: libvirt connection URI, overriding defaults

        .. versionadded:: 2019.2.0
    :param username: username to connect with, overriding defaults

        .. versionadded:: 2019.2.0
    :param password: password to connect with, overriding defaults

        .. versionadded:: 2019.2.0
    urebooturebooteduMachine has been rebootedR*R+R,(R@(RR*R+R,((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytrebooted�scC@st|ddd�S(u�
    .. deprecated:: 2016.3.0
       Use :py:func:`~salt.modules.virt.powered_off` instead.

    Stops a VM by power off.

    .. versionadded:: 2016.3.0

    .. code-block:: yaml

        domain_name:
          virt.stopped
    ustopu	unpowereduMachine has been powered off(R@(R((s4/usr/lib/python2.7/site-packages/salt/states/virt.pyt	unpoweredscC@st|dddd|�S(uo
    .. deprecated:: 2016.3.0
       Use :py:func:`~salt.modules.virt.snapshot` instead.

    Takes a snapshot of a particular VM or by a UNIX-style wildcard.

    .. versionadded:: 2016.3.0

    .. code-block:: yaml

        domain_name:
          virt.saved:
            - suffix: periodic

        domain*:
          virt.saved:
            - suffix: periodic
    usnapshotusaveduSnapshots has been takenR](R@(RR]((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytsaved sc	C@sVi|d6id6td6dd6}y�tjtd�|�}|sZdj|�|d<n�t�}t|�dkr�it�d	6|d<nx�|D]�}i}yCtd
|d|d|�}i|d
6|d	d6|dd6}WnLtk
r0}t|�dkr1|ji|d
6t	j
|�d6�q1nXt|�dkrd|ro|dd	j|�qoq�||d<Pq�Wt|�t|�k|d<|dr�djt|�dkr�dp�d�|d<n|r�||dd<n|dd	s|djd	�nWnNtj
k
r,}t	j
|�|d<n&tk
rQ}t	j
|�|d<nX|S(uD
    .. deprecated:: 2016.3.0

    Reverts to the particular snapshot.

    .. versionadded:: 2016.3.0

    .. code-block:: yaml

        domain_name:
          virt.reverted:
            - cleanup: True

        domain_name_1:
          virt.reverted:
            - snapshot: snapshot_name
            - cleanup: False
    unameuchangesuresultuucommentuvirt.list_domainsu#No domains found for criteria "{0}"iureverteduvirt.revert_snapshotR^tcleanupudomainucurrentudeleteduissueuDomain{0} has been revertedusuignored(RR-R.RRR/tlenRR2RR5tpopR3R4(	RR^RbR!tdomainsR<R6tresultR?((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytreverted7sB"	
'+

.c	C@sEi|d6id6td6dd6}	y�td|d|d|d	|�}
|
r�|
d
rmdj|�|	d<q
td|d|d|d	|�d
|	d|<dj|�|	d<n\td||||d|d|dtd|d|d	|�d|	d|<dj|�|	d<Wn0tjk
r@}t|	d<|j�|	d<nX|	S(u�
    Defines and starts a new network with specified arguments.

    :param connection: libvirt connection URI, overriding defaults

        .. versionadded:: 2019.2.0
    :param username: username to connect with, overriding defaults

        .. versionadded:: 2019.2.0
    :param password: password to connect with, overriding defaults

        .. versionadded:: 2019.2.0

    .. code-block:: yaml

        domain_name:
          virt.network_define

    .. code-block:: yaml

        network_name:
          virt.network_define:
            - bridge: main
            - forward: bridge
            - vport: openvswitch
            - tag: 180
            - autostart: True

    unameuchangesuresultuucommentuvirt.network_infoR*R+R,uactiveu!Network {0} exists and is runninguvirt.network_startuNetwork starteduNetwork {0} starteduvirt.network_definettagt	autostarttstartuNetwork defined and starteduNetwork {0} defined and started(R	RRR3R4Rtget_error_message(RtbridgetforwardtvportRhRiR*R+R,R!tinfoR?((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytnetwork_runningrs8&

"
 

c

'C@sQi|d6id6td6dd6}
y�td|d|d|d	|	�}|r�|d
dkrsdj|�|
d<qtd
|d|d|d	|	�d|
d|<dj|�|
d<nbtd|d|d|d|d|p�ijdd*�d|p�ijdd*�d|pijdd*�d|p'ijdd*�d|p?ijdd*�d|pWijdd*�d|poijd d*�d!|d"td|d|d	|	�|r�td#|d$|r�d%nd&d|d|d	|	�ntd'|d|d|d	|	�d(|
d|<d)j|�|
d<Wn0tjk
rL}|j�|
d<t|
d<nX|
S(+u
    Defines and starts a new pool with specified arguments.

    .. versionadded:: 2019.2.0

    :param ptype: libvirt pool type
    :param target: full path to the target device or folder. (Default: ``None``)
    :param permissions:
        target permissions. See :ref:`pool-define-permissions` for more details on this structure.
    :param source:
        dictionary containing keys matching the ``source_*`` parameters in function
        :func:`salt.modules.virt.pool_define`.
    :param transient:
        when set to ``True``, the pool will be automatically undefined after being stopped. (Default: ``False``)
    :param autostart:
        Whether to start the pool when booting the host. (Default: ``True``)
    :param start:
        When ``True``, define and start the pool, otherwise the pool will be left stopped.
    :param connection: libvirt connection URI, overriding defaults
    :param username: username to connect with, overriding defaults
    :param password: password to connect with, overriding defaults

    .. code-block:: yaml

        pool_name:
          virt.pool_define

    .. code-block:: yaml

        pool_name:
          virt.pool_define:
            - ptype: netfs
            - target: /mnt/cifs
            - permissions:
                - mode: 0770
                - owner: 1000
                - group: 100
            - source:
                - dir: samba_share
                - hosts:
                   one.example.com
                   two.example.com
                - format: cifs
            - autostart: True

    unameuchangesuresultuucommentuvirt.pool_infoR*R+R,ustateurunninguPool {0} exists and is runninguvirt.pool_startuPool starteduPool {0} starteduvirt.pool_definetptypettargettpermissionstsource_devicesudevicest
source_dirudirtsource_adapteruadaptertsource_hostsuhoststsource_authuauthtsource_namet
source_formatuformatt	transientRjuvirt.pool_set_autostarttstateuonuoffuvirt.pool_builduPool defined and starteduPool {0} defined and startedN(	R	RRRURRR3R4Rk(
RRqRrRstsourceR{RiR*R+R,R!RoR?((s4/usr/lib/python2.7/site-packages/salt/states/virt.pytpool_running�sX8

" 



($t__doc__t
__future__RRRR-RR3R	tHAS_LIBVIRTtImportErrorRtsalt.utils.argsRtsalt.utils.filestsalt.utils.stringutilstsalt.utils.versionstsalt.exceptionsRtsalt.extRRRR)RR@RARBR\R^R_R`RaRgRpR~(((s4/usr/lib/python2.7/site-packages/salt/states/virt.pyt<module>
sv


	b&� 	>B

Zerion Mini Shell 1.0