File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/lxd.cpython-310.pyc
Back
o ;j g � @ s� d Z ddlZddlZddlmZ ddlZddlZddlmZm Z ddl mZ zddlZdZ ddlZe�ejj� W n eyD dZ Y nw e�e�ZdZd Zd ddd dddddd� ZdZdZi Zdd� Zejjj� d�dd� �Z!dd� Z"ejjj� d� d�dd��Z#ejjj� d�ejjj� d�d d!� ��Z$ejjj� d�ejjj� d�d"d#� ��Z%d�d$d%�Z&d&d'� Z'd�d(d)�Z( d�d*d+�Z) , d�d-d.�Z* d�d/d0�Z+d�d1d2�Z, d�d3d4�Z-d�d5d6�Z.d�d7d8�Z/ 9 d�d:d;�Z0d�d<d=�Z1d�d>d?�Z2d�d@dA�Z3 d�dBdC�Z4 d�dDdE�Z5 d�dFdG�Z6 d�dHdI�Z7 d�dJdK�Z8 L d�dMdN�Z9 d�dOdP�Z: Q d�dRdS�Z; d�dTdU�Z< d�dVdW�Z= d�dXdY�Z> d�dZd[�Z? d�d\d]�Z@d�d^d_�ZA d�d`da�ZB d�dbdc�ZC d�ddde�ZD d�dfdg�ZE L d�dhdi�ZF d�djdk�ZG d�dldm�ZH d�dndo�ZI d�dpdq�ZJd�drds�ZK d�dtdu�ZL d�dvdw�ZM Q d�dxdy�ZN d�dzd{�ZO | d�d}d~�ZP d�dd��ZQd�d�d��ZR d�d�d��ZS d�d�d��ZT d�d�d��ZUd�d�� ZVd�d�d��ZWd�d�� ZXd�d�� ZYd�d�� ZZd�d�d��Z[d�d�� Z\e �ryddl]Ze^ejd���sUG d�d�� d�ejj_�Z`e`ej_`zdd�lambZb W n e�ym dd�lcmbZb Y nw d�d�d��Zdedebje_ddS dS )�uU 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. .. _LXD(1): https://linuxcontainers.org/lxd/ .. _pylxd(2): 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)�datetime)�CommandExecutionError�SaltInvocationError)�VersionTFzrestructuredtext enz2.2.5�0�1�2�3�4�5�6�7�8) �unknownZi686�x86_64Zarmv7l�aarch64�ppcZppc64Zppc64leZs390x�g Zlxdc C s0 t rtt� �tt�k rdd�t� t�fS tS dS )NFzdThe lxd execution module cannot be loaded: pylxd "{}" is not supported, you need at least pylxd "{}")FzTThe lxd execution module cannot be loaded: the pylxd python module is not available.)� HAS_PYLXDr � pylxd_version�_pylxd_minimal_version�format�__virtualname__� r r �D/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/lxd.py�__virtual__R s ��r c C s t d d�S )zt Returns the actual lxd version. CLI Example: .. code-block:: bash salt '*' lxd.version �cmd.runz lxd --version)�__salt__r r r r �versioni s r c C s t jS )z| Returns the actual pylxd version. CLI Example: .. code-block:: bash salt '*' lxd.pylxd_version )�pylxd�__version__r r r r r x s r �dirc C s d| � d�}|dur|d|� d� }|dur|d|� d� }|dur*|d|� d� }|dur6|d|� d� }|durB|d|� d� }|durN|d |� d� }zt d |�}W n tyn } ztd|� dt| �� ���d} ~ ww d |v r�t||�d �d d� ��|S )a 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 z#lxd init --auto --storage-backend="�"Nz --trust-password="z --network-address="z --network-port="z --storage-create-device="z --storage-create-loop="z --storage-pool="r zFailed to call: 'z', error was: �error:� )r � ValueErrorr �str�index) Zstorage_backendZtrust_password�network_addressZnetwork_portZstorage_create_deviceZstorage_create_loopZstorage_pool�cmd�output�er r r �init� s4 1����r, Zlxcc C sH d� | |�}td |�}d|v rt||�d�d d� ��d| � d�fS )ag 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 zlxc config set "{}" "{}"r r# r$ NzConfig value "z" successfully set.)r r r r'