%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/lxd_container.pyo

�
���^c
@@sLdZddlmZmZmZddlmZddlmZddlj	j
Z
ddlmZdZ
dZd	Zd
ZdZd�Zeeeeed
eeeeeed�Zeeeeed�Zeeeeed�Zeeeeed�Zeeeeed�Zeeeed�Zd�Zd�Zd�ZdS(uw
Manage LXD containers.

.. versionadded:: 2019.2.0

.. note:

    - `pylxd`_ version 2 is required to let this work,
      currently only available via pip.

        To install on Ubuntu:

        $ apt-get install libssl-dev python-pip
        $ pip install -U pylxd

    - you need lxd installed on the minion
      for the init() and version() methods.

    - for the config_get() and config_get() methods
      you need to have lxd-client installed.

.. _: https://github.com/lxc/pylxd/blob/master/doc/source/installation.rst

:maintainer: René Jochum <rene@jochums.at>
:maturity: new
:depends: python-pylxd
:platform: Linux
i(tabsolute_importtprint_functiontunicode_literals(tCommandExecutionError(tSaltInvocationErrorN(tmapurestructuredtext enu
lxd_containeriginifcC@sdtkrtStS(u>
    Only load if the lxd module is available in __salt__
    ulxd.version(t__salt__t__virtualname__tFalse(((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pyt__virtual__2sux86_64c

C@s�|d3krdg}n|d3kr-i}ni|d6|d6|d6|d6|d6|d6|d6|d	6|d
6|	d6|
d6|d
6|d6id6}
d3}y&td||	|
||dt�}Wn8tk
r�}t|
tj|��Stk
r�}nX|d3kr�tdr�dj	|�}i|d6|
d<|tkrb|d}dj	|�|
dd<ni|d6|
d<t
|
|�Sy3td|||||||t|	|
||�Wn&tk
r�}t|
tj|��SXdj	|�}i|d6|
d<|tkrvytd||	|
||�Wn&tk
rN}t|
tj|��SX|d}idj	|�d6|
d<nt|
|�Stt
tj|��}tt
tj|j��}t}g}x]|j|�D]L}tds|jdj	|��|j|�q�|jdj	|��q�Wx]|j|�D]L}tdsh|jdj	|��|j|�q2|jd j	|��q2W|r�t}||
dd<t|�|_ntd!||�\}}td"|||td�}|rt}|
dj|�n|jtk}tds[ytd#|�Wq[tk
rW}t|
tj|��SXn||kr|tkr�tdr�d$|d<t
|
d%j	|��S|jd&t�d'|d<q|tkrtdr�d(|d)<t
|
d*j	|��S|jd&t�d+|d)<qn|tks(|d3kr�|r�|r�|r�tdrdd,|d-<t
|
d.j	|��S|jd&t�d/j	|�|d-<t|
d/j	|��Sn|s�t|
d0�Stdr�t
|
d1j	|��St|
d2j	t|
dj����S(4u}	
    Create the named container if it does not exist

    name
        The name of the container to be created

    running : None
        * If ``True``, ensure that the container is running
        * If ``False``, ensure that the container is stopped
        * If ``None``, do nothing with regards to the running state of the
          container

    source : None
        Can be either a string containing an image alias:
             "xenial/amd64"
        or an dict with type "image" with alias:
            {"type": "image",
             "alias": "xenial/amd64"}
        or image with "fingerprint":
            {"type": "image",
             "fingerprint": "SHA-256"}
        or image with "properties":
            {"type": "image",
             "properties": {
                "os": "ubuntu",
                "release": "14.04",
                "architecture": "x86_64"
             }}
        or none:
            {"type": "none"}
        or copy:
            {"type": "copy",
             "source": "my-old-container"}


    profiles : ['default']
        List of profiles to apply on this container

    config :
        A config dict or None (None = unset).

        Can also be a list:
            [{'key': 'boot.autostart', 'value': 1},
             {'key': 'security.privileged', 'value': '1'}]

    devices :
        A device dict or None (None = unset).

    architecture : 'x86_64'
        Can be one of the following:
            * unknown
            * i686
            * x86_64
            * armv7l
            * aarch64
            * ppc
            * ppc64
            * ppc64le
            * s390x

    ephemeral : False
        Destroy this container after stop?

    restart_on_change : False
        Restart the container when we detect changes on the config or
        its devices?

    remote_addr :
        An URL to a remote Server, you also have to give cert and key if you
        provide remote_addr!

        Examples:
            https://myserver.lan:8443
            /var/lib/mysocket.sock

    cert :
        PEM Formatted SSL Zertifikate.

        Examples:
            ~/.config/lxc/client.crt

    key :
        PEM Formatted SSL Key.

        Examples:
            ~/.config/lxc/client.key

    verify_cert : True
        Wherever to verify the cert, this is by default True
        but in the most cases you want to set it off as LXD
        normaly uses self-signed certificates.
    udefaultunameurunninguprofilesusourceuconfigudevicesuarchitectureu	ephemeralurestart_on_changeuremote_addrucertukeyuverify_certuchangesulxd.container_gett_rawutestu Would create the container "{0}"ucreatedu and start it.uWould start the container "{0}"ustartedulxd.container_createuCreated the container "{0}"ulxd.container_startu and started it.uStarted the container "{0}"uRemoved profile "{0}"uWould remove profile "{0}"uAdded profile "{0}"uWould add profile "{0}"ulxd.normalize_input_valuesulxd.sync_config_devicesulxd.pylxd_save_objectuWould start the containeru.Container "{0}" would get changed and started.twaituStarted the containeruWould stopped the containerustoppedu.Container "{0}" would get changed and stopped.uStopped the containeruWould restart the containeru	restartedu!Would restart the container "{0}"u"Container "{0}" has been restartedu
No changesu"Container "{0}" would get changed.u{0} changesN(tNoneRtTrueRt_errortsixt	text_typeRt__opts__tformatt
_unchangedt_successtsetRtprofilesRt
differencetappendtdiscardtaddtlisttupdatetstatus_codetCONTAINER_STATUS_RUNNINGtstarttstoptrestarttlentkeys(tnametrunningtsourceRtconfigtdevicestarchitecturet	ephemeraltrestart_on_changetremote_addrtcerttkeytverify_certtrett	containertetmsgtnew_profilestold_profilestcontainer_changedtprofile_changestktchangest
is_running((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pytpresent9si	



















c	C@sHi|d6|d6|d6|d6|d6|d6id6}y&td|||||d	t�}WnKtk
r�}t|tj|��Stk
r�}t|d
j|��SXt	dr�idj|�d
6|d<t
||dd
�S|r|jtkr|j
dt�n|jdt�dj|�|dd<t||dd�S(u*
    Ensure a LXD container is not present, destroying it if present

    name :
        The name of the container to destroy

    stop :
        stop before destroying
        default: false

    remote_addr :
        An URL to a remote Server, you also have to give cert and key if you
        provide remote_addr!

        Examples:
            https://myserver.lan:8443
            /var/lib/mysocket.sock

    cert :
        PEM Formatted SSL Zertifikate.

        Examples:
            ~/.config/lxc/client.crt

    key :
        PEM Formatted SSL Key.

        Examples:
            ~/.config/lxc/client.key

    verify_cert : True
        Wherever to verify the cert, this is by default True
        but in the most cases you want to set it off as LXD
        normaly uses self-signed certificates.
    unameustopuremote_addrucertukeyuverify_certuchangesulxd.container_getR
uContainer "{0}" not found.utestu"Container "{0}" would get deleted.uremovedRu!Container "{0}" has been deleted.udeleted(RR
RRRRRRRRRRRR tdelete(	R$R R,R-R.R/R0R1R2((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pytabsentks0)

c
C@s�i|d6|d6|d6|d6|d6|d6id6}y&td|||||d	t�}WnKtk
r�}t|tj|��Stk
r�}t|d
j|��SX|jt	k}	|	rQ|s�t
|dj|��Stdrd
j|�|dd<t||dd�S|j
dt�dj|�|dd<t
||dd�Sntdr�dj|�|dd<t||dd�S|jdt�dj|�|dd<t
||dd�S(u:
    Ensure a LXD container is running and restart it if restart is True

    name :
        The name of the container to start/restart.

    restart :
        restart the container if it is already started.

    remote_addr :
        An URL to a remote Server, you also have to give cert and key if you
        provide remote_addr!

        Examples:
            https://myserver.lan:8443
            /var/lib/mysocket.sock

    cert :
        PEM Formatted SSL Zertifikate.

        Examples:
            ~/.config/lxc/client.crt

    key :
        PEM Formatted SSL Key.

        Examples:
            ~/.config/lxc/client.key

    verify_cert : True
        Wherever to verify the cert, this is by default True
        but in the most cases you want to set it off as LXD
        normaly uses self-signed certificates.
    unameurestarturemote_addrucertukeyuverify_certuchangesulxd.container_getR
uContainer "{0}" not foundu&The container "{0}" is already runningutestu!Would restart the container "{0}"u	restartedRuRestarted the container "{0}"uWould start the container "{0}"ustarteduStarted the container "{0}"(RR
RRRRRRRRRRRR!R(
R$R!R,R-R.R/R0R1R2R:((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pyR%�sB(


c
C@s�i|d6|d6|d6|d6|d6|d6id6}y&td|||||d	t�}WnKtk
r�}t|tj|��Stk
r�}t|d
j|��SX|jt	kr�t
|dj|��S|jtk}	|	r|rt|dj|��S|	rp|rptd
rFdj|�|dd<t
||dd�S|jdt�dj|�|dd<ntd
r�dj|�|dd<t
||dd�S|jdt�dj|�|dd<t
||dd�S(u
    Ensure a LXD container is frozen, start and freeze it if start is true

    name :
        The name of the container to freeze

    start :
        start and freeze it

    remote_addr :
        An URL to a remote Server, you also have to give cert and key if you
        provide remote_addr!

        Examples:
            https://myserver.lan:8443
            /var/lib/mysocket.sock

    cert :
        PEM Formatted SSL Zertifikate.

        Examples:
            ~/.config/lxc/client.crt

    key :
        PEM Formatted SSL Key.

        Examples:
            ~/.config/lxc/client.key

    verify_cert : True
        Wherever to verify the cert, this is by default True
        but in the most cases you want to set it off as LXD
        normaly uses self-signed certificates.
    unameustarturemote_addrucertukeyuverify_certuchangesulxd.container_getR
uContainer "{0}" not foundu Container "{0}" is alredy frozenuCContainer "{0}" is not running and start is False, cannot freeze itutestu3Would start the container "{0}" and freeze it afterustartedRuStart the container "{0}"u Would freeze the container "{0}"ufrozenuFroze the container "{0}"(RR
RRRRRRRtCONTAINER_STATUS_FROZENRRRRRtfreeze(
R$RR,R-R.R/R0R1R2R:((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pytfrozensH(




c	C@sHi|d6|d6|d6|d6|d6|d6id6}y&td|||||d	t�}WnKtk
r�}t|tj|��Stk
r�}t|d
j|��SX|jt	kr�t
|dj|��Stdrd
j|�|dd<t||dd�S|j
d|dt�dj|�|dd<t
||dd�S(u
    Ensure a LXD container is stopped, kill it if kill is true else stop it

    name :
        The name of the container to stop

    kill :
        kill if true

    remote_addr :
        An URL to a remote Server, you also have to give cert and key if you
        provide remote_addr!

        Examples:
            https://myserver.lan:8443
            /var/lib/mysocket.sock

    cert :
        PEM Formatted SSL Zertifikate.

        Examples:
            ~/.config/lxc/client.crt

    key :
        PEM Formatted SSL Key.

        Examples:
            ~/.config/lxc/client.key

    verify_cert : True
        Wherever to verify the cert, this is by default True
        but in the most cases you want to set it off as LXD
        normaly uses self-signed certificates.
    unameukilluremote_addrucertukeyuverify_certuchangesulxd.container_getR
uContainer "{0}" not foundu"Container "{0}" is already stoppedutestuWould stop the container "{0}"ustoppedtforceRuStopped the container "{0}"(RR
RRRRRRRtCONTAINER_STATUS_STOPPEDRRRR (	R$tkillR,R-R.R/R0R1R2((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pytstopped�s.(

c

C@s i
|d6|d6|d6|d6|d6|d6|d6|d6|d	6id
6}
d}y&td|||||dt�}Wn8tk
r�}t|
tj|��Stk
r�}nX|dk	r�t|
d
j	|��S|	dkr�|}	ny$td|||||	dt�WnKtk
r6}t|
tj|��Stk
r[}t|
dj	|��SXt
dr�dj	|||�|
d
d<t|
|
d
d�Sy-td||||||||||	�
Wn&tk
r�}t|
tj|��SXdj	|||�|
d
d<t|
|
d
d�S(u Ensure a container is migrated to another host

    If the container is running, it either must be shut down
    first (use stop_and_start=True) or criu must be installed
    on the source and destination machines.

    For this operation both certs need to be authenticated,
    use :mod:`lxd.authenticate <salt.states.lxd.authenticate`
    to authenticate your cert(s).

    name :
        The container to migrate

    remote_addr :
        An URL to the destination remote Server

        Examples:
            https://myserver.lan:8443
            /var/lib/mysocket.sock

    cert :
        PEM Formatted SSL Zertifikate.

        Examples:
            ~/.config/lxc/client.crt

    key :
        PEM Formatted SSL Key.

        Examples:
            ~/.config/lxc/client.key

    verify_cert : True
        Wherever to verify the cert, this is by default True
        but in the most cases you want to set it off as LXD
        normaly uses self-signed certificates.

    src_remote_addr :
        An URL to the source remote Server

        Examples:
            https://myserver.lan:8443
            /var/lib/mysocket.sock

    stop_and_start:
        Stop before migrating and start after

    src_cert :
        PEM Formatted SSL Zertifikate, if None we copy "cert"

        Examples:
            ~/.config/lxc/client.crt

    src_key :
        PEM Formatted SSL Key, if None we copy "key"

        Examples:
            ~/.config/lxc/client.key

    src_verify_cert :
        Wherever to verify the cert, if None we copy "verify_cert"
    unameuremote_addrucertukeyuverify_certusrc_remote_addru
src_and_startusrc_certusrc_keyuchangesulxd.container_getR
u)Container "{0}" exists on the destinationu Source Container "{0}" not foundutestu5Would migrate the container "{0}" from "{1}" to "{2}"umigratedulxd.container_migrateu0Migrated the container "{0}" from "{1}" to "{2}"N(RRR
RRRRRRRRR(
R$R,R-R.R/tsrc_remote_addrtstop_and_starttsrc_certtsrc_keytsrc_verify_certR0tdest_containerR2((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pytmigrated�s\H
	
cC@s1t|d<||d<d|kr-i|d<n|S(Nuresultucommentuchanges(R
(R0tsuccess_msg((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pyRWs



cC@s1d|d<||d<d|kr-i|d<n|S(Nuresultucommentuchanges(R(R0R3((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pyR_s



cC@s1t|d<||d<d|kr-i|d<n|S(Nuresultucommentuchanges(R(R0terr_msg((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pyRgs



(t__doc__t
__future__RRRtsalt.exceptionsRRtsalt.ext.sixtextRtsalt.ext.six.movesRt
__docformat__RRR>RBR	RRR
R;R=R%R@RDRKRRR(((s=/usr/lib/python2.7/site-packages/salt/states/lxd_container.pyt<module>sf	�(L\aM�		

Zerion Mini Shell 1.0