%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/syslog_ng.pyc

�
���^c@�sVdZddlmZmZmZmZmZddlZddlZddl	Z	ddl
Z
ddlZ
ddlZ	ddl
Z	ddlmZddlmZddlmZdadadZd	efd
��YZeje�Zejej�idd6Zd
a dZ!da"da#da$da%d�Z&d�Z'd�Z(d�Z)de*fd��YZ+de+fd��YZ,de,fd��YZ-de,fd��YZ.de+fd��YZ/de+fd��YZ0de+fd ��YZ1d!e1fd"��YZ2d#e1fd$��YZ3d%e+fd&��YZ4d'e4fd(��YZ5d)e4fd*��YZ6d+e*fd,��YZ7d-�Z8d.�Z9d/�Z:d0�Z;d1�Z<d2�Z=d3�Z>d4�Z?d5�Z@d6�ZAd7�ZBd8�ZCd9�ZDd:�ZEd;�ZFd<�ZGd=�ZHd>�ZIeJd?�ZKd@�ZLdA�ZMdB�ZNdXddC�ZOdD�ZPddddE�ZQdF�ZRdddG�ZSdddH�ZTddI�ZUddJ�ZVddK�ZWd
d
dL�ZXdd
dM�ZYdN�ZZdO�Z[ddP�Z\ddddde]de]de]e]e]e]ddddQ�Z^dR�Z_dS�Z`dTdU�ZadTdV�ZbdW�ZcdS(Yu�
Module for getting information about syslog-ng

:maintainer:    Tibor Benke <btibi@sch.bme.hu>
:maturity:      new
:depends:       cmd
:platform:      all

This module is capable of managing syslog-ng instances which were installed
via a package manager or from source. Users can use a directory as a parameter
in the case of most functions, which contains the syslog-ng and syslog-ng-ctl
binaries.

Syslog-ng can be installed via a package manager or from source. In the
latter case, the syslog-ng and syslog-ng-ctl binaries are not available
from the PATH, so users should set location of the sbin directory with
:mod:`syslog_ng.set_binary_path <salt.modules.syslog_ng.set_binary_path>`.

Similarly, users can specify the location of the configuration file with
:mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, then
the module will use it. If it is not set, syslog-ng uses the default
configuration file.


i(tabsolute_importt
generatorstwith_statementtunicode_literalstprint_functionN(tCommandExecutionError(tsix(trangeu/etc/syslog-ng.confu#Generated by Salt on {0}t
SyslogNgErrorcB�seZRS((t__name__t
__module__(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR4sureloadureload_uu    cC�stt7adS(u*
    Increases the indentation level.
    N(t_INDENTt_INDENT_STEP(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_increase_indentJscC�stdadS(u*
    Decreases the indentation level.
    iN(R(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_decrease_indentRscC�sdjt|�S(u)
    Returns the indented parameter.
    u{0}{1}(tformatR(tvalue((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_indentZscC�st|d�S(u5
    Return the indented parameter with newline.
    u
(R(tstring((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt	_indentlnast	BuildablecB�sAeZdZded�Zd�Zd�Zd�Zd�ZRS(u�
    Base class of most classes, which have a build method.

    It contains a common build function.

    Does not need examples.
    ucC�s||_||_||_dS(N(titerabletjoin_body_ontappend_extra_newline(tselfRRR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt__init__qs		cC�sdS(uH
        Builds the header of a syslog-ng configuration object.
        u((R((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytbuild_headervscC�sdS(uF
        Builds the tail of a syslog-ng configuration object.
        u((R((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt
build_tail|scC�s}t�g|jD]}|j�^q}|jr8dnd}t|j�dkrl|jj|�|}nd}t�|S(uF
        Builds the body of a syslog-ng configuration object.
        u
ui(R
RtbuildRtlenRtjoinR(Rtxt
body_arraytnltbody((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt
build_body�s"cC�s0|j�}|j�}|j�}|||S(uq
        Builds the textual representation of the whole configuration object
        with it's children.
        (RR#R(RtheaderR"ttail((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�s(	R	R
t__doc__tTrueRRRR#R(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyRhs			t	StatementcB�s;eZdZdded�Zd�Zd�Zd�ZRS(u
    It represents a syslog-ng configuration statement, e.g. source, destination,
    filter.

    Does not need examples.
    ucC�sbtt|�j|dddt�||_||_|r@|ng|_|j|_||_dS(NRuR(	tsuperR(RtFalsettypetidtoptionsRthas_name(RR+R,R-R.((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�s		cC�s?|jr%tdj|j|j��Stdj|j��SdS(Nu
{0} {1} {{u{0} {{(R.RRR+R,(R((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�s	cC�s
td�S(Nu};(R(R((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�scC�s|jj|�dS(N(R-tappend(Rtoption((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt	add_child�sN(	R	R
R&tNoneR'RRRR1(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR(�s

		tNamedStatementcB�seZdZddd�ZRS(up
    It represents a configuration statement, which has a name, e.g. a source.

    Does not need examples.
    ucC�s&tt|�j|||dt�dS(NR.(R)R3RR'(RR+R,R-((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�sN(R	R
R&R2R(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR3�stUnnamedStatementcB�seZdZdd�ZRS(u
    It represents a configuration statement, which doesn't have a name, e.g. a
    log path.

    Does not need examples.
    cC�s,tt|�j|ddd|dt�dS(NR,uR-R.(R)R4RR*(RR+R-((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�sN(R	R
R&R2R(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR4�stGivenStatementcB�s#eZdZed�Zd�ZRS(u�
    This statement returns a string without modification. It can be used to
     use existing configuration snippets.

    Does not need examples.
    cC�s/tt|�jdd�||_||_dS(NR(R)R5RR2Rtadd_newline(RRR6((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�s	cC�s|jr|jdS|jSdS(Nu
(R6R(R((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�s	(R	R
R&R'RR(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR5�stOptioncB�s/eZdZddd�Zd�Zd�ZRS(u�
    A Statement class contains Option instances.

    An instance of Option can represent a file(), tcp(), udp(), etc.  option.

    Does not need examples.
    ucC�sGtt|�j|d�||_|r.|ng|_|j|_dS(Nu,
(R)R7RR+tparamsR(RR+R8((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�s	cC�s<tdj|j��}td�}|j�}|||S(Nu{0}(u);(RRR+R#(RR$R%R"((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�scC�s|jj|�dS(N(R8R/(Rtparam((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt
add_parametersN(R	R
R&R2RRR:(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR7�s	t	ParametercB�seZdZddd�ZRS(uU
    An Option has one or more Parameter instances.

    Does not need examples.
    ucC�stt|�j||�dS(N(R)R;R(RRR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyRsN(R	R
R&R2R(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR;stSimpleParametercB�s#eZdZdd�Zd�ZRS(uB
    A Parameter is a SimpleParameter, if it's just a simple type, like a
    string.

    For example:

    .. code-block:: text

        destination d_file {
            file(
                '/var/log/messages'
            );
        };

    ``/var/log/messages`` is a SimpleParameter.

    Does not need examples.
    ucC�s tt|�j�||_dS(N(R)R<RR(RR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR#scC�s
t|j�S(N(RR(R((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR's(R	R
R&RR(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR<stTypedParametercB�s/eZdZddd�Zd�Zd�ZRS(u�
    A Parameter, which has a type:

    .. code-block:: text

        destination d_tcp {
            tcp(
                ip(127.0.0.1)
            );
        };

    ``ip(127.0.0.1)`` is a TypedParameter.

    Does not need examples.
    ucC�sGtt|�j|d�||_|r.|ng|_|j|_dS(Nu,
(R)R=RR+tvaluesR(RR+R>((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR<s	cC�s<tdj|j��}td�}|j�}|||S(Nu{0}(u)(RRR+RR#(RR$R%R"((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyRBscC�s|jj|�dS(N(R>R/(RR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt	add_valueIsN(R	R
R&R2RRR?(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR=+s	tParameterValuecB�seZdZddd�ZRS(uT
    A TypedParameter can have one or more values.

    Does not need examples.
    ucC�stt|�j||�dS(N(R)R@R(RRR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyRTsN(R	R
R&R2R(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR@MstSimpleParameterValuecB�s#eZdZdd�Zd�ZRS(u�
    A ParameterValuem which holds a simple type, like a string or a number.

    For example in ip(127.0.0.1) 127.0.0.1 is a SimpleParameterValue.

    Does not need examples.
    ucC�s tt|�j�||_dS(N(R)RARR(RR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyRascC�s
t|j�S(N(RR(R((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyRes(R	R
R&RR(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyRAXstTypedParameterValuecB�s/eZdZddd�Zd�Zd�ZRS(u
    We have to go deeper...

    A TypedParameter can have a 'parameter', which also have a type. For example
    key_file and cert_file:

    .. code-block:: text

        source demo_tls_source {
            tcp(
                ip(0.0.0.0)
                port(1999)
                tls(
                    key_file('/opt/syslog-ng/etc/syslog-ng/key.d/syslog-ng.key')
                    cert_file('/opt/syslog-ng/etc/syslog-ng/cert.d/syslog-ng.cert')
                )
            );
        };

    Does not need examples.
    ucC�sGtt|�j|d�||_|r.|ng|_|j|_dS(Nu
(R)RBRR+t	argumentsR(RR+RC((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�s	cC�s<tdj|j��}td�}|j�}|||S(Nu{0}(u)(RRR+RR#(RR$R%R"((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�scC�s|jj|�dS(N(RCR/(Rtarg((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytadd_argument�sN(R	R
R&R2RRRE(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyRBis	tArgumentcB�s#eZdZdd�Zd�ZRS(u�
    A TypedParameterValue has one or more Arguments. For example this can be
    the value of key_file.

    Does not need examples.
    ucC�s
||_dS(N(R(RR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�scC�s
t|j�S(N(RR(R((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�s(R	R
R&RR(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyRF�scC�s
|dkS(ub
    Returns True, if the given statement is an unnamed statement, like log or
    junction.

    uloguchannelujunctionuoptions(uloguchannelujunctionuoptions((t	statement((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_is_statement_unnamed�scC�s=t|tj�p<t|t�p<t|t�p<t|t�S(uj
    Returns True, if the given parameter value is an instance of either
    int, str, float or bool.
    (t
isinstanceRtstring_typestinttfloattbool(R((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_is_simple_type�scC�s_d|kr-|jd�\}}}|}n%ttj|��}|}||}|||fS(uD
    Returns the type, id and option of a configuration object.
    u.(t	partitiontnextRtiterkeys(tnamet
configurationttype_tseptid_R-((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_get_type_id_options�s	
cC�s)ttj|��}||}||fS(uD
    Returns the only one key and it's value from a dictionary.
    (RPRRQ(t_dicttkeyR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_expand_one_key_dictionary�s
cC�s�t|�\}}|t_t|�rCt|�}tj|�n<t|t�rx*|D]}t|�}tj|�qYWndS(u5
    Creates Arguments in a TypedParametervalue.
    N(RZt_current_parameter_valueR+RNRFRERItlist(R>RTRRDtidx((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt"_parse_typed_parameter_typed_value�s	
cC�s�t|�\}}|t_t|�rO|dkrOt|�atjt�n}t|t�r�xk|D]`}t|�r�t|�atjt�qet|t	�ret
�at|�tjt�qeqeWndS(u;
    Parses a TypedParameter and fills it with values.
    uN(RZt_current_parameterR+RNRAR[R?RIR\tdictRBR^(R9RTRti((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_parse_typed_parameter�s	
	
cC�sxt|�r(t|�atjt�nLxI|D]A}t|�rPt|�ant�at|�tjt�q/WdS(uC
    Parses the configuration and creates Parameter instances.
    N(RNR<R_t_current_optionR:R=Rb(R8Ra((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_create_and_add_parameters�s
	
cC�s?t�at|�\}}|t_t|�tjt�dS(uB
    Parses the configuration and creates an Option instance.
    N(R7RcRZR+Rdt_current_statementR1(R0RTR8((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_create_and_add_options
		
cC�sx|D]}t|�qWdS(uE
    Parses the configuration and creates options the statement.
    N(Rf(R-R0((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_parse_statements
cC�s@t|t�o?t|�dko?tttj|��tj�S(uO
    Return True, if arg is a reference to a previously defined statement.
    i(RIR`RRPRt
itervaluesRJ(RD((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt
_is_referencescC�s:t|t�o9t|�dko9ttj|��dkS(u6
    Return True, if arg is a junction statement.
    iujunction(RIR`RRPRRQ(RD((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_is_junctionscC�sHt|�\}}t|�}t|�}|j|�|j|�dS(u(
    Adds a reference to statement.
    N(RZR7R<R:R1(t	referenceRGRTRtoptR9((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_add_reference&s

cC�s=t|t�o<t|�dko<tttj|��t�S(uF
    Returns True, if arg is an inline definition of a statement.
    i(RIR`RRPRRhR\(RD((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_is_inline_definition1scC�sHt}t|�\}}td|�at|�|jt�|adS(u1
    Adds an inline definition to statement.
    R+N(ReRZR4RgR1(titemRGtbackupRTR-((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_add_inline_definition8s

cC�s�t|�\}}tdd�}x�|D]}}t|�\}}tdd�}xF|D]>}t|�rxt||�qVt|�rVt||�qVqVW|j|�q(Wtj|�dS(u4
    Adds a junction to the _current_statement.
    R+ujunctionuchannelN(RZR4RiRmRnRqR1Re(RoRTtchannelstjunctionRtchanneltval((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt
_add_junctionGs

cC�sfx_|D]W}t|�r)t|t�qt|�rBt|�qt|�rt|t�qqWdS(u
    Parses a log path.
    N(RiRmReRjRvRnRq(R-Ra((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_parse_log_statementYs

cC�s�t||�\}}}da|dkr9t|�ane|dkratdd�at|�n=t|�rtd|�antd|d|�at|�dS(uS
    Build the configuration tree.

    The root object is _current_statement.
    uuconfigulogR+R,N(	RWRR5ReR4RwRHR3Rg(RRRSRTRVR-((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_build_config_treefs
cC�stj�}d}|S(uO
    Renders the configuration tree into syslog-ng's configuration syntax.
    u(ReR(t	text_reprR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_render_configuration|scC�s�t||�t�}tjdt�rPdj|t�}t|dd
d|�S|}|rnt	d|�}nt|d|di|d6dd	6�S(u�
    Builds syslog-ng configuration. This function is intended to be used from
    the state module, users should not use it directly!

    name : the id of the Salt document or it is the format of <statement name>.id
    config : the parsed YAML code
    write : if True, it writes  the config into the configuration file,
    otherwise just returns it

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.config name='s_local' config="[{'tcp':[{'ip':'127.0.0.1'},{'port':1233}]}]"

    utestu)State syslog_ng will write '{0}' into {1}tresulttcommenttconfigtchangesunewuuoldN(
RxRzt__opts__tgetR*Rt__SYSLOG_NG_CONFIG_FILEt_format_state_resultR2t
_write_config(RRR}twritetconfigsR|tsucc((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR}�s
		cC�s1t}|at||�}t|dtd|�S(u@
    Sets the path, where the syslog-ng binary can be found. This function is
    intended to be used from states.

    If syslog-ng is installed via a package manager, users don't need to use
    this function.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.set_binary_path name=/usr/sbin

    R{R~(t__SYSLOG_NG_BINARY_PATHt_format_changesR�R'(RRtoldR~((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytset_binary_path�scC�s1t}|at||�}t|dtd|�S(u�
    Sets the configuration's name. This function is intended to be used from
    states.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.set_config_file name=/etc/syslog-ng

    R{R~(R�R�R�R'(RRR�R~((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytset_config_file�s
cC�stS(u�
    Returns the configuration directory, which contains syslog-ng.conf.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.get_config_file

    (R�(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytget_config_file�scC�s0|g}|j|�td|d|dt�S(um
    Runs the command cmd with options as its CLI parameters and returns the
    result as a dictionary.
    ucmd.run_alltenvtpython_shell(textendt__salt__R*(tcmdR-R�R8((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_run_command�s	
cC�sqt|�}|d}d}xJt|�D]<\}}|dkrN|d}n|dkr)|d|!Sq)W|d S(Nustdoutiu.iii(tversiont	enumerate(tsyslog_ng_sbin_dirtrettfull_versiont	dot_countR]tpart((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_determine_config_version�s

cO�sO|rt|�n|r&t|�n|rEtt�}t|�ntd�S(u
    Sets variables.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.set_parameters version='3.6'
        salt '*' syslog_ng.set_parameters  binary_path=/home/user/install/syslog-ng/sbin config_file=/home/user/install/syslog-ng/etc/syslog-ng.conf

    i(R�R�R�R�t
write_versiont_format_return_data(R�tbinary_pathtconfig_filetargstkwargs((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytset_parameters�s


cC�s}tjjdd�}d}|rgitjjjtjj	tjj
j||f���td�6}nt
|d|d|�S(uL
    Runs the specified command with the syslog_ng_sbin_dir in the PATH
    uPATHuR-R�N(tostenvironR�R2tsalttutilststringutilstto_strtpathsepRtdatatdecodetstrR�(R�tcommandR8t	orig_pathR�((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_run_command_in_extended_paths	"cC�sCi|d6}|dk	r&||d<n|dk	r?||d<n|S(ua
    Creates a dictionary from the parameters, which can be used to return data
    to Salt.
    uretcodeustdoutustderrN(R2(tretcodetstdouttstderrR�((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�*s


cC�s�dg}|r(|jdj|��nyt|d|�}Wn,tk
rl}tdddtj|��SX|jdd�}|jdd
�}|jd	d
�}t|||�S(u�
    Runs syntax check against cfgfile. If syslog_ng_sbin_dir is specified, it
    is added to the PATH during the test.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.config_test
        salt '*' syslog_ng.config_test /home/user/install/syslog-ng/sbin
        salt '*' syslog_ng.config_test /home/user/install/syslog-ng/sbin /etc/syslog-ng/syslog-ng.conf
    u
--syntax-onlyu
--cfgfile={0}u	syslog-ngR�i����R�uretcodeustderrustdoutN(	R/RR�RR�Rt	text_typeR�R2(R�tcfgfileR8R�terrR�R�R�((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytconfig_test7s
	
cC�s�yt|dd
�}Wn,tk
rD}tdddtj|��SX|ddkrwt|dd|dd	|d
�S|d
jd�}d}d}||j�|}tdd	|�S(uA
    Returns the version of the installed syslog-ng. If syslog_ng_sbin_dir is
    specified, it is added to the PATH during the execution of the command
    syslog-ng.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.version
        salt '*' syslog_ng.version /home/user/install/syslog-ng/sbin
    u	syslog-ngu-VR�i����R�uretcodeiustderrR�ustdoutu
i(u-V(R�RR�RR�tsplit(R�R�R�tlinestversion_line_indextversion_column_indextline((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�Us



cC�s�yt|dd�}Wn,tk
rD}tdddtj|��SX|ddkr{t|d|jd�|jd	��S|djd
�}xC|D];}|jd�r�|j�\}}t|dd|�Sq�Wtddd
�S(u,
    Returns the available modules. If syslog_ng_sbin_dir is specified, it
    is added to the PATH during the execution of the command syslog-ng.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.modules
        salt '*' syslog_ng.modules /home/user/install/syslog-ng/sbin
    u	syslog-ngu-VR�i����R�uretcodeiustdoutustderru
uAvailable-ModulesR�uUnable to find the modules.(u-V(R�RR�RR�R�R�t
startswith(R�R�R�R�R�tlabeltinstalled_modules((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytmodulesws"



cC�skyt|dd	�}Wn,tk
rD}tdddtj|��SXt|d|jd�|jd��S(
uI
    Returns statistics from the running syslog-ng instance. If
    syslog_ng_sbin_dir is specified, it is added to the PATH during the
    execution of the command syslog-ng-ctl.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.stats
        salt '*' syslog_ng.stats /home/user/install/syslog-ng/sbin
    u
syslog-ng-ctlustatsR�i����R�uretcodeustdoutustderr(ustats(R�RR�RR�R�(R�R�R�((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytstats�s


cC�si|d6|d6S(Nuoldunew((R�tnew((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR��scC�sC|dkr#idd6dd6}ni|d6|d6|d6|d6S(	u.
    Creates the state result dictionary.
    uuoldunewunameuresultuchangesucommentN(R2(RRR{R~R|((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR��scC�s,|dk	r(|jdj||��ndS(uC
    Adds key and value as a command line parameter to params.
    u	--{0}={1}N(R2R/R(R8RYR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_add_cli_param�scC�s)|tkr%|jdj|��ndS(u9
    Adds key as a command line parameter to params.
    u--{0}N(R'R/R(R8RYR((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_add_boolean_cli_param�scC�s�tddd�}|dks1t|�dkrGt|dtdd�Stjdt�rud	}t|ddd|�Std
d�}|d}||kr�i|d6gd
6}t|dtd|�St|dt�SdS(u�
    Kills syslog-ng. This function is intended to be used from the state module.

    Users shouldn't use this function, if the service module is available on
    their system.  If :mod:`syslog_ng.set_config_file
    <salt.modules.syslog_ng.set_binary_path>` is called before, this function
    will use the set binary path.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.stop

    ups.pgreptpatternu	syslog-ngiR{R|uSyslog-ng is not runningutestu)Syslog_ng state module will kill {0} pidsups.pkillukilleduoldunewR~N(R�R2RR�R*RR�R'(RRtpidsR|trestkilled_pidsR~((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytstop�s	
cC�s$g}t|d|�t|d|�t|d|�t|d|�t|d|�t|d|�t|d|�t|d|�t|d	|	�t|d
|
�t|d|�t|d|�t|d
t�t|d|
�t|d|�t|d|�tr~tjjtd�}|g|}tjdt	�redj
|�}t|ddd|�St
d|dt	�}nZdg|}tjdt	�r�dj
|�}t|ddd|�St
d|dt	�}|ddkr�t}nt	}t|d|didj|�d6dd6�S( u�
    Ensures, that syslog-ng is started via the given parameters. This function
    is intended to be used from the state module.

    Users shouldn't use this function, if the service module is available on
    their system. If :mod:`syslog_ng.set_config_file
    <salt.modules.syslog_ng.set_binary_path>`, is called before, this function
    will use the set binary path.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.start

    uuserugroupuchrootucapsuno-capseupidfileuenable-coreufd-limituverboseudebugutraceuyydebugucfgfileupersist-fileucontroluworker-threadsu	syslog-ngutestu%Syslog_ng state module will start {0}R{R|ucmd.run_allR�upidiR~u unewuuoldN(R�R�R�R�R�tpathRRR�R*RR�R2R�R'(RRtusertgrouptchroottcapstno_capstpidfiletenable_coretfd_limittverbosetdebugttracetyydebugtpersist_filetcontroltworker_threadsR8tsyslog_ng_binaryR�R|R{R�((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytstart�sD 

	cC�s�tr@tjjtd�}|dg}td|dt�}n"ddg}td|dt�}|ddkrxtnt}t|d|d|d	�S(
u7
    Reloads syslog-ng. This function is intended to be used from states.

    If :mod:`syslog_ng.set_config_file
    <salt.modules.syslog_ng.set_binary_path>`, is called before, this function
    will use the set binary path.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.reload

    u
syslog-ng-ctlureloaducmd.run_allR�uretcodeiR{R|ustdout(R�R�R�RR�R*R'R�(RRtsyslog_ng_ctl_binaryR�R{R�((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytreload_As	cC�stjd�}tj|�S(uF
    Formats a header, which is prepended to all appended config.
    u%Y-%m-%d %H:%M:%S(ttimetstrftimet__SALT_GENERATED_CONFIG_HEADERR(tnow((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt_format_generated_config_header]sicC�s7t||�}td|�}tddd|d|�S(uy
    Writes the given parameter config into the config file. This function is
    intended to be used from states.

    If :mod:`syslog_ng.set_config_file
    <salt.modules.syslog_ng.set_config_file>`, is called before, this function
    will use the set config file.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.write_config config='# comment'

    R�RRuR{R~(R�R�R�(R}tnewlinesR�R~((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pytwrite_configesc	C�s
|}t|t�r[ttt|j����dkr[ttj|��}||}ny~tj	j
jtd��\}|j
tj	jj|��x6td|�D]%}|j
tj	jjtj��q�WWdQXtSWn*tk
r}tjtj|��tSXdS(uA
    Writes the given parameter config into the config file.
    iuaiN(RIR`RR\tkeysRPRRQR�R�tfilestfopenR�R�R�R�RR�tlinesepR't	ExceptiontlogterrorR�R*(R}R�ttextRYtfhat_R�((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR�zs3
)cC�s�dj|�}y�tjjt�rQtjdt�tjt�tjd�nt�}t	d|dd�t	d|dd�t
|dt�SWn3tk
r�}tj
d	t|�t
|dt�SXd
S(u�
    Removes the previous configuration file, then creates a new one and writes
    the name line. This function is intended to be used from states.

    If :mod:`syslog_ng.set_config_file
    <salt.modules.syslog_ng.set_config_file>`, is called before, this function
    will use the set config file.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.write_version name="3.6"

    u
@version: {0}u(Removing previous configuration file: %su'Configuration file successfully removedR}R�iiR{u5Failed to remove previous configuration file '%s': %sN(RR�R�texistsR�R�R�tremoveR�R�R�R'tOSErrorR�R*(RRR�R$R�((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyR��s"
	
((dR&t
__future__RRRRRR�tloggingR�R�tos.pathtsalt.utils.filestsalt.utils.pathtsalt.exceptionsRtsalt.extRtsalt.ext.six.movesRR2R�R�R�R�Rt	getLoggerR	R�tsetLeveltDEBUGt__func_alias__RRReRcR_R[R
RRRtobjectRR(R3R4R5R7R;R<R=R@RARBRFRHRNRWRZR^RbRdRfRgRiRjRmRnRqRvRwRxRzR'R}R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R*R�R�R�R�R�R�(((s:/usr/lib/python2.7/site-packages/salt/modules/syslog_ng.pyt<module>s�(
				6
"(										
								
		$			
	
	
"!
		%>		

Zerion Mini Shell 1.0