HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/lxd.cpython-310.pyc
o

�N�g8�@szdZddlZddlmZmZdZdZdZdd�Z										
ddd�Z
ddd�Zddd�Zdd�Z
dd�Zdd�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
�N)�CommandExecutionError�SaltInvocationErrorzrestructuredtext enZlxd�core.trust_passwordcCsdtvrtSdS)z>
    Only load if the lxd module is available in __salt__
    zlxd.version)Fzlxd module could not be loaded)�__salt__�__virtualname__�rr�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/lxd.py�__virtual__)sr	�dir�!%SALT_CONFIG_DIR%/lxd_initializedc	
Cs�|||durdnd||||||d�	}	|�dd�}tj�|�r#t|	d�Stdr,t|	d	�Std
|�z*td|r:|nd|r?|nd|rD|nd|rI|nd|rN|nd|rS|nd|rX|nd�Wntyu}
z
t|	t	|
��WYd}
~
Sd}
~
wwt|	d�S)
a�
    Initializes the LXD Daemon, as LXD doesn't tell if its initialized
    we touch 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 there's currently no way
        to ask LXD if init has been called.
    NTF)	�name�storage_backend�trust_password�network_address�network_port�storage_create_device�storage_create_loop�storage_pool�	done_filez%SALT_CONFIG_DIR%z	/etc/saltzLXD is already initialized�testzWould initialize LXDz
file.touchzlxd.initzInitialized the LXD Daemon)
�replace�os�path�exists�_success�__opts__rr�_error�str)rr
rrrrrrr�ret�errr�init2s>0�









�	��
r Fc
Csz||dkr|nd|d�}ztd|�}Wnty-}z
t|t|��WYd}~Sd}~ww|tkr>|r6|s>t|d�|��St|�|krPt|d|�d|�d��Std	ry|tkred
}d|i|d<t||�Sd
|�d|�d�}||i|d<t||�Sd}z#td||�d}|tkr�|di|d<n
|d|�d|�d�i|d<Wnty�}z
t|t|��WYd}~Sd}~wwt||�S)a]
    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.

    rT)r�value�force_passwordzlxd.config_getNz?"{}" is already set (we don't known if the password is correct)�"z" is already set to "rzWould set the LXD password�password�changeszWould set the "z" to "�zlxd.config_setrzChanged the passwordzChanged from "z" to )	rrrr�_password_config_keyr�formatr�
_unchanged)rr!r"rZ
current_valuer�msgZ
result_msgrrr�config_managed�sN�����

���
r+Tc
Cs|||||d�}ztd||||�}Wn1ty,}z
t|t|��WYd}~Sd}~wtyD}z
t|t|��WYd}~Sd}~ww|jrMt|d�Sztd|||||�}	Wntyr}z
t|t|��WYd}~Sd}~ww|	durt|d|���Sd|��}
|
|d	<t||
�S)
a�
    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
        normally uses self-signed certificates.

    name:
        Ignore this. This is just here for salt.
    )r�remote_addr�cert�key�verify_certzlxd.pylxd_client_getNzAlready authenticated.zlxd.authenticateTz"Failed to authenticate with peer: z&Successfully authenticated with peer: r%)rrrrrZtrustedr)rr,r$r-r.r/r�clientr�resultr*rrr�authenticate�s<)����

���

r2cC�$d|d<||d<d|vri|d<|S)NTr1�commentr%r)rZsuccess_msgrrrr�
rcCs$d|d<||d<d|vri|d<|S)Nr1r4r%r)rr*rrrr)r5r)cCr3)NFr1r4r%r)r�err_msgrrrr!r5r)r
NNNNNNr)F)T)�__doc__Zos.pathrZsalt.exceptionsrrZ
__docformat__rr'r	r r+r2rr)rrrrr�<module>s*
�
X
>I