%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/splunk_search.pyo

�
���^c@@s:dZddlmZmZmZddlZddlZddlmZe	Z
y"ddlZddl
Z
eZ
Wnek
r�nXddlZddlmZeje�Zidd6ZdZd	�Zd
�Zd�Zdd
�Zdd�Zdd�Zdd�Zdd�Z ddddddd�Z"dS(u�
Module for interop with the Splunk API

.. versionadded:: 2015.5.0

:depends:   - splunk-sdk python module
:configuration: Configure this module by specifying the name of a configuration
    profile in the minion config, minion pillar, or master config. The module
    will use the 'splunk' key by default, if defined.

    For example:

    .. code-block:: yaml

        splunk:
            username: alice
            password: abc123
            host: example.splunkcloud.com
            port: 8080
i(tabsolute_importtunicode_literalstprint_functionN(tsix(tOrderedDictulistulist_u
splunk_searchcC@str
tStdfS(uF
    Only load this module if splunk is installed on this minion.
    u�The splunk_search execution module failed to load: requires both the requests and the splunk-sdk python library to be installed.(tHAS_LIBSt__virtualname__tFalse(((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pyt__virtual__4sc
C@s�td|�}dj|jd�|jd�|jd�|jd��}|tkr�tjjd|jd�d|jd�d	|jd�d
|jd��t|<nt|S(uK
    Return the splunk client, cached into __context__ for performance
    u
config.optionusplunk_search.{0}:{1}:{2}:{3}uhostuportuusernameupasswordthosttporttusernametpassword(t__salt__tformattgett__context__t	splunklibtclienttconnect(tprofiletconfigtkey((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pyt_get_splunk>scC@s-|j}|jj|d<|jj|d<|S(u5
    Get splunk search properties from an object
    uappusharing(tcontenttaccesstapptsharing(tsearchtprops((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pyt_get_splunk_search_propsRs	usplunkcC@s;t|�}d}y|j|}Wntk
r6nX|S(u[
    Get a splunk search

    CLI Example:

        splunk_search.get 'my search name'
    N(RtNonetsaved_searchestKeyError(tnameRRR((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pyR\s
c
K@st|�}|j|}t|�}|}t}t�}g}	x�t|�D]�}
|j|
d�}|j|
d�}t|t	j
�r�|j�}nt|t	j
�r�|j�}n||krM|||
<t}|	j
dj|
||��qMqMW|r|j|�j�||	fStS(um
    Update a splunk search

    CLI Example:

        splunk_search.update 'my search name' sharing=app
    u{0}: '{1}' => '{2}'N(RR RRtdicttsortedRRt
isinstanceRtstring_typeststriptTruetappendRtupdatetrefresh(
R"RtkwargsRRRtupdatest
update_neededt
update_settdiffsRt	old_valuet	new_value((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pyR*ns.
	

c
K@s�t|�}|jj||�}td|�}dj|jd�|jd��}|jd�|jd�f}i|jd�d6dd	6d
d6}dj||jd�tj|��}	tj	|	d
|dt
d|�t|�S(ut
    Create a splunk search

    CLI Example:

        splunk_search.create 'my search name' search='error msg'
    u
config.optionuhttps://{0}:{1}uhostuportuusernameupassworduowneruappusharingu*u
perms.readu0{0}/servicesNS/{1}/search/saved/searches/{2}/acltauthtverifytdata(RR tcreateR
RRturllibtquotetrequeststpostR(R(
R"RR,RRRturlR3R5t_req_url((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pyR6�s$
!cC@s=t|�}y|jj|�tSWntk
r8dSXdS(u`
    Delete a splunk search

    CLI Example:

       splunk_search.delete 'my search name'
    N(RR tdeleteR(R!R(R"RR((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pyR=�s
cC@s0t|�}g|jD]}|d^q}|S(uX
    List splunk searches (names only)

    CLI Example:
        splunk_search.list
    uname(RR (RRtxtsearches((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pytlist_�s c
C@sDt|�}d}y|jj|�Wntk
r9nX|jj|dd�}t|j�}	|jj|�d}
t�}tg|jD]}|j	|f^q��}
xw|
D]o\}}|r�|j
j|kr�q�n|r�|j
j|kr�q�n|r||krq�n|r:|j
|�r-q�n||}ni|d6g}d
}x�t|jj��D]�\}}||
kr�qfn|j
d�r�qfn|s�qfn||	kr�|	||kr�qfn|ji||6�|dkrf|}qfqfW|r||krq�ni|d6|d|<q�Wtjjj|dtdd�S(ur
    Get all splunk search details. Produces results that can be used to create
    an sls file.

    if app or owner are specified, results will be limited to matching saved
    searches.

    if description_contains is specified, results will be limited to those
    where "description_contains in description" is true if name_not_contains is
    specified, results will be limited to those where "name_not_contains not in
    name" is true.

    If prefix parameter is given, alarm names in the output will be prepended
    with the prefix; alarms that have the prefix will be skipped. This can be
    used to convert existing alarms to be managed by salt, as follows:

    CLI example:

            1. Make a "backup" of all existing searches
                $ salt-call splunk_search.list_all --out=txt | sed "s/local: //" > legacy_searches.sls

            2. Get all searches with new prefixed names
                $ salt-call splunk_search.list_all "prefix=**MANAGED BY SALT** " --out=txt | sed "s/local: //" > managed_searches.sls

            3. Insert the managed searches into splunk
                $ salt-call state.sls managed_searches.sls

            4.  Manually verify that the new searches look right

            5.  Delete the original searches
                $ sed s/present/absent/ legacy_searches.sls > remove_legacy_searches.sls
                $ salt-call state.sls remove_legacy_searches.sls

            6.  Get all searches again, verify no changes
                $ salt-call splunk_search.list_all --out=txt | sed "s/local: //" > final_searches.sls
                $ diff final_searches.sls managed_searches.sls
    u#splunk_search.list_all get defaultsRunothingutriggered_alert_countuaction.emailuaction.populate_lookupu
action.rssu
action.scriptuaction.summary_indexuqualifiedSearchunext_scheduled_timeunameuudisplay.udescriptionusplunk_search.presentumanage splunk search tdefault_flow_styletwidthix(utriggered_alert_countuaction.emailuaction.populate_lookupu
action.rssu
action.scriptuaction.summary_indexuqualifiedSearchunext_scheduled_time(RR R=t	ExceptionR6R#RRR$R"RRtownert
startswithtitemsR)tsalttutilstyamlt	safe_dumpR(tprefixRRDtdescription_containstname_not_containsRRR"Rtdefaultst
readonly_keystresultstsR?tdtdescriptiontktv((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pytlist_all�s`'
	+
"
(#t__doc__t
__future__RRRtloggingR7tsalt.extRRRtsplunklib.clientRR9R(tImportErrortsalt.utils.yamlRGtsalt.utils.odictRt	getLoggert__name__tlogt__func_alias__RRRRRR*R6R=R@RRV(((s>/usr/lib/python2.7/site-packages/salt/modules/splunk_search.pyt<module>s6


	
		
"

Zerion Mini Shell 1.0