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

�N�g�-�@sndZdZdd�Zdd�Z											dd	d
�Z								ddd�Z							dd
d�ZdS)a�
Zookeeper State

:depends:  kazoo
:configuration: See :py:mod:`salt.modules.zookeeper` for setup instructions.

ACLS
~~~~

For more information about acls, please checkout the kazoo documentation.

http://kazoo.readthedocs.io/en/latest/api/security.html#kazoo.security.make_digest_acl

The following options can be included in the acl dictionary:

    :param username: Username to use for the ACL.
    :param password: A plain-text password to hash.
    :param write: Write permission.
    :type write: bool
    :param create: Create permission.
    :type create: bool
    :param delete: Delete permission.
    :type delete: bool
    :param admin: Admin permission.
    :type admin: bool
    :param all: All permissions.
    :type all: bool
Z	zookeepercCsdtvrtSdS)N�zookeeper.create)Fz$zookeeper module could not be loaded)�__salt__�__virtualname__�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/zookeeper.py�__virtual__!srcCs4tt|�t|��}tt|�t|��}|o|S)N)�bool�set)�left�right�first�secondrrr�_check_acls'sr
NF���c
Csx|dd|��id�}
|||	|
||d�}|durg}ndd�|D�}td|fi|���r'td	|fi|��}td
|fi|��}||krVt||�rVd|
d<d
�|�|
d<|
Stddur�d|
d<d|�d�|
d<i|
dd<i|
dd<||kr�||
ddd<||
ddd<t||�s�||
ddd<||
ddd<|
Sd\}}i}||kr�td|||fi|��td	|fi|��}||k}|�di��d|�|�di��d|�|�rt||��std|||fi|��td
|fi|��}t||�}|�di��d|�|�di��d|�||
d<|�r%|�r%d|
d<d|�d�|
d<|
Stddu�rWd|
d<|�d�|
d<i|
dd<i|
dd<||
ddd<||
ddd<|
Std||||||fi|��d\}}dii}td	|fi|��}||k}|�di��d|�td
|fi|��}|du�p�t||�}|�di��d|�||
d<|�r�|�r�d|
d<d|�d�|
d<|
S)a
    Make sure znode is present in the correct state with the correct acls

    name
        path to znode

    value
        value znode should be set to

    acls
        list of acl dictionaries to set on znode (make sure the ones salt is connected with are included)
        Default: None

    ephemeral
        Boolean to indicate if ephemeral znode should be created
        Default: False

    sequence
        Boolean to indicate if znode path is suffixed with a unique index
        Default: False

    makepath
        Boolean to indicate if the parent paths should be created
        Default: False

    version
        For updating, specify the version which should be updated
        Default: -1 (always match)

    profile
        Configured Zookeeper profile to authenticate with (Default: None)

    hosts
        Lists of Zookeeper Hosts (Default: '127.0.0.1:2181)

    scheme
        Scheme to authenticate with (Default: 'digest')

    username
        Username to authenticate (Default: None)

    password
        Password to authenticate (Default: None)

    default_acl
        Default acls to assign if a node is created in this connection (Default: None)

    .. code-block:: yaml

        add znode:
          zookeeper.present:
            - name: /test/name
            - value: gtmanfred
            - makepath: True

        update znode:
          zookeeper.present:
            - name: /test/name
            - value: daniel
            - acls:
              - username: daniel
                password: test
                read: true
              - username: gtmanfred
                password: test
                read: true
                write: true
                create: true
                delete: true
                admin: true
            - makepath: True
    FzFailed to setup znode ��name�result�comment�changes��profile�hosts�scheme�username�password�default_aclNcS�g|]}tddi|���qS�zzookeeper.make_digest_aclr�r��.0Zaclrrr�
<listcomp>��zpresent.<locals>.<listcomp>�zookeeper.exists�
zookeeper.get�zookeeper.get_aclsTrzBZnode {} is already set to the correct value with the correct aclsr�test�Znode z is will be updatedr�old�new�value�acls)TTz
zookeeper.set�zookeeper.set_aclsz successfully updatedz is will be createdrz successfully created)rr
�format�__opts__�
setdefault)rr)r*Z	ephemeralZsequence�makepath�versionrrrrrr�ret�
connkwargs�chk_aclsZ	cur_value�cur_aclsZvalue_resultZ
acl_resultrZ	new_value�new_aclsrrr�present-s�Y����

��r6c	Cs:|dd|��id�}	||||||d�}
td|fi|
��dur-d|	d<d|�d	�|	d
<|	Si}td|fi|
��|d<td
|fi|
��|d<|durWtd|fi|
��|d<tddurqd|	d<d|�d�|	d
<||	dd<|	Std|||fi|
��td|fi|
��dur�d|	d<d|�d�|	d
<||	dd<|	S)a`
    Make sure znode is absent

    name
        path to znode

    version
        Specify the version which should be deleted
        Default: -1 (always match)

    recursive
        Boolean to indicate if children should be recursively deleted
        Default: False

    profile
        Configured Zookeeper profile to authenticate with (Default: None)

    hosts
        Lists of Zookeeper Hosts (Default: '127.0.0.1:2181)

    scheme
        Scheme to authenticate with (Default: 'digest')

    username
        Username to authenticate (Default: None)

    password
        Password to authenticate (Default: None)

    default_acl
        Default acls to assign if a node is created in this connection (Default: None)

    .. code-block:: yaml

        delete znode:
          zookeeper.absent:
            - name: /test
            - recursive: True
    FzFailed to delete znode rrr"Trr&z does not existrr#r)r$r*zzookeeper.get_children�childrenr%Nz will be removedrr'zzookeeper.deletez has been removed)rr-)rr0�	recursiverrrrrrr1r2rrrr�absent�s@3��	r9c	CsZ|dd|��id�}	||||||d�}
t|t�r|g}dd�|D�}td|fi|
��s6|	dd	7<|	Std
|fi|
��}t||�rSd|	d<d
|�d�|	d<|	Stddursd|	d<d
|�d�|	d<||	dd<||	dd<|	Std|||fi|
��td
|fi|
��}
||
d�|	d<t|
|�r�d|	d<d
|�d�|	d<|	Sd
|�d�|	d<|	S)a�
    Update acls on a znode

    name
        path to znode

    acls
        list of acl dictionaries to set on znode

    version
        Specify the version which should be deleted
        Default: -1 (always match)

    profile
        Configured Zookeeper profile to authenticate with (Default: None)

    hosts
        Lists of Zookeeper Hosts (Default: '127.0.0.1:2181)

    scheme
        Scheme to authenticate with (Default: 'digest')

    username
        Username to authenticate (Default: None)

    password
        Password to authenticate (Default: None)

    default_acl
        Default acls to assign if a node is created in this connection (Default: None)

    .. code-block:: yaml

        update acls:
          zookeeper.acls:
            - name: /test/name
            - acls:
              - username: daniel
                password: test
                all: True
              - username: gtmanfred
                password: test
                all: True
    FzFailed to set acls on znode rrcSrrrrrrrr �r!zacls.<locals>.<listcomp>r"rz: Znode does not existr$Trr&z acls already setr%Nz acls will be updatedrr'r(r+)r'r(z
 acls updatedz acls failed to update)�
isinstance�dictrr
r-)rr*r0rrrrrrr1r2r3r4r5rrrr*?sL8��


r*)NFFFrNNNNNN)rFNNNNNN)rNNNNNN)�__doc__rrr
r6r9r*rrrr�<module>sD	
�9
�_�