%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/haproxyconn.pyo

�
���^c@@s�dZddlmZmZmZmZddlZddlZddlZddl	Z	y"ddl
ZddlZe
ZWnek
r�eZnXeje�ZdZdZdddgZd	Zd
�Zed�Zeed�Zd
ded�Zed�Zed�Zed�Zed�Zded�Z ed�Z!ed�Z"ed�Z#ed�Z$e
ed�Z%ed�Z&dS(u1
Support for haproxy

.. versionadded:: 2014.7.0
i(tabsolute_importt
generatorstprint_functiontunicode_literalsNuhaproxyu/var/run/haproxy.sockuweightubinuboutunamecC@str
tStdfS(u9
    Only load the module if haproxyctl is installed
    uRThe haproxyconn execution module cannot be loaded: haproxyctl module not available(tHAS_HAPROXYt__virtualname__tFalse(((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyt__virtual__#scC@s(tj|�j}tjj|�}|S(u+
    Get connection to haproxy socket.
    (toststattst_modethaproxytconntHaPConn(tsockettissocktha_conn((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyt	_get_conn,scC@s4t|�}tjjd|�}|j|d|�S(u�
    List servers in haproxy backend.

    backend
        haproxy backend

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.list_servers mysql
    tbackendt	objectify(RRtcmdstlistServerstsendCmd(RRRRtha_cmd((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pytlist_servers7suupi<icC@s`tj�|}xItj�|kr[td|d|�|dj�|j�krtSqWtS(u�

    Wait for a specific server state

    backend
        haproxy backend

    server
        targeted server

    value
        state value

    timeout
        timeout before giving up state value, default 5 min

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.wait_state mysql server01 up 60
    RRustatus(ttimetget_backendtlowertTrueR(RtservertvaluettimeoutRtt((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyt
wait_stateLs
/cC@s�td|d|�jdd�jd�}i}d�}x�|D]�}d|krp|jdd�j�}q@n(|j�tkr�|}i||<q@n|tkr�|dkr�d|||<q�||�|||<q@||||<q@W|S(	u

    Receive information about a specific backend.

    backend
        haproxy backend

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.get_backend mysql
    RRu
u cS@s'yt|�SWntk
r"|SXdS(N(tintt
ValueError(ts((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pytnum�s
u:ui(RtreplacetsplitRtFIELD_NODE_NAMEt
FIELD_NUMERIC(RRtbackend_datatresultR%tdatatactive_fieldt
active_server((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyRms"*	

cC@s�|dkr'td|�jd�}n	|g}i}xX|D]P}t|�}tjjd|d|�}|j|�t|d|�||<q=W|S(uC
    Enable Server in haproxy

    name
        Server to enable

    backend
        haproxy backend, or all backends if "*" is supplied

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.enable_server web1.example.com www
    u*Ru
RR(t
show_backendsR'RRRtenableServerRR(tnameRRtbackendstresultsRR((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyt
enable_server�s	

cC@s�|dkr'td|�jd�}n	|g}i}xX|D]P}t|�}tjjd|d|�}|j|�t|d|�||<q=W|S(uH
    Disable server in haproxy.

    name
        Server to disable

    backend
        haproxy backend, or all backends if "*" is supplied

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.disable_server db1.example.com mysql
    u*Ru
RR(R/R'RRRt
disableServerRR(R1RRR2R3RR((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pytdisable_server�s	

cC@s4t|�}tjjd|d|�}|j|�S(u
    Get server weight

    name
        Server name

    backend
        haproxy backend

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.get_weight web1.example.com www
    RR(RRRt	getWeightR(R1RRRR((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyt
get_weight�scC@sMt|�}tjjd|d|d|�}|j|�t||d|�S(u5
    Set server weight

    name
        Server name

    backend
        haproxy backend

    weight
        Server Weight

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.set_weight web1.example.com www 13
    RRtweightR(RRRR7RR8(R1RR9RRR((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyt
set_weight�s!
cC@sPdtjjfd��Y}t|�}|d|d|d|�}|j|�S(u�
    Force a server's administrative state to a new state. This can be useful to
    disable load balancing and/or any traffic to a server. Setting the state to
    "ready" puts the server in normal mode, and the command is the equivalent of
    the "enable server" command. Setting the state to "maint" disables any traffic
    to the server as well as any health checks. This is the equivalent of the
    "disable server" command. Setting the mode to "drain" only removes the server
    from load balancing but still allows it to be checked and to accept new
    persistent connections. Changes are propagated to tracking servers if any.

    name
        Server name

    backend
        haproxy backend

    state
        A string of the state to set. Must be 'ready', 'drain', or 'maint'

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.set_state my_proxy_server my_backend ready

    tsetServerStatecB@s)eZdZdZdddgZdZRS(uSet server state command.u3set server %(backend)s/%(server)s state %(value)s
ubackenduserveruvalueu5Force a server's administrative state to a new state.(t__name__t
__module__t__doc__tcmdTxttp_argsthelpTxt(((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyR;8sRRR(RRtCmdRR(R1RtstateRR;RR((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyt	set_states cC@s(t|�}tjj�}|j|�S(u�
    Show HaProxy frontends

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.show_frontends
    (RRRt
showFrontendsR(RRR((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pytshow_frontendsCs
cC@std|�jd�S(u�

    List HaProxy frontends

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.list_frontends
    Ru
(RFR'(R((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pytlist_frontendsUscC@s(t|�}tjj�}|j|�S(u�
    Show HaProxy Backends

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.show_backends
    (RRRtshowBackendsR(RRR((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyR/fs
cC@sc|std|�jd�Si}x6tdtd|�D]}td|d|�||<q8W|SdS(u�

    List HaProxy Backends

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    servers
        list backends with servers

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.list_backends
    Ru
tserversRN(R/R't
list_backendsRR(RIRR+R((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyRJxsc	C@s�dtjjfd��Y}t|�}|d|d|�}|j|�}xP|jd�D]?}|j|�r\|jd�}|d|kr�|dSq\q\Wd	S(
u\
    .. versionadded:: 2016.11.0

    Get number of current sessions on server in backend (scur)

    name
        Server name

    backend
        haproxy backend

    socket
        haproxy stats socket, default ``/var/run/haproxy.sock``

    CLI Example:

    .. code-block:: bash

        salt '*' haproxy.get_sessions web1.example.com www
    tgetStatscB@s eZddgZdZdZRS(ubackenduserverushow stat
uFetch all statistics(R<R=R@R?thelpText(((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyRK�sRRu
u,iiN(RRRBRRR't
startswith(	R1RRRKRRR+tlinetoutCols((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pytget_sessions�si,('R>t
__future__RRRRRtloggingR	Rthaproxy.cmdsRthaproxy.connRRtImportErrorRt	getLoggerR<tlogRtDEFAULT_SOCKET_URLR)R(RRRR!RR4R6R8R:RDRFRGR/RJRP(((s</usr/lib/python2.7/site-packages/salt/modules/haproxyconn.pyt<module>s>"


		!1##+

Zerion Mini Shell 1.0