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

�
���^c@@s�dZddlmZmZmZddlZddlmZddlZddl	Zddl
mZddlm
Z
ddlmZddljjZddlmZdd	lmZy5ddlZeZddlZejejj�Wnek
reZnXddlZeje �Z!d
Z"dZ#i	dd
6dd6dd6dd6dd6dd6dd6dd6dd6Z$dZ%dZ&iZ'd �Z(ej)j*j+j,d�d!��Z-d"�Z.ej)j*j+j,d�d#ddddddd$��Z0ej)j*j+j,d�ej)j*j+j,d%�d&���Z1ej)j*j+j,d�ej)j*j+j,d%�d'���Z2ddded(�Z3d)�Z4ed*�Z5eddded+�Z6ddddeedddeed,�Z7ddddeed-�Z8ddded.�Z9ddded/�Z:dddded0�Z;ddded1�Z<d2eddded3�Z=ddded4�Z>ddded5�Z?ddded6�Z@edddeddddd7�	ZAddded8�ZBddded9�ZCddded:�ZDddded;�ZEd<ddded=�ZFddded>�ZGeedddd?ddded@�
ZHeddddddedA�ZIdddedB�ZJedddedC�ZKddddddedD�ZLdddeedE�ZMdddedF�ZNdddedG�ZOdddedH�ZPdddedI�ZQdddedJ�ZRd<dddedK�ZSdddedL�ZTedddedM�ZUdddeedN�ZVdddeedO�ZWdddedP�ZXdddedeeedQ�ZYdddedeeedR�ZZdddeded?edS�Z[edddedT�Z\dUdddedV�Z]dddedW�Z^dddedX�Z_ddddedY�Z`dddedZ�Zaddded[�Zbd\�Zced]�Zdd^�Zed_�Zfd`�Zgdddeda�Zhdb�Zier�ddljZekejdc�swddejjlfde��YZmemej_mnyddflnmoZoWn!ek
r�ddflpmoZonXdgeojqfdh��YZqeqeo_qndS(iuJ
Module for managing the LXD daemon and its containers.

.. versionadded:: 2019.2.0

`LXD(1)`__ is a container "hypervisor". This execution module provides
several functions to help manage it and its containers.

.. note:

    - `pylxd(2)`__ version >=2.2.5 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://linuxcontainers.org/lxd/
.. __: 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_literalsN(tdatetime(tLooseVersion(tCommandExecutionError(tSaltInvocationError(tmap(tzipurestructuredtext enu2.2.5u0uunknownu1ui686u2ux86_64u3uarmv7lu4uaarch64u5uppcu6uppc64u7uppc64leu8us390xigulxdcC@sHtr>tt��tt�kr:tdjt�t�fStStdfS(NufThe lxd execution module cannot be loaded: pylxd "{0}" is not supported, you need at least pylxd "{1}"uTThe lxd execution module cannot be loaded: the pylxd python module is not available.(t	HAS_PYLXDRt
pylxd_versiont_pylxd_minimal_versiontFalsetformatt__virtualname__(((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyt__virtual__Ys
cC@stdd�S(ut
    Returns the actual lxd version.

    CLI Example:

    .. code-block:: bash

        salt '*' lxd.version

    ucmd.runu
lxd --version(t__salt__(((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytversionrscC@stjS(u|
    Returns the actual pylxd version.

    CLI Example:

    .. code-block:: bash

        salt '*' lxd.pylxd_version

    (tpylxdt__version__(((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyR
�sudirc
C@sVdj|�}|dk	r1|dj|�}n|dk	rS|dj|�}n|dk	ru|dj|�}n|dk	r�|dj|�}n|dk	r�|dj|�}n|dk	r�|dj|�}nytd|�}Wn4tk
r%}	td	j|tj|	����nXd
|krRt||jd
�d��n|S(
u
    Calls lxd init --auto -- opts

    storage_backend :
        Storage backend to use (zfs or dir, default: dir)

    trust_password :
        Password required to add new clients

    network_address : None
        Address to bind LXD to (default: none)

    network_port : None
        Port to bind LXD to (Default: 8443)

    storage_create_device : None
        Setup device based storage using this DEVICE

    storage_create_loop : None
        Setup loop based storage with this SIZE in GB

    storage_pool : None
        Storage pool to use or create

    CLI Examples:

    To listen on all IPv4/IPv6 Addresses:

    .. code-block:: bash

        salt '*' lxd.init dir PaSsW0rD [::]

    To not listen on Network:

    .. code-block:: bash

        salt '*' lxd.init
    u'lxd init --auto --storage-backend="{0}"u --trust-password="{0}"u --network-address="{0}"u --network-port="{0}"u --storage-create-device="{0}"u --storage-create-loop="{0}"u --storage-pool="{0}"ucmd.runu%Failed to call: '{0}', error was: {1}uerror:iN(R
tNoneRt
ValueErrorRtsixt	text_typetindex(
tstorage_backendttrust_passwordtnetwork_addresstnetwork_porttstorage_create_devicetstorage_create_looptstorage_pooltcmdtoutputte((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytinit�s4+		
	
ulxccC@s^dj||�}td|�}d|krNt||jd�d��ndj|�fS(ug
    Set an LXD daemon config option

    CLI Examples:

    To listen on IPv4 and IPv6 port 8443,
    you can omit the :8443 its the default:

    .. code-block:: bash

        salt '*' lxd.config_set core.https_address [::]:8443

    To set the server trust password:

    .. code-block:: bash

        salt '*' lxd.config_set core.trust_password blah

    ulxc config set "{0}" "{1}"ucmd.runuerror:iu$Config value "{0}" successfully set.(R
RRR(tkeytvalueR R!((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyt
config_set�s	cC@sOdj|�}td|�}d|krKt||jd�d��n|S(u�
    Get an LXD daemon config option

    key :
        The key of the config value to retrieve

    CLI Examples:

    .. code-block:: bash

        salt '*' lxd.config_get core.https_address
    ulxc config get "{0}"ucmd.runuerror:i(R
RRR(R$R R!((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyt
config_get
s	c	C@sdjtj|�tj|�tj|�tj|�f�}|tkritjdj|��t|Sy;|dks�|dkr�tjd�tj	�}n|j
d�r�tj	|�}n�|dks�|dkr�td��ntj
j|�}tj
j|�}tj
j|�s6tdj|���ntj
j|�s`tdj|���ntjd	j||||��tj	d
|d||fd|�}Wn_tjjk
r�td
j|���n4tk
r}tdj|tj|����nX|t|<|S(uj
    Get an pyxld client, this is not ment to be runned over the CLI.

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.

    See the `requests-docs`_ for the SSL stuff.

    .. _requests-docs: http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification

    # noqa
    u|u3Returning the client "{0}" from our connection poolu/var/lib/lxd/unix.socketu*Trying to connect to the local unix socketu/u:You have to give a Cert and Key file for remote endpoints.uVYou have given an invalid cert path: "{0}", the file does not exists or is not a file.uUYou have given an invalid key path: "{0}", the file does not exists or is not a file.uNTrying to connecto to "{0}" with cert "{1}", key "{2}" and verify_cert "{3!s}"tendpointtcerttverifyuFailed to connect to '{0}'uRFailed to connect to "{0}", looks like the SSL verification failed, error was: {1}N(tjoinRRt_connection_pooltlogtdebugR
RRtClientt
startswithRtostpatht
expandusertisfilet
exceptionstClientConnectionFailedRt	TypeError(tremote_addrR)R$tverify_certtpool_keytclientR"((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytpylxd_client_get*sX$

	

cC@sCy|j�Wn.tjjk
r>}ttj|���nXtS(u� Saves an object (profile/image/container) and
        translate its execpetion on failure

    obj :
        The object to save

    This is an internal method, no CLI Example.
    (tsaveRR5tLXDAPIExceptionRRRtTrue(tobjR"((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytpylxd_save_object�s
	cC@skt||||�}|jr"tSy|j|�Wn.tjjk
rc}ttj	|���nX|jS(u
    Authenticate with a remote LXDaemon.

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

        Examples:
            https://myserver.lan:8443

    password :
        The password of the remote.

    cert :
        PEM Formatted SSL Certificate.

        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.

    CLI Example:

    .. code-block:: bash

        $ salt '*' lxd.authenticate https://srv01:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false

    See the `requests-docs`_ for the SSL stuff.

    .. _requests-docs: http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification

    # noqa
    (
R<ttrustedR?tauthenticateRR5R>RRR(R8tpasswordR)R$R9R;R"((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyRC�s+	cC@sQt||||�}|jj�}|rDg|D]}|j^q1Stt|�S(u,
    Lists containers

    list_names : False
        Only return a list of names when True

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.

    CLI Examples:

    Full dict with all available informations:

    .. code-block:: bash

        salt '*' lxd.container_list

    For a list of names:

    .. code-block:: bash

        salt '*' lxd.container_list true

    # See: https://github.com/lxc/pylxd/blob/master/doc/source/containers.rst#container-attributes

    # noqa
    (R<t
containerstalltnameRt_pylxd_model_to_dict(t
list_namesR8R)R$R9R;REtc((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_list�s
4c
C@s�|dkrdg}n|dkr-i}n|dkrBi}nt||	|
|�}
t|tttf�s~td��n|tkr�tdj||���nt|t	j
�r�idd6|d6}nt||�\}}yJ|
jj
i|d6t|d6|d	6|d
6|d6|d6d
|�}Wn.tjjk
r]}tt	j|���nX|sr|j�dS|r�x0t	j|�D]\}}t|||�q�Wn|r�|St|�S(u�
    Create a container

    name :
        The name of the container

    source :
        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?

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.

    _raw : False
        Return the raw pyxld object or a dict?

    CLI Examples:

    .. code-block:: bash

        salt '*' lxd.container_create test xenial/amd64

    # See: https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1
    udefaultu/'profiles' must be formatted as list/tuple/set.u8Unknown architecture '{0}' given for the container '{1}'uimageutypeualiasunameuarchitectureuprofilesusourceuconfigu	ephemeraltwaitu	operationN(RR<t
isinstancetlistttupletsetRt_architecturesR
Rtstring_typestnormalize_input_valuesREtcreateRR5R>RRtjsont	iteritemstcontainer_device_addRH(RGtsourcetprofilestconfigtdevicestarchitecturet	ephemeralRLR8R)R$R9t_rawR;t	containerR"tdntdargs((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_create sPa			

c
C@s�t||||�}|dkr=|jj�}|r�|Sn\g}y|jj|�g}Wn,tjjk
r�tdj	|���nX|r�|dSg}x3|D]+}	|j
t|	jt
|	�fg��q�W|S(u� Gets a container from the LXD

        name :
            The name of the container to get.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        _raw :
            Return the pylxd object, this is internal and by states in use.
    uContainer '{0}' not foundiN(R<RRERFtgetRR5R>RR
tappendtdictRGRH(
RGR8R)R$R9R^R;REtinfosR_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyt
container_get�s$#
	 cC@s2t|||||dt�}|jdt�tS(u�
    Delete a container

    name :
        Name of the container to delete

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^RL(RgR?tdelete(RGR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_delete�s!cC@sbt|||||dt�}|jtkrEtdj|���n|j|dt�t|�S(u
    Rename a container

    name :
        Name of the container to Rename

    newname :
        The new name of the contianer

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^u)Can't rename the running container '{0}'.RL(RgR?tstatus_codetCONTAINER_STATUS_RUNNINGRR
trenameRH(RGtnewnameR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_rename"s$cC@st||||�}|dkr3|jj�}nHy|jj|�g}Wn,tjjk
rztdj	|���nXg}x||D]t}i}	|j
�}	|jt|j
tgt|	�D]*}
|
jd�s�|
t|	|
�f^q��fg��q�W|S(u�
    Get container state

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    uContainer '{0}' not foundu_N(R<RRERFRcRR5R>RR
tstateRdReRGtdirR0tgetattr(RGR8R)R$R9R;REtstatesR_Rotk((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_stateSs&
	;cC@s8t|||||dt�}|jdt�t|�S(u�
    Start a container

    name :
        Name of the container to start

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^RL(RgR?tstartRH(RGR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_start�s!icC@s>t|||||dt�}|j||dt�t|�S(u�
    Stop a container

    name :
        Name of the container to stop

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^RL(RgR?tstopRH(RGttimeouttforceR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_stop�s!cC@s8t|||||dt�}|jdt�t|�S(u�
    Restart a container

    name :
        Name of the container to restart

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^RL(RgR?trestartRH(RGR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_restart�s!cC@s8t|||||dt�}|jdt�t|�S(u�
    Freeze a container

    name :
        Name of the container to freeze

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^RL(RgR?tfreezeRH(RGR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_freezes!cC@s8t|||||dt�}|jdt�t|�S(u�
    Unfreeze a container

    name :
        Name of the container to unfreeze

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^RL(RgR?tunfreezeRH(RGR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_unfreeze/s!c
C@s�|dkr|}n|dkr*|}n|	dkr?|}	nt|||||	dt�}
t||||�}xK|
jD]@}y|jj|�Wq|tjjk
r�t	d��q|Xq|W|
j
tk}
|r�|
r�|
jdt�ny/|
j
|dt�}|
j|_|j�Wn.tjjk
rM}ttj|���nX|
jdt�|r}|
r}|jdt�nt|�S(u5 Migrate a container.

        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.modules.lxd.authenticate`
        to authenticate your cert(s).

        name :
            Name of the container to migrate

        stop_and_start :
            Stop the container on the source and start it on dest

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Example:

        .. code-block:: bash

            # Authorize
            salt '*' lxd.authenticate https://srv01:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false
            salt '*' lxd.authenticate https://srv02:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false

            # Migrate phpmyadmin from srv01 to srv02
            salt '*' lxd.container_migrate phpmyadmin stop_and_start=true remote_addr=https://srv02:8443 cert=~/.config/lxc/client.crt key=~/.config/lxc/client.key verify_cert=False src_remote_addr=https://srv01:8443

    # noqa
    R^u8not all the profiles from the source exist on the targetRLN(RRgR?R<RYRcRR5R>RRjRkRwtmigrateR=RRRRhRuRH(RGtstop_and_startR8R)R$R9tsrc_remote_addrtsrc_certtsrc_keytsrc_verify_certR_tdest_clienttpnametwas_runningtdest_containerR"((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_migrateWs:@			cC@s.t|||||dt�}t|d|�S(u
    Get a container config value

    name :
        Name of the container

    config_key :
        The config key to retrieve

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^uconfig(RgR?t_get_property_dict_item(RGt
config_keyR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_config_get�s$cC@s1t|||||dt�}t|d||�S(u0
    Set a container config value

    name :
        Name of the container

    config_key :
        The config key to set

    config_value :
        The config value to set

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^uconfig(RgR?t_set_property_dict_item(RGR�tconfig_valueR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_config_set�s'cC@s.t|||||dt�}t|d|�S(u
    Delete a container config value

    name :
        Name of the container

    config_key :
        The config key to delete

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^uconfig(RgR?t_delete_property_dict_item(RGR�R8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_config_deletes$cC@s.t|||||dt�}t|d|�S(u�
    Get a container device

    name :
        Name of the container

    device_name :
        The device name to retrieve

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^udevices(RgR?R�(RGtdevice_nameR8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_device_getKs$udiskc	K@s;t|||||dt�}||d<t|d||�S(uV
    Add a container device

    name :
        Name of the container

    device_name :
        The device name to add

    device_type :
        Type of the device

    ** kwargs :
        Additional device args

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^utypeudevices(RgR?R�(	RGR�tdevice_typeR8R)R$R9tkwargsR_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyRWvs
,
cC@s.t|||||dt�}t|d|�S(u�
    Delete a container device

    name :
        Name of the container

    device_name :
        The device name to delete

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.
    R^udevices(RgR?R�(RGR�R8R)R$R9R_((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_device_delete�s$ubasec
C@s�tj|�}|jd�s0dj|�}nt||	|
||dt�}
tjj|�}tjj	|�s�|j
d�dkr�td|d|�}|s�tdj|���ntjj	|�s�td	��n|}q�n|j
tjj�}|stjj}ntjj|�s<td
j|���ntjj|�rd|rdtd��ny)t}|
jjtjj|d��WnVtjjk
r�n@tjjk
r�}tj|�j
d
�dkr�t}q�nXtjj|�r�|r�tjj|tjj|��}|s�t}y |
jjtjj|��Wn_tjjk
rjt}nCtjjk
r�}tj|�j
d�dkr�t}q��nX|r�td��q�q�n|dk	s�|dk	s�|dk	rLtj|�}|dkrt|j�}n|dkr1|j }n|dkrL|j!}qLnt"j#jj$|d��2}|
jj%||j&�d|d|d|�WdQXtStjj|�s�td��n|j'tj�r�t(tjj)|��}n�|r�t(|�}n�y/|
jjtjjtjj)|�d��Wnhtjjk
rGnRtjjk
r�}tj|�j
d
�dkr�t}t(|�}t}q�nX|s�td��ng}xUtj*|�D]D\}}}tjj|||j+tjj��}|j,|�q�W|
j-ddg|�|}|}|}xStj*|�D]B\}}}tjj|||j+tjj��}x|D]}tjj||�}tjj||�}|dk	s�|dk	s�|dk	r7tj|�}|dkrt|j�}n|dkr|j }n|dkr7|j!}q7nt"j#jj$|d��2}|
jj%||j&�d|d|d|�WdQXq�WqEWtS(u�
    Put a file into a container

    name :
        Name of the container

    src :
        The source file or directory

    dst :
        The destination file or directory

    recursive :
        Decent into src directory

    overwrite :
        Replace destination if it exists

    mode :
        Set file mode to octal number

    uid :
        Set file uid (owner)

    gid :
        Set file gid (group)

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.

    CLI Example:

    .. code-block:: bash

        salt '*' lxd.container_file_put <container name> /var/tmp/foo /var/tmp/

    u0u0{0}R^u://iu
cp.cache_filetsaltenvuFile '{0}' not founduFile path must be absolute.uNo such file or directory '{0}'uGCannot copy overwriting a directory without recursive flag set to true!u.uIs a directoryu	not foundu)Destination exists and overwrite is falseurbtmodetuidtgidNu$Source is neither file nor directoryumkdiru-p(.RRR0R
RgR?R1R2R3tisabstfindRRtrstriptseptexistsRtisdirRtfilesRcR+RR5tNotFoundR>R4tbasenameRtstattocttst_modetst_uidtst_gidtsalttutilstfopentputtreadtendswithtlentdirnametwalktlstripRdtexecute(RGtsrctdstt	recursivet	overwriteR�R�R�R�R8R)R$R9R_tcached_filetdst_is_directorytwhytfoundR�tsrc_fptidxtdstdirsR2t_R�tdstdirtset_modetset_uidtset_gidtsrc_nametdst_name((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_file_put�s�M#
! 		$	/
((
$	!cC@sM|d
k	r?tj|�}|jd�s?dj|�}q?nt||||	|
dt�}tjj	|�}tjj
|�s�td��ntjj|�r�tjj
|tjj|��}n-tjjtjj|��s�td��ntjj|�r>|std��ntjj|�sztd��qzn<tjj|�}tjj|�sztdj|���ntjjj|d	�� }
|
j|jj|��Wd
QX|r�tj||�n|s�|dkr�t|�}nd}|s|dkrt|�}nd}|dks3|dkrItj|||�ntS(u�
    Get a file from a container

    name :
        Name of the container

    src :
        The source file or directory

    dst :
        The destination file or directory

    mode :
        Set file mode to octal number

    uid :
        Set file uid (owner)

    gid :
        Set file gid (group)

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.

    u0u0{0}R^uFile path must be absolute.u/Parent directory for destination doesn't exist.u*Destination exists and overwrite is false.u%Destination exists but is not a file.uNo such file or directory '{0}'uwbNi����(RRRR0R
RgR?R1R2R3R�RR�R+R�R�R�R4RR�R�R�R�twriteRctchmodtinttchown(RGR�R�R�R�R�R�R8R)R$R9R_tdst_pathtdf((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_file_get�sL7$c
C@st|||||dt�}yr|j|�}i}t|d�sktddd|dd|d�}n$td|jd|jd|j�}Wn=tj	j
k
r�}	tdddddtj|	��}nXt
|d�dkr�t|d	<n
t|d	<|S(
u�
    Execute a command list on a container.

    name :
        Name of the container

    cmd :
        Command to be executed (as a list)

        Example :
            '["ls", "-l"]'

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

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

    cert :
        PEM Formatted SSL Certificate.

        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.

    CLI Example:

    .. code-block:: bash

        salt '*' lxd.container_execute <container name> '["ls", "-l"]'

    R^u	exit_codet	exit_codeitstdouttstderriuuresult(RgR?R�thasattrReR�R�R�RR5R�RRR�R(
RGR R8R)R$R9R_tresultt
saltresultR"((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytcontainer_execute,s(.
		(

cC@sQt||||�}|jj�}|rDg|D]}|j^q1Stt|�S(u� Lists all profiles from the LXD.

        list_names :

            Return a list of names instead of full blown dicts.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Examples:

        .. code-block:: bash

            salt '*' lxd.profile_list true --out=json
            salt '*' lxd.profile_list --out=json
    (R<RYRFRGRRH(RIR8R)R$R9R;RYtp((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_list}s
)cC@s�t||||�}t||�\}}y|jj|||�}	Wn.tjjk
rv}
ttj	|
���nX|dk	r�||	_t|	�nt
|	�S(u� Creates a profile.

        name :
            The name of the profile to get.

        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).

        description :
            A description string or None (None = unset).

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Examples:

        .. code-block:: bash

            $ salt '*' lxd.profile_create autostart config="{boot.autostart: 1, boot.autostart.delay: 2, boot.autostart.priority: 1}"
            $ salt '*' lxd.profile_create shared_mounts devices="{shared_mount: {type: 'disk', source: '/home/shared', path: '/home/shared'}}"

        See the `lxd-docs`_ for the details about the config and devices dicts.

        .. _lxd-docs: https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-10

        # noqa
    N(R<RSRYRTRR5R>RRRRtdescriptionRARH(RGRZR[R�R8R)R$R9R;tprofileR"((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_create�s;	
cC@stt||||�}d}y|jj|�}Wn,tjjk
r_tdj|���nX|rj|St	|�S(u� Gets a profile from the LXD

        name :
            The name of the profile to get.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        _raw :
            Return the pylxd object, this is internal and by states in use.

        CLI Examples:

        .. code-block:: bash

            $ salt '*' lxd.profile_get autostart
    uProfile '{0}' not foundN(
R<RRYRcRR5R>RR
RH(RGR8R)R$R9R^R;R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_get�s)cC@s,t|||||dt�}|j�tS(u� Deletes a profile.

        name :
            The name of the profile to delete.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Example:

        .. code-block:: bash

            $ salt '*' lxd.profile_delete shared_mounts
    R^(R�R?Rh(RGR8R)R$R9R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_delete6s&	
cC@s.t|||||dt�}t|d|�S(u� Get a profile config item.

        name :
            The name of the profile to get the config item from.

        config_key :
            The key for the item to retrieve.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Example:

        .. code-block:: bash

            $ salt '*' lxd.profile_config_get autostart boot.autostart
    R^uconfig(R�R?R�(RGR�R8R)R$R9R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_config_getis)	cC@s1t|||||dt�}t|d||�S(u Set a profile config item.

        name :
            The name of the profile to set the config item to.

        config_key :
            The items key.

        config_value :
            Its items value.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Example:

        .. code-block:: bash

            $ salt '*' lxd.profile_config_set autostart boot.autostart 0
    R^uconfig(R�R?R�(RGR�R�R8R)R$R9R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_config_set�s-	cC@s.t|||||dt�}t|d|�S(u Delete a profile config item.

        name :
            The name of the profile to delete the config item.

        config_key :
            The config key for the value to retrieve.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Example:

        .. code-block:: bash

            $ salt '*' lxd.profile_config_delete autostart boot.autostart.delay
    R^uconfig(R�R?R�(RGR�R8R)R$R9R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_config_delete�s)	cC@s.t|||||dt�}t|d|�S(u� Get a profile device.

        name :
            The name of the profile to get the device from.

        device_name :
            The name of the device to retrieve.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Example:

        .. code-block:: bash

            $ salt '*' lxd.profile_device_get default eth0
    R^udevices(R�R?R�(RGR�R8R)R$R9R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_device_get	s)	cK@snt|||||dt�}||d<x0tj|�D]\}	}
tj|
�||	<q8Wt|d||�S(u Set a profile device.

        name :
            The name of the profile to set the device to.

        device_name :
            The name of the device to set.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Example:

        .. code-block:: bash

            $ salt '*' lxd.profile_device_set autostart eth1 nic nictype=bridged parent=lxdbr0

        # noqa
    R^utypeudevices(R�R?RRVRR�(RGR�R�R8R)R$R9R�R�Rstv((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_device_setE	s-	
cC@s.t|||||dt�}t|d|�S(u� Delete a profile device.

        name :
            The name of the profile to delete the device.

        device_name :
            The name of the device to delete.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Example:

        .. code-block:: bash

            $ salt '*' lxd.profile_device_delete autostart eth1

        # noqa

    R^udevices(R�R?R�(RGR�R8R)R$R9R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytprofile_device_delete�	s,	cC@sEt||||�}|jj�}|r8d�|D�Stt|�S(u Lists all images from the LXD.

        list_aliases :

            Return a dict with the fingerprint as key and
            a list of aliases as value instead.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Examples:

        .. code-block:: bash

            $ salt '*' lxd.image_list true --out=json
            $ salt '*' lxd.image_list --out=json
    cS@s6i|],}g|jD]}|d^q|j�qS(uname(taliasestfingerprint(t.0tita((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pys
<dictcomp>�	s	(R<timagesRFRRH(tlist_aliasesR8R)R$R9R;R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyt
image_list�	s
)cC@stt||||�}d}y|jj|�}Wn,tjjk
r_tdj|���nX|rj|St	|�S(u� Get an image by its fingerprint

        fingerprint :
            The fingerprint of the image to retrieve

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        _raw : False
            Return the raw pylxd object or a dict of it?

        CLI Examples:

        ..code-block:: bash

            $ salt '*' lxd.image_get <fingerprint>
    u&Image with fingerprint '{0}' not foundN(
R<RR�RcRR5R>RR
RH(R�R8R)R$R9R^R;timage((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyt	image_get�	s-cC@stt||||�}d}y|jj|�}Wn,tjjk
r_tdj|���nX|rj|St	|�S(u� Get an image by an alias

        alias :
            The alias of the image to retrieve

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        _raw : False
            Return the raw pylxd object or a dict of it?

        CLI Examples:

        ..code-block:: bash

            $ salt '*' lxd.image_get_by_alias xenial/amd64
    u Image with alias '{0}' not foundN(
R<RR�tget_by_aliasRR5R>RR
RH(taliasR8R)R$R9R^R;R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytimage_get_by_alias1
s-cC@s&t|||||�}|j�tS(u� Delete an image by an alias or fingerprint

        name :
            The alias or fingerprint of the image to delete,
            can be a obj for the states.

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Examples:

        ..code-block:: bash

            $ salt '*' lxd.image_delete xenial/amd64
    (t
_verify_imageRhR?(R�R8R)R$R9((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytimage_deleten
s+
c

C@s�|dkrg}nt||||�}
y%|
jj||d|d|�}Wn.tjjk
r}ttj	|���nXx|D]}t
||�q�W|	r�|St|�S(u~ Create an image from simplestreams

        server :
            Simplestreams server URI

        alias :
            The alias of the image to retrieve

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        aliases : []
            List of aliases to append to the copied image

        public : False
            Make this image public available

        auto_update : False
            Should LXD auto update that image?

        _raw : False
            Return the raw pylxd object or a dict of the image?

        CLI Examples:

        ..code-block:: bash

            $ salt '*' lxd.image_from_simplestreams "https://cloud-images.ubuntu.com/releases" "trusty/amd64" aliases='["t", "trusty/amd64"]' auto_update=True

        # noqa
    tpublictauto_updateN(RR<R�tcreate_from_simplestreamsRR5R>RRRtimage_alias_addRH(
tserverR�R8R)R$R9R�R�R�R^R;R�R"((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytimage_from_simplestreams�
s?		
c	
C@s�|dkrg}nt||||�}	y"|	jj|d|d|�}
Wn.tjjk
r|}ttj	|���nXx|D]}t
|
|�q�W|r�|
St|
�S(u Create an image from an url

        url :
            The URL from where to download the image

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        aliases : []
            List of aliases to append to the copied image

        public : False
            Make this image public available

        auto_update : False
            Should LXD auto update that image?

        _raw : False
            Return the raw pylxd object or a dict of the image?

        CLI Examples:

        ..code-block:: bash

            $ salt '*' lxd.image_from_url https://dl.stgraber.org/lxd aliases='["busybox-amd64"]'

        # noqa
    R�R�N(RR<R�tcreate_from_urlRR5R>RRRR�RH(
turlR8R)R$R9R�R�R�R^R;R�R"R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytimage_from_url�
s;		
c	C@s�|dkrg}ntd|d|�}	d}
tjjj|	d��}|j�}
WdQXt||||�}y"|jj	|
d|dt
�}
Wn.tjj
k
r�}ttj|���nXx|D]}t|
|�q�W|r�|
St|
�S(u� Create an image from a file

        filename :
            The filename of the rootfs

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        aliases : []
            List of aliases to append to the copied image

        public : False
            Make this image public available

        saltenv : base
            The saltenv to use for salt:// copies

        _raw : False
            Return the raw pylxd object or a dict of the image?

        CLI Examples:

        ..code-block:: bash

            $ salt '*' lxd.image_from_file salt://lxd/files/busybox.tar.xz aliases=["busybox-amd64"]

        # noqa
    u
cp.cache_fileR�tur+bNR�RL(RRR�R�R�R�R�R<R�RTR?RR5R>RRRR�RH(tfilenameR8R)R$R9R�R�R�R^R�tdatatfpR;R�R"R�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytimage_from_fileEs ;	"
c
C@s�|	dkrg}	ntjdj|||��d}
y"t|||||dt�}
Wn/tk
r�t|||||dt�}
nXt||||�}|
j	|d|
d|dt�}x|	D]}t
||�q�W|r�|St|�S(uD Copy an image from another LXD instance

    source :
        An alias or a fingerprint of the source.

    src_remote_addr :
        An URL to the source remote daemon

        Examples:
            https://mysourceserver.lan:8443

    src_cert :
        PEM Formatted SSL Certificate for the source

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

    src_key :
        PEM Formatted SSL Key for the source

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

    src_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.

    remote_addr :
        Address of the destination daemon

        Examples:
            https://mydestserver.lan:8443

    cert :
        PEM Formatted SSL Certificate for the destination

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

    key :
        PEM Formatted SSL Key for the destination

        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.

    aliases : []
        List of aliases to append to the copied image

    public : None
        Make this image public available, None = copy source

    auto_update : None
        Wherever to auto-update from the original source, None = copy source

    _raw : False
        Return the raw pylxd object or a dict of the destination image?

    CLI Examples:

    .. code-block:: bash

        $ salt '*' lxd.image_copy_lxd xenial/amd64 https://srv01:8443 ~/.config/lxc/client.crt ~/.config/lxc/client.key false https://srv02:8443 ~/.config/lxc/client.crt ~/.config/lxc/client.key false aliases="['xenial/amd64']"

    # noqa
    u2Trying to copy the image "{0}" from "{1}" to "{2}"R^R�R�RLN(RR-R.R
R�R?RR�R<tcopyR�RH(RXR�R�R�R�R8R)R$R9R�R�R�R^t	src_imageR�t
dest_imageR�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytimage_copy_lxd�s,T		
	
ucC@sTt|||||�}x%|jD]}|d|kr"tSq"W|j||�tS(uC Create an alias on the given image

        image :
            An image alias, a fingerprint or a image object

        alias :
            The alias to add

        description :
            Description of the alias

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Examples:

        .. code-block:: bash

            $ salt '*' lxd.image_alias_add xenial/amd64 x "Short version of xenial/amd64"

        # noqa
    uname(R�R�R?t	add_alias(R�R�R�R8R)R$R9t
alias_info((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyR�s3cC@sHt|||||�}y|j|�Wntjjk
rCtSXtS(u' Delete an alias (this is currently not restricted to the image)

        image :
            An image alias, a fingerprint or a image object

        alias :
            The alias to delete

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

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

        cert :
            PEM Formatted SSL Certificate.

            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.

        CLI Examples:

        .. code-block:: bash

            $ salt '*' lxd.image_alias_add xenial/amd64 x "Short version of xenial/amd64"

        # noqa
    (R�tdelete_aliasRR5R>RR?(R�R�R8R)R$R9((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytimage_alias_deleteSs/c	C@s�t|||||dt�}|r0|g}ni}xK|D]C}|jig|jj�D]}i|jd6^q\|j6�q=W|S(u�
    Get all snapshots for a container

    container :
        The name of the container to get.

    remote_addr :
        An URL to a remote server. The 'cert' and 'key' fields must also be
        provided if 'remote_addr' is defined.

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

    cert :
        PEM Formatted SSL Certificate.

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

    key :
        PEM Formatted SSL Key.

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

    verify_cert : True
        Verify the ssl certificate.  Default: True

    CLI Examples:

    .. code-block:: bash

        $ salt '*' lxd.snapshots_all test-container
    R^uname(RgR?tupdatet	snapshotsRFRG(	R_R8R)R$R9REtrettcontRJ((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyt
snapshots_all�s$
5cC@s�t|||||dt�}|s<tj�jd�}n|jj|�x=t|�j|�D]&}|jd�|krbi|d6SqbWit	d6S(u
    Create a snapshot for a container

    container :
        The name of the container to get.

    name :
        The name of the snapshot.

    remote_addr :
        An URL to a remote server. The 'cert' and 'key' fields must also be
        provided if 'remote_addr' is defined.

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

    cert :
        PEM Formatted SSL Certificate.

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

    key :
        PEM Formatted SSL Key.

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

    verify_cert : True
        Verify the ssl certificate.  Default: True

    CLI Examples:

    .. code-block:: bash

        $ salt '*' lxd.snapshots_create test-container test-snapshot
    R^u%Y%m%d%H%M%Suname(
RgR?RtnowtstrftimeRRTRRcR(R_RGR8R)R$R9R
RJ((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytsnapshots_create�s(cC@swt|||||dt�}y;x4|jj�D]#}|j|kr1|j�tSq1WWntjjk
rrnXt	S(u
    Delete a snapshot for a container

    container :
        The name of the container to get.

    name :
        The name of the snapshot.

    remote_addr :
        An URL to a remote server. The 'cert' and 'key' fields must also be
        provided if 'remote_addr' is defined.

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

    cert :
        PEM Formatted SSL Certificate.

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

    key :
        PEM Formatted SSL Key.

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

    verify_cert : True
        Verify the ssl certificate.  Default: True

    CLI Examples:

    .. code-block:: bash

        $ salt '*' lxd.snapshots_delete test-container test-snapshot
    R^(
RgR?RRFRGRhRR5R>R(R_RGR8R)R$R9R
ts((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytsnapshots_delete�s(
cC@s.t|||||dt�}|jj|�S(u
    Get information about snapshot for a container

    container :
        The name of the container to get.

    name :
        The name of the snapshot.

    remote_addr :
        An URL to a remote server. The 'cert' and 'key' fields must also be
        provided if 'remote_addr' is defined.

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

    cert :
        PEM Formatted SSL Certificate.

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

    key :
        PEM Formatted SSL Key.

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

    verify_cert : True
        Verify the ssl certificate.  Default: True

    CLI Examples:

    .. code-block:: bash

        $ salt '*' lxd.snapshots_get test-container test-snapshot
    R^(RgR?RRc(R_RGR8R)R$R9((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyt
snapshots_get/
s(cC@s1t|t�rQ|rHd|dkrHd|dkrHd�|D�}qQi}nt|tj�rrtd��nt|tj�r�td��n|dk	r�x3tj|�D]\}}tj|�||<q�Wn|dk	r'xC|D]8}x/tj||�D]\}}||||<qWq�Wn||fS(u
    normalize config input so returns can be put into mongodb, which doesn't like `.`

    This is not meant to be used on the commandline.

    CLI Examples:

    .. code-block:: bash

        salt '*' lxd.normalize_input_values config={} devices={}
    ukeyiuvaluecS@s!i|]}|d|d�qS(uvalueukey((R�td((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pys
<dictcomp>q
s	u3config can't be a string, validate your YAML input.u4devices can't be a string, validate your YAML input.N(RMRNRRRRRRVR(RZR[RsR�R`((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyRSa
s(	
 c
C@swi}|dkri}ntttttj|j��ttj|j�����}t	|j��}tttttj|j
j��ttj|j
j�����|_
t	|j
j��}i}x�|j|�D]w}|jd�s�|jd�r	q�n|s9dj
||j
|�||<|j
|=q�dj
||j
|�||<q�Wx�|j|�D]�}|jd�sj|jd�r�qjn|||j
|krj|s�dj
||||j
|�||<|||j
|<qdj
||||j
|�||<qjqjWx�|j|�D]x}|jd�s$|jd�rNq$n|s�dj
|||�||<|||j
|<q$dj
|||�||<q$W|r�||d	<n|dkr�i}nt	|jj��}	t	|j��}
i}xb|	j|
�D]Q}|d
krqn|sCdj
|�||<|j|=qdj
|�||<qWx�tj|j�D]�\}}|d
kr�qmn||kr�qmn|||krm|s�d
j
|�||<|||j|<q�dj
|�||<qmqmWxi|
j|	�D]X}|d
krqn|sIdj
|�||<|||j|<qdj
|�||<qW|rs||d<n|S(u� Syncs the given config and devices with the object
        (a profile or a container)
        returns a changes dict with all changes made.

        obj :
            The object to sync with / or just test with.

        newconfig:
            The new config to check with the obj.

        newdevices:
            The new devices to check with the obj.

        test:
            Wherever to not change anything and give "Would change" message.
    u	volatile.uimage.u-Removed config key "{0}", its value was "{1}"u-Would remove config key "{0} with value "{1}"u6Changed config key "{0}" to "{1}", its value was "{2}"uBWould change config key "{0}" to "{1}", its current value is "{2}"uAdded config key "{0}" = "{1}"u"Would add config key "{0}" = "{1}"uconfigurootuRemoved device "{0}"uWould remove device "{0}"uChanged device "{0}"uWould change device "{0}"uAdded device "{0}"uWould add device "{0}"udevicesN(RReRNRRRRtkeystvaluesRPRZt
differenceR0R
tintersectionR[RV(
R@t	newconfigt
newdevicesttesttchangestccktocktconfig_changesRstdktndktdevices_changesR�((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pytsync_config_devices�
s�		!	'
%
	




cC@s�t||�}|dkr�|d}|dkrzd|krLtd��n|ddkrzd|krztd��qznx-|j�D]}|jd	�r�||=q�q�W|||<ntj|�||<t|�t|�S(
u� Sets the dict item key of the attr from obj.

        Basicaly it does getattr(obj, prop)[key] = value.


        For the disk device we added some checks to make
        device changes on the CLI saver.
    udevicesutypeudiskupathupath must be given as parameteru/usourceu!source must be given as parameteru__(RqRRR0RRRARH(R@tpropR$R%tattrR�Rs((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyR�,s"	


cC@s;t||�}||kr3tdj|���n||S(Nu'{0}' doesn't exists(RqRR
(R@R%R$R&((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyR�Ss
cC@sHt||�}||kr3tdj|���n||=t|�tS(Nu'{0}' doesn't exists(RqRR
RAR?(R@R%R$R&((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyR�]s
cC@s�t|tj�ru|}d}y"t|||||dt�}Wq�tk
rqt|||||dt�}q�Xn't|d�s�tdj	|���n|S(NR^ufingerprintuInvalid image '{0}'(
RMRRRRR�R?RR�R�R
(R�R8R)R$R9RG((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyR�js	
	cC@sIi}x<|jj�D]+}t||�rt||�||<qqW|S(u)Translates a plyxd model object to a dict(t__attributes__RR�Rq(R@t
marshalledR$((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyRH�s
uNotFoundR�cB@seZdZRS(u0An exception raised when an object is not found.(t__name__t
__module__t__doc__(((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyR��s(t	ContainertFilesManagercB@seZdddd�ZRS(cC@s�i}|dk	r^t|t�r0t|�}n!|jd�sQdj|�}n||d<n|dk	r�tj|�|d<n|dk	r�tj|�|d<n|jj	j
|jjj
jdi|d6d|d	|�}|jd
kS(Nu0u0{0}u
X-LXD-modeu	X-LXD-uidu	X-LXD-gidtparamsupathR�theadersi�(RRMR�R�R0R
RRt_clienttapiREt
_containerRGR�tpostRj(tselftfilepathR�R�R�R�R/tresponse((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyR��s
N(R)R*RR�(((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyR-�s(rR+t
__future__RRRR1Rtsalt.utils.decorators.pathR�tsalt.utils.filestsalt.utils.versionsRtsalt.exceptionsRRtsalt.ext.sixtextRtsalt.ext.six.movesRRRR?R	turllib3tdisable_warningsR5tInsecureRequestWarningtImportErrorRtloggingt	getLoggerR)R-t
__docformat__RRQRkRR,RR�t
decoratorsR2twhichRR
RR#R&R'R<RARCRKRbRgRiRnRtRvRzR|R~R�R�R�R�R�R�RWR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRR�R	RRRRRSR$R�R�R�R�RHtpylxd.exceptionsR�R>R�tpylxd.containerR,tpylxd.models.containerR-(((s4/usr/lib/python2.7/site-packages/salt/modules/lxd.pyt<module>!s�


	!		T$#$m	<;	�;'0;'	'''(d)/,*4,�mP1	L825964><299/MJTs981661	*�	'	
		



Zerion Mini Shell 1.0