Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/clustering/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/clustering/consul_session.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zy&dd
l	Z	ddl
mZeZ
Wnek
r�eZ
nXddlmZd
�Zd�Zd�Zd�Zd�Zd�Zd�Zedkr�e�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys?

module: consul_session
short_description: Manipulate consul sessions
description:
 - Allows the addition, modification and deletion of sessions in a consul
   cluster. These sessions can then be used in conjunction with key value pairs
   to implement distributed locks. In depth documentation for working with
   sessions can be found at http://www.consul.io/docs/internals/sessions.html
requirements:
  - python-consul
  - requests
version_added: "2.0"
author:
- Steve Gargan (@sgargan)
options:
    id:
        description:
          - ID of the session, required when I(state) is either C(info) or
            C(remove).
        type: str
    state:
        description:
          - Whether the session should be present i.e. created if it doesn't
            exist, or absent, removed if present. If created, the I(id) for the
            session is returned in the output. If C(absent), I(id) is
            required to remove the session. Info for a single session, all the
            sessions for a node or all available sessions can be retrieved by
            specifying C(info), C(node) or C(list) for the I(state); for C(node)
            or C(info), the node I(name) or session I(id) is required as parameter.
        choices: [ absent, info, list, node, present ]
        type: str
        default: present
    name:
        description:
          - The name that should be associated with the session. Required when
            I(state=node) is used.
        type: str
    delay:
        description:
          - The optional lock delay that can be attached to the session when it
            is created. Locks for invalidated sessions ar blocked from being
            acquired until this delay has expired. Durations are in seconds.
        type: int
        default: 15
    node:
        description:
          - The name of the node that with which the session will be associated.
            by default this is the name of the agent.
        type: str
    datacenter:
        description:
          - The name of the datacenter in which the session exists or should be
            created.
        type: str
    checks:
        description:
          - Checks that will be used to verify the session health. If
            all the checks fail, the session will be invalidated and any locks
            associated with the session will be release and can be acquired once
            the associated lock delay has expired.
        type: list
    host:
        description:
          - The host of the consul agent defaults to localhost.
        type: str
        default: localhost
    port:
        description:
          - The port on which the consul agent is running.
        type: int
        default: 8500
    scheme:
        description:
          - The protocol scheme on which the consul agent is running.
        type: str
        default: http
        version_added: "2.1"
    validate_certs:
        description:
          - Whether to verify the TLS certificate of the consul agent.
        type: bool
        default: True
        version_added: "2.1"
    behavior:
        description:
          - The optional behavior that can be attached to the session when it
            is created. This controls the behavior when a session is invalidated.
        choices: [ delete, release ]
        type: str
        default: release
        version_added: "2.2"
s�
- name: register basic session with consul
  consul_session:
    name: session1

- name: register a session with an existing check
  consul_session:
    name: session_with_check
    checks:
      - existing_check_name

- name: register a session with lock_delay
  consul_session:
    name: session_with_delay
    delay: 20s

- name: retrieve info about session by id
  consul_session:
    id: session_id
    state: info

- name: retrieve active sessions
  consul_session:
    state: list
N(tConnectionError(t
AnsibleModulecC`sR|jjd�}|dkr+t|�n#|dkrDt|�n
t|�dS(Ntstatetinfotlisttnodetpresent(sinfoslistsnode(tparamstgettlookup_sessionstupdate_sessiontremove_session(tmoduleR
((sM/usr/lib/python2.7/site-packages/ansible/modules/clustering/consul_session.pytexecute�s

c
C`sk|jjd�}|jjd�}t|�}y
|dkr�|jjd|�}|ryt|�dkry|d}n|jdtd|�n�|d	kr�|jjd	�}|jj|d|�}|jdtd	|d|�nU|d
kr<|jjd�}|jj	|d|�}|jdtd|d|�nWn't
k
rf}	|jd
d|	�nXdS(Nt
datacenterR
RtdciitchangedtsessionsR
Rtidt
session_idtmsgs"Could not retrieve session info %s(RRtget_consul_apitsessionRtlent	exit_jsontTrueR
Rt	Exceptiont	fail_json(
RRR
t
consul_clientt
sessions_listR
RRt
session_by_idte((sM/usr/lib/python2.7/site-packages/ansible/modules/clustering/consul_session.pyR�s0


c
C`s|jjd�}|jjd�}|jjd�}|jjd�}|jjd�}|jjd�}t|�}yk|jjd|d|d|d|d|d|�}|jd	td
|d|d|d|d|d|�Wn'tk
r}	|jdd|	�nXdS(
NtnametdelaytchecksRR
tbehaviort
lock_delayRRRRs"Could not create/update session %s(	RRRRtcreateR R!R"R#(
RR(R)R*RR
R+R$RR'((sM/usr/lib/python2.7/site-packages/ansible/modules/clustering/consul_session.pyR�s0	cC`s||jjd�}t|�}y*|jj|�|jdtd|�Wn-tk
rw}|jdd||f�nXdS(NRRRRs(Could not remove session with id '%s' %s(	RRRRtdestroyR R!R"R#(RRR$R'((sM/usr/lib/python2.7/site-packages/ansible/modules/clustering/consul_session.pyR�sc
C`sRtjd|jjd�d|jjd�d|jjd�d|jjd��S(Nthosttporttschemetverifytvalidate_certs(tconsultConsulRR(R((sM/usr/lib/python2.7/site-packages/ansible/modules/clustering/consul_session.pyR�scC`sts|jdd�ndS(NRshpython-consul required for this module. see https://python-consul.readthedocs.io/en/latest/#installation(tpython_consul_installedR#(R((sM/usr/lib/python2.7/site-packages/ansible/modules/clustering/consul_session.pyttest_dependencies�sc!C`s�tdtdd�dtdddd�dtdd	dd
dd
dg�d
tdd	dd�dtdddd�dtdd	dd�dtdddt�dtdd	�dtdd	�dtdd	�dtdd	ddddddddg�dtdd	��}td|ddddgfdddgfdddgfgd t�}t|�yt|�Wnptk
r�}|jd!d"|jj	d
�|jj	d�|f�n)t
k
r�}|jd!t|��nXdS(#NR*ttypeRR)tinttdefaultt15R+tstrtreleasetchoicestdeleteR/t	localhostR0i4!R1thttpR3tboolRR(R
R
RtabsentRRt
argument_spectrequired_iftremovetsupports_check_modeRs8Could not connect to consul agent at %s:%s, error was %s(tdictR!R	tFalseR7RRR#RRR"R<(RDRR'((sM/usr/lib/python2.7/site-packages/ansible/modules/clustering/consul_session.pytmain�s6!*	
,t__main__(t
__future__RRRR8t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR4trequests.exceptionsRR!R6tImportErrorRItansible.module_utils.basicR	RRRRRR7RJt__name__(((sM/usr/lib/python2.7/site-packages/ansible/modules/clustering/consul_session.pyt<module>s,


]


		 					%

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]