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__/lxc.cpython-310.pyc
o

�N�g�W�@s�dZddlmZmZdZ																ddd�Zddd	�Zdd
d�Zdd
d�Zddd�Z	dd�Z
ddd�ZdS)z1
Manage Linux Containers
=======================
�)�CommandExecutionError�SaltInvocationErrorzrestructuredtext enNFcCs�|dd|�d�id�}t|||f�s:td|�}tdd�|D��s*d|d	<d
|d<nz|d}Wn	ty9Ynw|rPtd
||d�sPd|d	<d|�d�|d<|d	sV|S|r]d|��nd}dtd||d�i}tdr�|ddur�d�||r}d|��nd�|d<d|d	<|S|dur�|S|r�|ddvr�d�||ddkr�dnd�|d<d|d	<|S|dd7<|S|ddvr�d|�d�|d<d|d	<|S|dd 7<|S|ddu�r=z'|r�td!||||||||d"�}ntd#|||||||	|
|||
|||d$�}Wnttf�y }zd|d	<|j|d<WYd}~n!d}~ww|�r-d%�||�|d<nd&|�d'�|d<|d(d)|d)<|d	du�r\|du�rK�n|�r�td||d�}|d*k�rd|dd7<n�d+}z,|dk�rnd,nd-}t|||d�d(d)|d)<|d)d*k�r�d|d	<|d|7<Wn&ttf�y�}zd|d	<|d|�d.|��7<WYd}~n�d}~ww|ddu�r�|dd/7<n�d0�||ddk�r�dnd�|d<n�td||d�}|d1k�r�|ddu�r�|dd 7<ndd2}z#td3||d�d(d)|d)<|d)d1k�rd|d	<|d|7<Wn&ttf�yC}zd|d	<|d|�d.|��7<WYd}~nd}~ww|ddu�rT|dd47<nd|�d5�|d<d)|v�rktd||d�|d)<|d|d)k�rz||d6d(<|S)7a8
    .. versionchanged:: 2015.8.0

        The :mod:`lxc.created <salt.states.lxc.created>` state has been renamed
        to ``lxc.present``, and the :mod:`lxc.cloned <salt.states.lxc.cloned>`
        state has been merged into this state.

    Create the named container if it does not exist

    name
        The name of the container to be created

    path
        path to the container parent
        default: /var/lib/lxc (system default)

        .. versionadded:: 2015.8.0


    running : False
        * If ``True``, ensure that the container is running
        * If ``False``, ensure that the container is stopped
        * If ``None``, do nothing with regards to the running state of the
          container

        .. versionadded:: 2015.8.0

    clone_from
        Create named container as a clone of the specified container

    snapshot : False
        Use Copy On Write snapshots (LVM). Only supported with ``clone_from``.

    profile
        Profile to use in container creation (see the :ref:`LXC Tutorial
        <tutorial-lxc-profiles-container>` for more information). Values in a
        profile will be overridden by the parameters listed below.

    network_profile
        Network Profile to use in container creation
        (see the :ref:`LXC Tutorial <tutorial-lxc-profiles-container>`
        for more information). Values in a profile will be overridden by
        the parameters listed below.

        .. versionadded:: 2015.5.2

    **Container Creation Arguments**

    template
        The template to use. For example, ``ubuntu`` or ``fedora``.
        For a full list of available templates, check out
        the :mod:`lxc.templates <salt.modules.lxc.templates>` function.

        Conflicts with the ``image`` argument.

        .. note::

            The ``download`` template requires the following three parameters
            to be defined in ``options``:

            * **dist** - The name of the distribution
            * **release** - Release name/version
            * **arch** - Architecture of the container

            The available images can be listed using the :mod:`lxc.images
            <salt.modules.lxc.images>` function.

    options

        .. versionadded:: 2015.5.0

        Template-specific options to pass to the lxc-create command. These
        correspond to the long options (ones beginning with two dashes) that
        the template script accepts. For example:

        .. code-block:: yaml

            web01:
              lxc.present:
                - template: download
                - options:
                    dist: centos
                    release: 6
                    arch: amd64

        Remember to double-indent the options, due to :ref:`how PyYAML works
        <nested-dict-indentation>`.

        For available template options, refer to the lxc template scripts
        which are usually located under ``/usr/share/lxc/templates``,
        or run ``lxc-create -t <template> -h``.

    image
        A tar archive to use as the rootfs for the container. Conflicts with
        the ``template`` argument.

    backing
        The type of storage to use. Set to ``lvm`` to use an LVM group.
        Defaults to filesystem within /var/lib/lxc.

    fstype
        Filesystem type to use on LVM logical volume

    size
        Size of the volume to create. Only applicable if ``backing`` is set to
        ``lvm``.

    vgname : lxc
        Name of the LVM volume group in which to create the volume for this
        container. Only applicable if ``backing`` is set to ``lvm``.

    lvname
        Name of the LVM logical volume in which to create the volume for this
        container. Only applicable if ``backing`` is set to ``lvm``.

    thinpool
        Name of a pool volume that will be used for thin-provisioning this
        container. Only applicable if ``backing`` is set to ``lvm``.
    T�Container 'z' already exists��name�result�comment�changeszlxc.get_container_profilecss�|]	}|dvr|VqdS))�template�image�
clone_fromN�)�.0�xr
r
�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/lxc.py�	<genexpr>�s�zpresent.<locals>.<genexpr>FrzhNo template, image, or clone_from parameter was found in either the state's arguments or the LXC profilerr�
lxc.exists��pathzClone source '�' does not existzcloned from �created�old�	lxc.state�testNzContainer '{}' will be {})�frozen�stoppedzContainer '{}' would be {}r�unfrozen�startedz and is running)r�runningz' would be stoppedz and is stoppedz	lxc.clone)�profile�network_profile�snapshot�sizer�backingz
lxc.create)
rr r
�optionsr�config�fstyper"r#�vgnamer�lvname�thinpoolzCloned container '{}' as '{}'zCreated container '�'�state�newrz, but it could not be started�lxc.unfreeze�	lxc.startz: z, and the container was startedzContainer '{}' was {}rz, but it could not be stopped�lxc.stopz, and the container was stoppedz
' was stoppedr	)�any�__salt__�KeyError�__opts__�formatrr�strerror)rrrr!rr r
r$rr%r&r"r#r'r(r)r�retZ	c_profile�actionr+r�excZc_state�errorZ
start_funcr
r
r�presents
����������
�

�&��
�
��&��
r:c
Cs�|idd|�d�d�}td||d�s|Stdr'd|d	<d|�d
�|d<|Sztd|||d
�}Wn ttfyR}zd|d	<d|��|d<WYd}~|Sd}~ww|d|dd<d|�d�|d<|S)a�
    Ensure a container is not present, destroying it if present

    name
        Name of the container to destroy

    stop
        stop before destroying
        default: false

        .. versionadded:: 2015.5.2

    path
        path to the container parent
        default: /var/lib/lxc (system default)

        .. versionadded:: 2015.8.0


    .. code-block:: yaml

        web01:
          lxc.absent
    Trr)rr	rrrrrNrz' would be destroyedrzlxc.destroy)�stoprFzFailed to destroy container: r+r	z' was destroyed)r1r3rr)rr;rr6rr8r
r
r�absent?s,
���r<c
Cs|dd|�d�id�}dtd||d�i}|ddur)d	|d
<d|�d�|d<|S|dd
kr3|s3|S|ddkr=|r=d	}|rK|ddkrHd}nd}n|ddkrTd}nd}tdrld|d
<d|�d|d��|d<|Sz&|ddkr~|s~td||d�}n|r�td||d�}ntd||d�}Wn'ttfy�}zd	|d
<|j|d<td||d�|d<WYd}~nCd}~ww|dd|d<|dd
kr�d	|d
<d|d�d|�d�|d<n
d�||d�|d<z
|d |d!d <Wn	ty�Ynw|d|dk�r||d!d<|S)"a4
    .. versionchanged:: 2015.5.0
        The :mod:`lxc.started <salt.states.lxc.started>` state has been renamed
        to ``lxc.running``

    Ensure that a container is running

    .. note::

        This state does not enforce the existence of the named container, it
        just starts the container if it is not running. To ensure that the
        named container exists, use :mod:`lxc.present
        <salt.states.lxc.present>`.

    name
        The name of the container

    path
        path to the container parent
        default: /var/lib/lxc (system default)

        .. versionadded:: 2015.8.0

    restart : False
        Restart container if it is already running

    .. code-block:: yaml

        web01:
          lxc.running

        web02:
          lxc.running:
            - restart: True
    Trz' is already runningrrrrNFrrrrr)�restart�	restarted)�startrr)Zunfreezerr�' would be �r-zlxc.restartr.r,r+�
Unable to r� container 'r*�"Container '{}' was successfully {}r>r	�r1r3rrr5r4r2)rr=rr6r+r7rr8r
r
rrssj%
��
 ����rTc
Cs�|dd|�d�id�}dtd||d�i}|ddur(d	|d
<d|�d�|d<n|dd
kr<|s<d	|d
<d|�d�|d<|d
d	usH|ddkrJ|S|dd
krSd}nd}tdrkd|d
<d|�d|d��|d<|Sztd|||d�}Wn'ttfy�}zd	|d
<|j|d<td||d�|d<WYd}~nCd}~ww|dd|d<|ddkr�d	|d
<d|d�d|�d�|d<n
d�||d�|d<z
|d|dd<Wn	ty�Ynw|d|dkr�||dd<|S) a
    .. versionadded:: 2015.5.0

    Ensure that a container is frozen

    .. note::

        This state does not enforce the existence of the named container, it
        just freezes the container if it is running. To ensure that the named
        container exists, use :mod:`lxc.present <salt.states.lxc.present>`.

    name
        The name of the container

    path
        path to the container parent
        default: /var/lib/lxc (system default)

        .. versionadded:: 2015.8.0


    start : True
        Start container first, if necessary. If ``False``, then this state will
        fail if the container is not running.

    .. code-block:: yaml

        web01:
          lxc.frozen

        web02:
          lxc.frozen:
            - start: False
    Trz' is already frozenrrrrNFrrrrz' is stoppedr)zstart and freezezstarted and frozen)Zfreezerrr@rAz
lxc.freeze)r?rr,r+rBrrCr*rDrr	rE)rr?rr6r+r7rr8r
r
rr�sX$
�
 ����rc
Csv|dd|�d�id�}dtd||d�i}|ddur)d	|d
<d|�d�|d<|S|dd
kr1|S|r6d}nd}tdrNd|d
<d|�d|d��|d<|Sztd|||d�}Wn'ttfy�}zd	|d
<|j|d<td||d�|d<WYd}~n/d}~ww|dd|d<|dd
kr�d	|d
<d|d�d|�d�|d<n
d�||d�|d<|d|dkr�||dd<|S)a~
    Ensure that a container is stopped

    .. note::

        This state does not enforce the existence of the named container, it
        just stops the container if it running or frozen. To ensure that the
        named container exists, use :mod:`lxc.present
        <salt.states.lxc.present>`, or use the :mod:`lxc.absent
        <salt.states.lxc.absent>` state to ensure that the container does not
        exist.

    name
        The name of the container

    path
        path to the container parent
        default: /var/lib/lxc (system default)

        .. versionadded:: 2015.8.0

    kill : False
        Do not wait for the container to stop, kill all tasks in the container.
        Older LXC versions will stop containers like this irrespective of this
        argument.

        .. versionadded:: 2015.5.0

    .. code-block:: yaml

        web01:
          lxc.stopped
    Trz' is already stoppedrrrrNFrrrr)z
force-stopz
force-stopped)r;rrr@rAr/)�killrr,r+rBrrCr*rDr	)r1r3rrr5r4)rrFrr6r+r7rr8r
r
rr0sJ#
�
 ���rcKs|ddid�S)an
    .. deprecated:: 2015.5.0

    This state function has been disabled, as it did not conform to design
    guidelines. Specifically, due to the fact that :mod:`lxc.set_password
    <salt.modules.lxc.set_password>` uses ``chpasswd(8)`` to set the password,
    there was no method to make this action idempotent (in other words, the
    password would be changed every time). This makes this state redundant,
    since the following state will do the same thing:

    .. code-block:: yaml

        setpass:
          module.run:
            - name: set_pass
            - m_name: root
            - password: secret
    zoThe lxc.set_pass state is no longer supported. Please see the LXC states documentation for further information.F�rrrr	r
)r�kwargsr
r
r�set_pass�s
�rIcCsJtdr||�d�did�S|si}|si}td|||d�}||d<|S)a\
    .. warning::

        This state is unsuitable for setting parameters that appear more than
        once in an LXC config file, or parameters which must appear in a
        certain order (such as when configuring more than one network
        interface).

        `Issue #35523`_ was opened to track the addition of a suitable replacement
        or fix.

    Edit LXC configuration options

    .. deprecated:: 2015.5.0

    path
        path to the container parent
        default: /var/lib/lxc (system default)

        .. versionadded:: 2015.8.0


    .. code-block:: bash

        setconf:
          lxc.edited_conf:
            - name: ubuntu
            - lxc_conf:
                - network.ipv4.ip: 10.0.3.6
            - lxc_conf_unset:
                - lxc.utsname

    .. _`Issue #35523`: https://github.com/saltstack/salt/issues/35523

    rz lxc.conf will be editedTrGzlxc.update_lxc_conf)�lxc_conf�lxc_conf_unsetr)r3r1)rrJrKZcretr
r
r�edited_conf�s$��rL)NNFNNNNNNNNNNNNN)FN)TN)NN)�__doc__Zsalt.exceptionsrrZ
__docformat__r:r<rrrrIrLr
r
r
r�<module>s8
�
5
4
e
XP