%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlmZddl	Z
ddlZ
ddlm
Z
d�Zddded�Zd�Zd	�Zd
d�Zd�ZdS(
u�
Icinga2 state
=============

.. versionadded:: 2017.7.0

:depends:   - Icinga2 Python module
:configuration: See :py:mod:`salt.modules.icinga2` for setup instructions.

The icinga2 module is used to execute commands.
Its output may be stored in a file or in a grain.

.. code-block:: yaml

    command_id:
      icinga2.generate_ticket
        - name: domain.tld
        - output:  "/tmp/query_id.txt"
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tget_certs_pathcC@s
dtkS(uB
    Only load if the icinga2 module is available in __salt__
    uicinga2.generate_ticket(t__salt__(((s7/usr/lib/python2.7/site-packages/salt/states/icinga2.pyt__virtual__!sc
	C@s%i|d6id6td6dd6}|dkrE|r�|r�|rl|td�krldj|�|d<|Std	rBd|d<d
j|�|d<|Sq�|r*|td�kr�td|�}ni}|r�||kr�dj||�|d<|Std	rBd|d<d
j||�|d<|Sq�t|d<d|d<|Sn�|r�|r{tjj|�r{dj|�|d<|Std	r�d|d<dj|�|d<|Sn"td	r�d|d<d|d<|Std|�}|d}|dst	j
|�|d<n|dkr�|rI|rItd||�dj|�|dd<q!|r!|td�krutd|�}ni}|||<td||�dj||�|dd<q!nk|rdj|�|dd<tjj
j|d��#}	|	jtjjj|��WdQXnd|dd<|S(u8
    Generate an icinga2 ticket on the master.

    name
        The domain name for which this ticket will be generated

    output
        grain: output in a grain
        other: the file to store results
        None:  output to the result comment (default)

    grain:
        grain to store the output (need output=grain)

    key:
        the specified grain will be treated as a dictionary, the result
        of this state will be stored under the specified key.

    overwrite:
        The file or grain will be overwritten if it already exists (default)
    unameuchangesuresultuucommentugrainu	grains.lsu*No execution needed. Grain {0} already setutestuATicket generation would be executed, storing result in grain: {0}u
grains.getu.No execution needed. Grain {0}:{1} already setuETicket generation would be executed, storing result in grain: {0}:{1}u5Error: output type 'grain' needs the grain parameter
u)No execution needed. File {0} already setu@Ticket generation would be executed, storing result in file: {0}u7Ticket generation would be executed, not storing resultuicinga2.generate_ticketustdouturetcodeu
grains.setvalu Executed. Output into grain: {0}uticketu$Executed. Output into grain: {0}:{1}uExecuted. Output into {0}uwNuExecuted(tTrueRtformatt__opts__tNonetFalsetostpathtisfileRt	text_typetsalttutilstfilestfopentwritetstringutilstto_str(
tnametoutputtgraintkeyt	overwritetrettgrain_valuet
ticket_resttickettoutput_file((s7/usr/lib/python2.7/site-packages/salt/states/icinga2.pytgenerate_ticket(sx

















 %cC@si|d6id6td6dd6}djt�|�}djt�|�}tjj|�r�tjj|�r�dj||�|d<|Std	r�d|d<d
|d<|Std|�}|dsd
|d<dj|�|dd<dj|�|dd<n|S(u�
    Generate an icinga2 certificate and key on the client.

    name
        The domain name for which this certificate and key will be generated
    unameuchangesuresultuucommentu
{0}{1}.crtu
{0}{1}.keyu>No execution needed. Cert: {0} and key: {1} already generated.utestu0Certificate and key generation would be executeduicinga2.generate_certuretcodeuCertificate and key generatedu Executed. Certificate saved: {0}ucertuExecuted. Key saved: {0}ukeyN(	RRRRR
RR	R
R(RRtcertRt	cert_save((s7/usr/lib/python2.7/site-packages/salt/states/icinga2.pyt
generate_cert�s&

$




cC@s�i|d6id6td6dd6}djt��}tjj|�r]dj|�|d<|Stdrd|d<d	|d<|Std
||�}|ds�d|d<d
j|�|dd<n|S(u�
    Save the certificate on master icinga2 node.

    name
        The domain name for which this certificate will be saved

    master
        Icinga2 master node for which this certificate will be saved
    unameuchangesuresultuucommentu{0}trusted-master.crtu-No execution needed. Cert: {0} already saved.utestu5Certificate save for icinga2 master would be executeduicinga2.save_certuretcodeu$Certificate for icinga2 master savedu Executed. Certificate saved: {0}ucertN(	RRRRR
RR	R
R(RtmasterRR"R#((s7/usr/lib/python2.7/site-packages/salt/states/icinga2.pyt	save_cert�s"







u5665cC@s�i|d6id6td6dd6}djt��}tjj|�r]dj|�|d<|Stdrd|d<d	|d<|Std
||||�}|ds�d|d<d
j|�|dd<|Sdj|d�|d<t	|d<|S(uM
    Request CA certificate from master icinga2 node.

    name
        The domain name for which this certificate will be saved

    master
        Icinga2 master node for which this certificate will be saved

    ticket
        Authentication ticket generated on icinga2 master

    port
        Icinga2 port, defaults to 5665
    unameuchangesuresultuucommentu	{0}ca.crtu.No execution needed. Cert: {0} already exists.utestu9Certificate request from icinga2 master would be executeduicinga2.request_certuretcodeu0Certificate request from icinga2 master executedu$Executed. Certificate requested: {0}ucertu5FAILED. Certificate requested failed with output: {0}ustdoutN(
RRRRR
RR	R
RR(RR%RtportRR"tcert_request((s7/usr/lib/python2.7/site-packages/salt/states/icinga2.pytrequest_cert�s(







cC@si|d6id6td6dd6}djt�|�}djt�|�}tjj|�r~tjj|�r~d|d<|Std	r�d|d<d
|d<|Std|||�}|ds�d
|d<d|dd<|Sdj|d�|d<t	|d<|S(u
    Setup the icinga2 node.

    name
        The domain name for which this certificate will be saved

    master
        Icinga2 master node for which this certificate will be saved

    ticket
        Authentication ticket generated on icinga2 master
    unameuchangesuresultuucommentu{0}{1}.crt.origu{0}{1}.key.origu-No execution needed. Node already configured.utestuNode setup will be executed.uicinga2.node_setupuretcodeuNode setup executed.u!Node setup finished successfully.ucertu)FAILED. Node setup failed with outpu: {0}ustdoutN(
RRRRR
RR	R
RR(RR%RRR"Rt
node_setup((s7/usr/lib/python2.7/site-packages/salt/states/icinga2.pyR*�s*

$






(t__doc__t
__future__RRRtos.pathRtsalt.extRtsalt.utils.filesRtsalt.utils.stringutilstsalt.utils.icinga2RRR
RR!R$R&R)R*(((s7/usr/lib/python2.7/site-packages/salt/states/icinga2.pyt<module>s	^	 	!+

Zerion Mini Shell 1.0