%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c	@@s�dZddlmZmZmZddlZddlmZddlm	Z	ddl
jjZdZ
dZdZd	�Zd
dddddddd�Zed
�Zed�Zd�Zd�Zd�ZdS(uz
Manage LXD profiles.

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

.. _pylxd: 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(tCommandExecutionError(tSaltInvocationErrorurestructuredtext enulxducore.trust_passwordcC@sdtkrtStS(u>
    Only load if the lxd module is available in __salt__
    ulxd.version(t__salt__t__virtualname__tFalse(((s3/usr/lib/python2.7/site-packages/salt/states/lxd.pyt__virtual__/sudiru!%SALT_CONFIG_DIR%/lxd_initializedc	C@s[i	|d6|d6|dk	r#tntd6|d6|d6|d6|d6|d6|d	6}	|jd
d�}tjj|�r�t|	d�Std
r�t|	d�St	d|�yxt	d|r�|nd|r�|nd|r�|nd|r�|nd|r�|nd|r|nd|r|nd�Wn&t
k
rM}
t|	tj
|
��SXt|	d�S(u�
    Initalizes the LXD Daemon, as LXD doesn't tell if its initialized
    we touch the the done_file and check if it exist.

    This can only be called once per host unless you remove the done_file.

    name :
        Ignore this. This is just here for salt.

    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

    done_file :
        Path where we check that this method has been called,
        as it can run only once and theres currently no way
        to ask LXD if init has been called.
    unameustorage_backendutrust_passwordunetwork_addressunetwork_portustorage_create_deviceustorage_create_loopustorage_poolu	done_fileu%SALT_CONFIG_DIR%u	/etc/saltuLXD is already initializedutestuWould initialize LXDu
file.touchulxd.inituInitialized the LXD DaemonN(tNonetTrueRtreplacetostpathtexistst_successt__opts__RRt_errortsixt	text_type(tnametstorage_backendttrust_passwordtnetwork_addresstnetwork_porttstorage_create_devicetstorage_create_looptstorage_poolt	done_filetrette((s3/usr/lib/python2.7/site-packages/salt/states/lxd.pytinit6s8(



cC@s�i|d6|dkr|ntd6|d6}ytd|�}Wn&tk
ri}t|tj|��SX|tkr�|s�|r�dj|�}t||�Stj|�|kr�dj||�}t||�St	drA|tkrd	}i|d
6|d<t
||�Sdj||�}i||6|d<t
||�Snd
}yXtd||�d}|tkr�id|6|d<nidj||�|6|d<Wn&tk
r�}t|tj|��SXt||�S(u]
    Manage a LXD Server config setting.

    name :
        The name of the config key.

    value :
        Its value.

    force_password : False
        Set this to True if you want to set the password on every run.

        As we can't retrieve the password from LXD we can't check
        if the current one is the same as the given one.

    unameucore.trust_passworduvalueuforce_passwordulxd.config_getu@"{0}" is already set (we don't known if the password is correct)u"{0}" is already set to "{1}"utestuWould set the LXD passwordupassworduchangesuWould set the "{0}" to "{1}"uulxd.config_setiuChanged the passworduChanged from "{0}" to {1}"(R
RRRRRt_password_config_keytformatRRt
_unchanged(Rtvaluetforce_passwordRt
current_valueRtmsgt
result_msg((s3/usr/lib/python2.7/site-packages/salt/states/lxd.pytconfig_managed�sH
	



cC@s;i|d6|d6|d6|d6|d6}ytd||||�}WnKtk
rn}t|tj|��Stk
r�}t|tj|��SX|jr�t|d�Sy td|||||�}	Wn&tk
r�}t|tj|��SX|	tk	rt|d	j	|��Sd
j	|�}
|
|d<t||
�S(u�
    Authenticate with a remote peer.

    .. notes:

        This function makes every time you run this a connection
        to remote_addr, you better call this only once.

    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

    password :
        The PaSsW0rD

    cert :
        PEM Formatted SSL Zertifikate.

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

    key :
        PEM Formatted SSL Key.

        Examples:
            /root/.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.

    name:
        Ignore this. This is just here for salt.
    unameuremote_addrucertukeyuverify_certulxd.pylxd_client_getuAlready authenticated.ulxd.authenticateu%Failed to authenticate with peer: {0}u)Successfully authenticated with peer: {0}uchanges(
RRRRRRttrustedRR
R!(Rtremote_addrtpasswordtcerttkeytverify_certRtclientRtresultR&((s3/usr/lib/python2.7/site-packages/salt/states/lxd.pytauthenticate�s:(
	

cC@s1t|d<||d<d|kr-i|d<n|S(Nuresultucommentuchanges(R
(Rtsuccess_msg((s3/usr/lib/python2.7/site-packages/salt/states/lxd.pyRs



cC@s1d|d<||d<d|kr-i|d<n|S(Nuresultucommentuchanges(R	(RR&((s3/usr/lib/python2.7/site-packages/salt/states/lxd.pyR"%s



cC@s1t|d<||d<d|kr-i|d<n|S(Nuresultucommentuchanges(R(Rterr_msg((s3/usr/lib/python2.7/site-packages/salt/states/lxd.pyR-s



(t__doc__t
__future__RRRtos.pathRtsalt.exceptionsRRtsalt.ext.sixtextRt
__docformat__RR RR	RRR(R
R1RR"R(((s3/usr/lib/python2.7/site-packages/salt/states/lxd.pyt<module>s$		NEQ		

Zerion Mini Shell 1.0