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_image.cpython-310.pyc
o

�N�g*�@sbdZddlmZmZdZdZdd�Z							dd	d
�Zddd�Zd
d�Z	dd�Z
dd�ZdS)u�
Manage LXD images.

.. versionadded:: 2019.2.0

.. link: https://github.com/lxc/pylxd/blob/master/doc/source/installation.rst

.. note:

    - :role:`pylxd <link>` 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.


:maintainer: René Jochum <rene@jochums.at>
:maturity: new
:depends: python-pylxd
:platform: Linux
�)�CommandExecutionError�SaltInvocationErrorzrestructuredtext enZ	lxd_imagecCsdtvrtSdS)z>
    Only load if the lxd module is available in __salt__
    zlxd.version)Fzlxd module could not be loaded)�__salt__�__virtualname__�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/lxd_image.py�__virtual__&srNTc	Cs�|durg}|dd�}|||||||||id�
}	d}
ztd|||||dd�}
Wn*tyB}z
t|	t|��WYd}~Sd}~wtyS}zWYd}~nd}~ww|
du�r"tdrnd|�d�}d	|i|	d
<t|	|�Sz�|ddkr�td
|d|d|d|d|�dd�|||||||dd�
}
|ddkr�d|vr�t|d<td|d||||||dur�dn||ddd�	}
|ddkr�td|d|d||||||dur�dn||dur�dn|dd�
}
|ddk�rtd|d||||||dur�dn||du�rdn|dd�	}
Wnt�y!}z
t|	t|��WYd}~Sd}~ww||v�r,|�	|�d d!�|
j
D�}
ttt|��}g}|
�
|�D]#}td�s[td"|
|�|�	d#|�d���qB|�	d$|�d���qB|�
|
�D]$}td�s�td%|
|d&�|�	d'|�d���qk|�	d(|�d���qk|�r�||	d
d)<|du�r�|
j|k�r�td�s�d*|��|	d
d+<||
_td,|
�n	d-|��|	d
d+<td�r�|	d
�r�t|	d.�t|	d
�����St|	d/�t|	d
�����S)0aZ	
    Ensure an image exists, copy it else from source

    name :
        An alias of the image, this is used to check if the image exists and
        it will be added as alias to the image on copy/create.

    source :
        Source dict.

        For an LXD to LXD copy:

        .. code-block:: yaml

            source:
                type: lxd
                name: ubuntu/xenial/amd64  # This can also be a fingerprint.
                remote_addr: https://images.linuxcontainers.org:8443
                cert: ~/.config/lxd/client.crt
                key: ~/.config/lxd/client.key
                verify_cert: False

        .. attention:

            For this kind of remote you also need to provide:
            - a https:// remote_addr
            - a cert and key
            - verify_cert

        From file:

        .. code-block:: yaml

            source:
                type: file
                filename: salt://lxd/files/busybox.tar.xz
                saltenv: base

        From simplestreams:

        .. code-block:: yaml

            source:
                type: simplestreams
                server: https://cloud-images.ubuntu.com/releases
                name: xenial/amd64

        From an URL:

        .. code-block:: yaml

            source:
                type: url
                url: https://dl.stgraber.org/lxd

    aliases :
        List of aliases to append, can be empty.

    public :
        Make this image public available on this instance?
            None on source_type LXD means copy source
            None on source_type file means False

    auto_update :
        Try to auto-update from the original source?
            None on source_type LXD means copy source
            source_type file does not have auto-update.

    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

    cert :
        PEM Formatted SSL Zertifikate.

        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
        normally uses self-signed certificates.
    N)
�name�source�aliases�public�auto_update�remote_addr�cert�key�verify_cert�changes�lxd.image_get_by_aliasT��_raw�testzWould create the image "�"�createdr�typeZlxdzlxd.image_copy_lxdr	rrrr)Zsrc_remote_addrZsrc_certZsrc_keyZsrc_verify_certrrrrrrr
r�file�saltenvzlxd.image_from_file�filenameF)rrrrrrrrZ
simplestreamszlxd.image_from_simplestreamsZserver)rrrrrrr
r�urlzlxd.image_from_urlcSsh|]}t|d��qS)r	)�str)�.0�arrr�	<setcomp>�szpresent.<locals>.<setcomp>zlxd.image_alias_deletezRemoved alias "zWould remove alias "zlxd.image_alias_add�z
Added alias "zWould add alias "rzSetting the image public to rzlxd.pylxd_save_objectzWould set public to zWould do {} changesz
{} changes)rr�_errorrr�__opts__�
_unchanged�getZ__env__�appendr�set�map�
differencer�format�len�keys�_success)r	r
rrr
rrrr�ret�image�e�msgZold_aliasesZnew_aliasesZ
alias_changes�krrr�present/s�h�

����


���
����




r4c
Cs�|||||id�}d}ztd|||||dd�}Wnxty2}z
t|t|��WYd}~Sd}~wty�}zTztd|||||dd�}Wn?tyf}zt|t|��WYd}~WYd}~Sd}~wty�}zt|d|�d��WYd}~WYd}~Sd}~wwWYd}~nd}~wwtd	r�d
d|�d�i|d<t||dd
�Std
|�d
d|�d�i|d<t||dd
�S)a�
    name :
        An alias or fingerprint of the image to check and delete.

    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

    cert :
        PEM Formatted SSL Zertifikate.

        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
        normally uses self-signed certificates.
    )r	rrrrrNrTrz
lxd.image_getzImage "z" not found.rZremovedz" would get deleted.rzlxd.image_deletez" has been deleted.)rrr#rrr.r$)r	rrrrr/r0r1rrr�absent#sH�
��
�&�*�����
r5cC�$d|d<||d<d|vri|d<|S)NT�result�commentrr)r/Zsuccess_msgrrrr.d�
r.cCs$d|d<||d<d|vri|d<|S)Nr7r8rr)r/r2rrrr%lr9r%cCr6)NFr7r8rr)r/�err_msgrrrr#tr9r#)NNNNNNT)NNNT)�__doc__Zsalt.exceptionsrrZ
__docformat__rrr4r5r.r%r#rrrr�<module>s$
�
uA