File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/lxd.cpython-310.pyc
o
�N�g8 � @ sz d Z ddlZddlmZmZ dZdZdZdd� Z
ddd�Z
ddd�Zddd�Zdd� 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_passwordc C s dt v rtS dS )z>
Only load if the lxd module is available in __salt__
zlxd.version)Fzlxd module could not be loaded)�__salt__�__virtualname__� r r �C/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/lxd.py�__virtual__) s r �dir�!%SALT_CONFIG_DIR%/lxd_initializedc
C s� | ||durdnd||||||d� } |� dd�}tj�|�r#t| d�S td r,t| d �S td
|� z*td |r:|nd|r?|nd|rD|nd|rI|nd|rN|nd|rS|nd|rX|nd� W n tyu }
z
t| t |
��W Y d}
~
S d}
~
ww t| 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__r r �_error�str)r r
r r r r r r r �ret�er r r �init2 s>