%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyc

�
���^c@@s�dZddlmZmZmZy"ddlZddlZeZ	Wne
k
r]eZ	nXddlZ
dZd�Zdd�Zddeeeddddddd�Zdddddddd	�Zddddddd
�Zddddddd�Zddddddd�Zd
ddddddd�Zddddddd�Zd
ddddddd�Zd
eddddddd�Zeeeeeed�ZdS(u
Zookeeper Module
~~~~~~~~~~~~~~~~
:maintainer:    SaltStack
:maturity:      new
:platform:      all
:depends:       kazoo

.. versionadded:: 2018.3.0

Configuration
=============

:configuration: This module is not usable until the following are specified
    either in a pillar or in the minion's config file:

    .. code-block:: yaml

        zookeeper:
          hosts: zoo1,zoo2,zoo3
          default_acl:
            - username: daniel
              password: test
              read: true
              write: true
              create: true
              delete: true
              admin: true
          username: daniel
          password: test

    If configuration for multiple zookeeper environments is required, they can
    be set up as different configuration profiles. For example:

    .. code-block:: yaml

        zookeeper:
          prod:
            hosts: zoo1,zoo2,zoo3
            default_acl:
              - username: daniel
                password: test
                read: true
                write: true
                create: true
                delete: true
                admin: true
            username: daniel
            password: test
          dev:
            hosts:
              - dev1
              - dev2
              - dev3
            default_acl:
              - username: daniel
                password: test
                read: true
                write: true
                create: true
                delete: true
                admin: true
            username: daniel
            password: test
i(tabsolute_importtprint_functiontunicode_literalsNu	zookeepercC@str
tStS(N(t	HAS_KAZOOt__virtualname__tFalse(((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyt__virtual__Ssc
@s�|rd|�nd�d��fd�}|dd�}|dd�}|dd�}|dd�}|d	d�}t|t�r�d
j|�}n|dk	r�|dk	r�|dkr�d}nd}|r|r|r|dj||g�fg}n|dk	rOt|t�r=g|D]}	t|	�^q"}qOt|�g}ntjd
i�j|pj|tjj	d|d|d|��td
|p�|j
s�td
|p�|j�ntd
|p�|S(Nu
zookeeper:u	zookeeperc@s/�j|�p.tddj�|g�|�S(uL
        look in connection_args first, then default to config file
        u
config.getu:(tgett__salt__tjoin(tkeytdefault(tconnection_argstprefix(s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyR_suhostsu127.0.0.1:2181uschemeuusernameupasswordudefault_aclu,udigestu:uzkconnectionthoststdefault_aclt	auth_data(tNonet
isinstancetlistR	tmake_digest_aclt__context__t
setdefaulttkazootclienttKazooClientt	connectedtstart(
tprofileRRRtschemetusernametpasswordRRtacl((RR
s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyt_get_zk_connYs6
$	!"
uc
C@s�|dkrg}ng|D]}t|�^q}td|d|d|d|	d|
d|�}
|
j|tjjj|�||||�S(u�
    Create Znode

    path
        path of znode to create

    value
        value to assign to znode (Default: '')

    acls
        list of acl dictionaries to be assigned (Default: None)

    ephemeral
        indicate node is ephemeral (Default: False)

    sequence
        indicate node is suffixed with a unique index (Default: False)

    makepath
        Create parent paths if they do not exist (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)

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.create /test/name daniel profile=prod

    RRRRRRN(RRR!tcreatetsalttutilststringutilstto_bytes(tpathtvaluetaclst	ephemeraltsequencetmakepathRRRRRRR tconn((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyR"�s0	c

C@sq|dkrg}ng|D]}t|�^q}td|d|d|d|d|d|�}	|	j||�S(u�
    Ensure Znode path exists

    path
        Parent path to create

    acls
        list of acls dictionaries to be assigned (Default: None)

    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)

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.ensure_path /test/name profile=prod

    RRRRRRN(RRR!tensure_path(
R'R)RRRRRRR R-((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyR.�s$	c
C@s@td|d|d|d|d|d|�}t|j|��S(ur
    Check if path exists

    path
        path to check

    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)

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.exists /test/name profile=prod

    RRRRRR(R!tbooltexists(R'RRRRRRR-((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyR0�s c

C@sUtd|d|d|d|d|d|�}|j|�\}}	tjjj|�S(us
    Get value saved in znode

    path
        path to check

    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)

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.get /test/name profile=prod

    RRRRRR(R!RR#R$R%tto_str(
R'RRRRRRR-trett_((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyRs c	
C@sFtd|d|d|d|d|d|�}|j|�}|pEgS(uy
    Get children in znode path

    path
        path to check

    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)

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.get_children /test profile=prod

    RRRRRR(R!tget_children(	R'RRRRRRR-R2((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyR45s i����c	

C@sRtd|d|d|d|d|d|�}	|	j|tjjj|�d|�S(u
    Update znode with new value

    path
        znode to update

    value
        value to set in znode

    version
        only update znode if version matches (Default: -1 (always matches))

    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)

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.set /test/name gtmanfred profile=prod

    RRRRRRtversion(R!tsetR#R$R%R&(
R'R(R5RRRRRRR-((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyR6[s'c
C@s>td|d|d|d|d|d|�}|j|�dS(us
    Get acls on a znode

    path
        path to znode

    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)

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.get_acls /test/name profile=prod

    RRRRRRi(R!tget_acls(R'RRRRRRR-((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyR7�s c	
C@s�td|d|d|d|d|d|�}	|dkrBg}ng|D]}
t|
�^qI}td|d|d|d|d|d|�}	|	j|||�S(uK
    Set acls on a znode

    path
        path to znode

    acls
        list of acl dictionaries to set on the znode

    version
        only set acls if version matches (Default: -1 (always matches))

    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)

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.set_acls /test/name acls='[{"username": "gtmanfred", "password": "test", "all": True}]' profile=prod

    RRRRRRN(R!RRtset_acls(R'R)R5RRRRRRR-R ((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyR8�s'	c	

C@s@td|d|d|d|d|d|�}	|	j|||�S(u�
    Delete znode

    path
        path to znode

    version
        only delete if version matches (Default: -1 (always matches))

    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)

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.delete /test/name profile=prod

    RRRRRR(R!tdelete(
R'R5t	recursiveRRRRRRR-((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyR9�s$c	C@s%tjj||||||||�S(u(
    Generate acl object

    .. note:: This is heavily used in the zookeeper state and probably is not useful as a cli module

    username
        username of acl

    password
        plain text password of acl

    read
        read acl

    write
        write acl

    create
        create acl

    delete
        delete acl

    admin
        admin acl

    allperms
        set all other acls to True

    CLI Example:

    .. code-block:: bash

        salt minion1 zookeeper.make_digest_acl username=daniel password=mypass allperms=True
    (RtsecurityR(RRtreadtwriteR"R9tadmintallperms((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyRs%(t__doc__t
__future__RRRtkazoo.clientRtkazoo.securitytTrueRtImportErrorRtsalt.utils.stringutilsR#RRRR!R"R.R0RR4R6R7R8R9R(((s:/usr/lib/python2.7/site-packages/salt/modules/zookeeper.pyt<module>Bs6


	-7+%&&+%0(

Zerion Mini Shell 1.0