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

�
���^c@@sSdZddlmZmZmZddlZddlmZddlm	Z
mZm
ZmZmZddlZddlZd�Zd�Zd�Zedddd	�Zddd
�Zdddd�Zd�Zdd
�Zdddd�Z ddd�Z!d�Z"d�Z#ddd�Z$dd�Z%dd�Z&dd�Z'ddd�Z(ddd�Z)ddd�Z*ddd�Z+ddd�Z,dde-d�Z.ddd�Z/ddd�Z0dd�Z1ddd�Z2ddd �Z3dde-d!�Z4dde-d"�Z5ddddd#�Z6ddddd$�Z7dde-d%�Z8dS(&u�
Apache Solr Salt Module

Author: Jed Glazner
Version: 0.2.1
Modified: 12/09/2011

This module uses HTTP requests to talk to the apache solr request handlers
to gather information and report errors. Because of this the minion doesn't
necessarily need to reside on the actual slave.  However if you want to
use the signal function the minion must reside on the physical solr host.

This module supports multi-core and standard setups.  Certain methods are
master/slave specific.  Make sure you set the solr.type. If you have
questions or want a feature request please ask.

Coming Features in 0.3
----------------------

1. Add command for checking for replication failures on slaves
2. Improve match_index_versions since it's pointless on busy solr masters
3. Add additional local fs checks for backups to make sure they succeeded

Override these in the minion config
-----------------------------------

solr.cores
    A list of core names e.g. ['core1','core2'].
    An empty list indicates non-multicore setup.
solr.baseurl
    The root level URL to access solr via HTTP
solr.request_timeout
    The number of seconds before timing out an HTTP/HTTPS/FTP request. If
    nothing is specified then the python global timeout setting is used.
solr.type
    Possible values are 'master' or 'slave'
solr.backup_path
    The path to store your backups. If you are using cores and you can specify
    to append the core name to the path in the backup method.
solr.num_backups
    For versions of solr >= 3.5. Indicates the number of backups to keep. This
    option is ignored if your version is less.
solr.init_script
    The full path to your init script with start/stop options
solr.dih.options
    A list of options to pass to the DIH.

Required Options for DIH
------------------------

clean : False
    Clear the index before importing
commit : True
    Commit the documents to the index upon completion
optimize : True
    Optimize the index after commit is complete
verbose : True
    Get verbose output
i(tabsolute_importtunicode_literalstprint_functionN(tsix(turlopentHTTPBasicAuthHandlertHTTPDigestAuthHandlertbuild_openertinstall_openercC@s<tjjjd�rdStjjjd�r2dStdfS(uZ
    PRIVATE METHOD
    Solr needs to be installed to use this.

    Return: str/bool
    usolruapache-solrufThe solr execution module failed to load: requires both the solr and apache-solr binaries in the path.(tsalttutilstpathtwhichtFalse(((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt__virtual__Us
cC@sN|dkrdS|s|St|tj�rF|j�dkrBdS|SdSdS(ug
    PRIVATE METHOD
    Checks to see if the value of a primitive or built-in container such as
    a list, dict, set, tuple etc is empty or none. None type is returned if the
    value is empty/None/False. Number data types that are 0 will return None.

    value : obj
        The primitive or built-in container to evaluate.

    Return: None or value
    unoneN(tNonet
isinstanceRtstring_typestlower(tvalue((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_get_none_or_valuecscC@sttdd��dkS(u�
    PRIVATE METHOD
    Checks to see if using_cores has been set or not. if it's been set
    return it, otherwise figure it out and set it. Then return it

    Return: boolean

        True if one or more cores defined in __opts__['solr.cores']
    u
config.optionu
solr.coresi(tlent__salt__(((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_check_for_cores}s
cC@sn|dkrin|}|dkr*gn|}|dkrBgn|}i|d6|d6|d6|d6}|S(u
    PRIVATE METHOD
    Creates a new return dict with default values. Defaults may be overwritten.

    success : boolean (True)
        True indicates a successful result.
    data : dict<str,obj> ({})
        Data to be returned to the caller.
    errors : list<str> ([()])
        A list of error messages to be returned to the caller
    warnings : list<str> ([])
        A list of warnings to be returned to the caller.

    Return: dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}
    usuccessudatauerrorsuwarningsN(R(tsuccesstdataterrorstwarningstret((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_get_return_dict�s

cC@ss|dkrgn|}|dkr*gn|}||d<|dj|�|d||d<|d||d<|S(u�
    PRIVATE METHOD
    Updates the return dictionary and returns it.

    ret : dict<str,obj>
        The original return dict to update. The ret param should have
        been created from _get_return_dict()
    success : boolean (True)
        True indicates a successful result.
    data : dict<str,obj> ({})
        Data to be returned to the caller.
    errors : list<str> ([()])
        A list of error messages to be returned to the caller
    warnings : list<str> ([])
        A list of warnings to be returned to the caller.

    Return: dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}
    usuccessudatauerrorsuwarningsN(Rtupdate(RRRRR((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_update_return_dict�s
c
C@s4|dkrgn|}t|�dks6|dkrItdd�}ntdd�}tdd�}t|�dkr�|dks�t|�dkr�dj||||�Sdj||||d	j|��Sn\|dks�t|�dkrd
j|||||�Sdj|||||d	j|��SdS(
uR
    PRIVATE METHOD
    Formats the URL based on parameters, and if cores are used or not

    handler : str
        The request handler to hit.
    host : str (None)
        The solr host to query. __opts__['host'] is default
    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you
        are not using cores or if you want to check all cores.
    extra : list<str> ([])
        A list of name value pairs in string format. e.g. ['name=value']

    Return: str
        Fully formatted URL (http://<host>:<port>/solr/<handler>?wt=json&<extra>)
    uNoneu
config.optionu	solr.hostu	solr.portusolr.baseurliuhttp://{0}:{1}{2}/{3}?wt=jsonu!http://{0}:{1}{2}/{3}?wt=json&{4}u&u!http://{0}:{1}{2}/{3}/{4}?wt=jsonu%http://{0}:{1}{2}/{3}/{4}?wt=json&{5}N(RRRRtformattjoin(thandlerthostt	core_nametextratporttbaseurl((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_format_url�s c
C@s�tddt�}tddt�}tddd�}|r�|r�t�}|jd|d|d|d	|�t�}|jd|d|d|d	|�tt||��nd
S(u-
    Install an auth handler for urllib2
    u
config.getu	solr.userusolr.passwdusolr.auth_realmuSolrtrealmturitusertpasswdN(RR
t_HTTPBasicAuthHandlertadd_passwordt_HTTPDigestAuthHandlert_install_openert
_build_opener(turlR+tpasswordR)tbasictdigest((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_auth�s				cC@s�t|�yatdd�}|dkr/in
i|d6}tjjjt||��}tt	|g�SWn/t
k
r�}ttidj||�g�SXdS(u�
    PRIVATE METHOD
    Uses salt.utils.json.load to fetch the JSON results from the solr API.

    url : str
        a complete URL that can be passed to urllib.open
    request_timeout : int (None)
        The number of seconds before the timeout should fail. Leave blank/None
        to use the default. __opts__['solr.request_timeout']

    Return: dict<str,obj>::

         {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}
    u
config.optionusolr.request_timeoututimeoutu	{0} : {1}N(
R6RRR	R
tjsontloadt_urlopenRtTruet	ExceptionR
R (R2trequest_timeouttkwargsRterr((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt
_http_requests
cC@sV|dkrgn|}dj|�g|}tdd|d|d|�}t|�S(u�
    PRIVATE METHOD
    Performs the requested replication command and returns a dictionary with
    success, errors and data as keys. The data object will contain the JSON
    response.

    command : str
        The replication command to execute.
    host : str (None)
        The solr host to query. __opts__['host'] is default
    core_name: str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.
    params : list<str> ([])
        Any additional parameters you want to send. Should be a lsit of
        strings in name=value format. e.g. ['name=value']

    Return: dict<str, obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}
    ucommand={0}ureplicationR#R$R%N(RR R(R?(tcommandR#R$tparamsR%R2((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_replication_requests
	cC@s.tdj|�|d|�}t|�}|S(u�
    PRIVATE METHOD
    Calls the _http_request method and passes the admin command to execute
    and stores the data. This data is fairly static but should be refreshed
    periodically to make sure everything this OK. The data object will contain
    the JSON response.

    command : str
        The admin command to execute.
    host : str (None)
        The solr host to query. __opts__['host'] is default
    core_name: str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.

    Return: dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}
    u	admin/{0}R$(R(R R?(R@R#R$R2tresp((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_get_admin_info9scC@stdd�dkS(u�
    PRIVATE METHOD
    Simple method to determine if the minion is configured as master or slave

    Return: boolean::

        True if __opts__['solr.type'] = master
    u
config.optionu	solr.typeumaster(R(((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt
_is_masterRs	cC@s~tdd�}t|t�r/|j|�nxHtj|�D]7\}}t|t�r?tj|�j�||<q?q?W|S(u�
    PRIVATE METHOD
    updates the default import options from __opts__['solr.dih.import_options']
    with the dictionary passed in.  Also converts booleans to strings
    to pass to solr.

    options : dict<str,boolean>
        Dictionary the over rides the default options defined in
        __opts__['solr.dih.import_options']

    Return: dict<str,boolean>::

        {option:boolean}
    u
config.optionusolr.dih.import_options(	RRtdictRRt	iteritemstboolt	text_typeR(toptionstdefaultstkeytval((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_merge_options^s cC@s t|�dkr2t�r2dg}tt|�St|�dkrft�rfdg}ttd|�St|||�}|dr�|dd}|dkr�dg}ttd	|�S|d
krdj|�g}ttd|dd|�Sn,d
j|�g}ttd|dd|�S|S(u�
    PRIVATE METHOD - MASTER CALL
    Does a pre-check to make sure that all the options are set and that
    we can talk to solr before trying to send a command to solr. This
    Command should only be issued to masters.

    handler : str
        The import handler to check the state of
    host : str (None):
        The solr host to query. __opts__['host'] is default
    core_name (None):
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.
        REQUIRED if you are using cores.

    Return:  dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}
    u>solr.pre_indexing_check can only be called by "master" minionsu9solr.full_import is not safe to multiple handlers at onceRusuccessudataustatusubusyu'An indexing process is already running.RuidleuUnknown status: "{0}"Ru*Status check failed. Response details: {0}N(	RRRERR
Rt
import_statusR:R (R"R#R$R>RRCtstatustwarn((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_pre_index_checkvs$	
	
	cC@s�|dkr|}ndj||�}g}x�tj|�D]�\}}||krl|ji||6�nt|t�r�x9|D].}t|t�r�|t|||�}q�q�Wnt|t�r=|t|||�}q=q=W|S(u�
    PRIVATE METHOD
    Traverses a dictionary of dictionaries/lists to find key
    and return the value stored.
    TODO:// this method doesn't really work very well, and it's not really
            very useful in its current state. The purpose for this method is
            to simplify parsing the JSON output so you can just pass the key
            you want to find and have it return the value.
    ret : dict<str,obj>
        The dictionary to search through. Typically this will be a dict
        returned from solr.
    key : str
        The key (str) to find in the dictionary

    Return: list<dict<str,obj>>::

        [{path:path, value:value}]
    u{0}:{1}N(	RR RRGtappendRtlistRFt_find_value(tret_dictRLRRtikeyRMtitem((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyRU�s	
 cC@st�}t|�dkr�t�r�t}x�tdd�D]~}tdd|�}|dr�|ddd}ii|d	6|6}niidd	6|6}t}t||||d
�}q;W|Stdd|�}|dr
|ddd}tti|d6|d
�S|SdS(
u?
    Gets the lucene version that solr is using. If you are running a multi-core
    setup you should specify a core name since all the cores run under the same
    servlet container, they will all have the same version.

    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.

    Return: dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.lucene_version
    u
config.optionu
solr.coresusystemR$usuccessudatauluceneulucene-spec-versionulucene_versionuerrorsuversionN(	RRRRR:RRDR
R(R$RRtnameRCtversion_numR((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytlucene_version�s"	

c	C@st�}t|�dkr�t�r�t}x�tdD]�}tdd|�}|dr�|dd}ii|dd6|6}nt}iidd6|6}t||||d	|d
�}q5W|Stdd|�}|dr|ddd}tti|d6|d	|d
�S|SdS(u
    Gets the solr version for the core specified.  You should specify a core
    here as all the cores will run under the same servlet container and so will
    all have the same version.

    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.version
    u
solr.coresusystemR$usuccessudatauluceneusolr-spec-versionuversionuerrorsuwarningsN(	RRRRR:t__opts__RDR
R(R$RRRYRCtluceneRRZ((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytversion�s&	

c
C@s(t�}t|�dkr�t�r�t}x�tdd�D]�}tdd|d|ddg�}t|�}|dr�ii|d	d	6|6}t||||d
|d�}q;t	}ii|d	d	6|6}t||||d
|d�}q;W|Stdd|d|ddg�}t|�SdS(
u�
    Search queries fast, but it is a very expensive operation. The ideal
    process is to run this with a master/slave configuration.  Then you
    can optimize the master, and push the optimized index to the slaves.
    If you are running a single solr instance, or if you are going to run
    this on a slave be aware than search performance will be horrible
    while this command is being run. Additionally it can take a LONG time
    to run and your HTTP request may timeout. If that happens adjust your
    timeout settings.

    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.optimize music
    u
config.optionu
solr.coresuupdateR#R$R%u
optimize=trueusuccessudatauerrorsuwarningsN(
RRRRR:RR(R?RR
(R#R$RRRYR2RCR((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytoptimize%s&	
cC@s�t�}t|�d	kr�t�r�t}x�tdD]z}tdd|d|�}|dr|ii|ddd6|6}nt}iid	d6|6}t||||d�}q5W|Stdd|d|�}|Sd	S(
u�
    Does a health check on solr, makes sure solr can talk to the indexes.

    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.ping music
    u
solr.coresupingR#R$usuccessudataustatusuerrorsN(	RRRRR:R\RDR
R(R#R$RRRYRCR((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytpingXs	
c	@s�t�}t}t�rH|d	krHdg}|jitd6|d6�S�fd�}t|�d	kr�t�r�x{tdD]9}t	dd|d|��|||�|�\}}q}Wn3t	dd|d|��|||�|�\}}|S(
u
    SLAVE CALL
    Check for errors, and determine if a slave is replicating or not.

    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.is_replication_enabled music
    u5Only "slave" minions can run "is_replication_enabled"usuccessuerrorsc	@s �dr|ddd}d}|d}d|kr�t}dj||d|�}|d	j|�|dkrz|nii|d6|6}n|d
dd}|dkr�|d
jd�t}n|ddkr�t}|djd�nt||||d	|d
�}n||fS(Nusuccessudataudetailsuslaveufalseu	masterUrluERRORu{0}: {1} - {2}uerrorsu
masterDetailsumasterureplicationEnableduwarningsu"Replication is disabled on master.uisPollingDisabledutrueuwarninguPolling is disabled(R
R RSRR(	RRRCtcoretslavetenabledt
master_urlR>R(tresponse(s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_checks�s(

)	u
solr.coresudetailsR#R$N(
RR:RERRR
RRR\RB(R#R$RRRRfRY((Res5/usr/lib/python2.7/site-packages/salt/modules/solr.pytis_replication_enabled}s		 	"	c	@s�t�}t}t�rHt|�d	krH|jitd6dgd6�S�fd�}t|�d	kr�t�r�t}x{tdD]9}t	dd|d|��|||�|�\}}q�Wn3t	dd|d|��|||�|�\}}|S(
u5
    SLAVE CALL
    Verifies that the master and the slave versions are in sync by
    comparing the index version. If you are constantly pushing updates
    the index the master and slave versions will seldom match. A solution
    to this is pause indexing every so often to allow the slave to replicate
    and then call this method before allowing indexing to resume.

    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.match_index_versions music
    usuccessu?solr.match_index_versions can only be called by "slave" minionsuerrorsc
@s��dry|ddd}|dddd}d|kr�|d}t}dj|||�}|dj|�|dkr�|nii|d6|6}n�i|d	d
dd
6|dddd6|d
d6gd6}	d|kr|	ji|dd6�n|	d
|	dkr0t}|djd�n|dkrB|	nii|	d6|6}t||||d|d�}n2t}|d}|d}t|||d|�}||fS(Nusuccessudataudetailsuslaveu	masterUrluERRORu{0}: {1} - {2}uerrorsu
masterDetailsumasterureplicatableIndexVersionuindexVersionunextExecutionAtunext_replicationufailed_listureplicationFailedAtListu-Master and Slave index versions do not match.uwarningsR(R
R RSRRR(
RRRCRaRbRdterrorR>Rtversions(Re(s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt_match�s<

)


&

u
solr.coresudetailsR#R$N(
RR:RERRRR
RR\RB(R#R$RRRjRY((Res5/usr/lib/python2.7/site-packages/salt/modules/solr.pytmatch_index_versions�s"		(	"	cC@s�t�}t|�d	kr�t}x�tdD]V}tdd|d|�}ii|dd6|6}t||||d|d�}q,WnQtdd|d|�}|dr�t||d|d|d|d�}n|S|S(
u�
    Get the full replication details.

    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.replication_details music
    u
solr.coresudetailsR#R$udatauerrorsuwarningsusuccessN(RRRR:R\RBR(R#R$RRRYRCR((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytreplication_details#s	
c
C@s�td}td}|dk	rK|jtjj�sK|tjj7}qKnt�}t|�dkrRt�rRt	}x�tdD]�}g}|dk	r�|r�||n|}|j
dj||��n|j
dj|��tdd|d|d	|�}	|	d
st
}nii|	dd6|6}
t|||
|	d|	d
�}q�W|S|dk	r�|dk	r�|r�||7}q�n|dk	r�dj|�g}n|j
dj|��tdd|d|d	|�}	|	SdS(uP
    Tell solr make a backup.  This method can be mis-leading since it uses the
    backup API.  If an error happens during the backup you are not notified.
    The status: 'OK' in the response simply means that solr received the
    request successfully.

    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.
    append_core_to_path : boolean (False)
        If True add the name of the core to the backup path. Assumes that
        minion backup path is not None.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.backup music
    usolr.backup_pathusolr.num_backupsu
solr.coresu
&location={0}u&numberToKeep={0}ubackupR#R$RAusuccessudatauerrorsuwarningsulocation={0}N(R\RtendswithtosRtsepRRRR:RSR RBR
R(R#R$tappend_core_to_pathRtnum_backupsRRRYRARCR((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytbackupIs>

		
		c

C@st�}t�rHt|�dkrHdg}|jitd6|d6�S|rTdnd}t|�dkr�t�r�t}xutdD]i}t	|d|d|�}|ds�t}nii|d	d	6|6}	t
|||	|d|d
�}q�W|St|d|d|�}|SdS(uW
    SLAVE CALL
    Prevent the slaves from polling the master for updates.

    polling : boolean
        True will enable polling. False will disable it.
    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to check all cores.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.set_is_polling False
    u9solr.set_is_polling can only be called by "slave" minionsusuccessuerrorsu
enablepolludisapblepollu
solr.coresR#R$udatauwarningsN(RRERRRR
RR:R\tset_is_pollingRRB(
tpollingR#R$RR>tcmdRRYRCR((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyRs�s"		
	c	
C@st�r/t|�dkr/ttddg�S|r;dnd}t|�dkr�t�r�t�}t}xotdD]c}t|||�}|ds�t}nii|dd6|6}t	||||d|d	�}qvW|S|r�t
|d
|d|�St
|d
|d|�SdS(
u�
    MASTER ONLY
    Sets the master to ignore poll requests from the slaves. Useful when you
    don't want the slaves replicating during indexing or when clearing the
    index.

    status : boolean
        Sets the replication status to the specified state.
    host : str (None)
        The solr host to query. __opts__['host'] is default.

    core_name : str (None)
        The name of the solr core if using cores. Leave this blank if you are
        not using cores or if you want to set the status on all cores.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.set_replication_enabled false, None, music
    Ru.Only minions configured as master can run thisuenablereplicationudisablereplicationu
solr.coresusuccessudatauerrorsuwarningsR#R$N(RERRRR
RR:R\tset_replication_enabledRRB(	RPR#R$RuRRRYRCR((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyRv�s$	
	
	cC@swd
}||krI|d dj|d�f}dj|dj|��Sdjtd	|�}td
|dt�dS(u�
    Signals Apache Solr to start, stop, or restart. Obviously this is only
    going to work if the minion resides on the solr host. Additionally Solr
    doesn't ship with an init script so one must be created.

    signal : str (None)
        The command to pass to the apache solr init valid values are 'start',
        'stop', and 'restart'

    CLI Example:

    .. code-block:: bash

        salt '*' solr.signal restart
    ustartustopurestarti����uor {0}u*{0} is an invalid signal. Try: one of: {1}u, u{0} {1}usolr.init_scriptucmd.runtpython_shellN(ustartustopurestart(R R!R\RR
(tsignalt
valid_signalstmsgRu((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyRx�sc
	C@st�}t�s6dg}|jitd6|d6�St|�d
kr�t�r�t}xltdD]`}t||�}|ds�t}nii|dd6|6}t	||||d|d�}qbW|Sddj
|�g}td	d
|dd
d|�}	t|	�S(u�
    MULTI-CORE HOSTS ONLY
    Load a new core from the same configuration as an existing registered core.
    While the "new" core is initializing, the "old" one will continue to accept
    requests. Once it has finished, all new request will go to the "new" core,
    and the "old" core will be unloaded.

    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core_name : str
        The name of the core to reload

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.reload_core None music

    Return data is in the following format::

        {'success':bool, 'data':dict, 'errors':list, 'warnings':list}
    u;solr.reload_core can only be called by "multi-core" minionsusuccessuerrorsu
solr.coresudatauwarningsu
action=RELOADucore={0}uadmin/coresR#R$R%N(
RRRR
RRR:R\treload_coreRR R(R?(
R#R$RR>RRYRCRR%R2((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyR{s"			
	c
	C@st�}t�s6dg}|jitd6|d6�St|�d
kr�t�r�t}xltdD]`}t||�}|ds�t}nii|dd6|6}t	||||d|d�}qbW|Sddj
|�g}td	d
|dd
d|�}	t|	�S(u�
    MULTI-CORE HOSTS ONLY
    Get the status for a given core or all cores if no core is specified

    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core_name : str
        The name of the core to reload

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.core_status None music
    u;solr.reload_core can only be called by "multi-core" minionsusuccessuerrorsu
solr.coresudatauwarningsu
action=STATUSucore={0}uadmin/coresR#R$R%N(
RRRR
RRR:R\R{RR R(R?(
R#R$RR>RRYRCRR%R2((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytcore_status0s"			
	c
C@s�t�r2t|�dkr2dg}tt|�St|�dkrct�rcdg}tt|�Sdg}|r�|jd�nt|d|d|d|�}t|�S(	u�
    MASTER ONLY
    re-loads the handler config XML file.
    This command can only be run if the minion is a 'master' type

    handler : str
        The name of the data import handler.
    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core : str (None)
        The core the handler belongs to.
    verbose : boolean (False)
        Run the command with verbose output.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.reload_import_config dataimport None music {'clean':True}
    u>solr.pre_indexing_check can only be called by "master" minionsu<No core specified when minion is configured as "multi-core".ucommand=reload-configuverbose=trueR#R$R%N(	RERRRR
RRSR(R?(R"R#R$tverboseR>RAR2((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytreload_import_configZs	
	
	c
C@s�t�r5t|�d	kr5dg}ttd|�St|�d	krft�rfdg}tt|�Sdg}|r�|jd�nt|d|d|d|�}t|�S(
u�
    MASTER ONLY
    Aborts an existing import command to the specified handler.
    This command can only be run if the minion is configured with
    solr.type=master

    handler : str
        The name of the data import handler.
    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core : str (None)
        The core the handler belongs to.
    verbose : boolean (False)
        Run the command with verbose output.

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.abort_import dataimport None music {'clean':True}
    u8solr.abort_import can only be called on "master" minionsRu<No core specified when minion is configured as "multi-core".u
command=abortuverbose=trueR#R$R%N(	RERRRR
RRSR(R?(R"R#R$R}R>RAR2((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytabort_import�s		
	c
C@se|dkrin|}|dkr*gn|}t�sRdg}ttd|�St|�dkr�t�r�dg}tt|�St|||�}|ds�|St|�}|dr�ttd|d|�}|ds�dg}ttd|�Snd	g}x6t	j
|�D]%\}	}
|jd
j|	|
��qWt
|d|d|d||�}t|�S(
u�
    MASTER ONLY
    Submits an import command to the specified handler using specified options.
    This command can only be run if the minion is configured with
    solr.type=master

    handler : str
        The name of the data import handler.
    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core : str (None)
        The core the handler belongs to.
    options : dict (__opts__)
        A list of options such as clean, optimize commit, verbose, and
        pause_replication. leave blank to use __opts__ defaults. options will
        be merged with __opts__
    extra : dict ([])
        Extra name value pairs to pass to the handler. e.g. ["name=value"]

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.full_import dataimport None music {'clean':True}
    u7solr.full_import can only be called on "master" minionsRu<No core specified when minion is configured as "multi-core".usuccessucleanR#R$u3Failed to set the replication status on the master.ucommand=full-importu&{0}={1}R%N(RRERR
RRRRRNRvRRGRSR R(R?(R"R#R$RJR%R>RCRRARLRMR2((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytfull_import�s.			



		
cC@sV|dkrin|}|dkr*gn|}t�ret|�dkredg}ttd|�St|d|d|�}|ds�|St|�}|dr�t�r�ttd|d|�}|ds�dg}ttd|�Sndg}x6t	j
|�D]%\}	}
|jd	j|	|
��qWt
|d|d|d
||�}t|�S(u�
    Submits an import command to the specified handler using specified options.
    This command can only be run if the minion is configured with
    solr.type=master

    handler : str
        The name of the data import handler.
    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core : str (None)
        The core the handler belongs to.
    options : dict (__opts__)
        A list of options such as clean, optimize commit, verbose, and
        pause_replication. leave blank to use __opts__ defaults. options will
        be merged with __opts__

    extra : dict ([])
        Extra name value pairs to pass to the handler. e.g. ["name=value"]

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.delta_import dataimport None music {'clean':True}
    u8solr.delta_import can only be called on "master" minionsRR#R$usuccessucleanu3Failed to set the replication status on the master.ucommand=delta-importu{0}={1}R%N(RRERRR
RRRNRRvRRGRSR R(R?(R"R#R$RJR%R>RCRRARLRMR2((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pytdelta_import�s(	

		
c	C@s|t�r5t|�dkr5dg}ttd|�Sdg}|rT|jd�nt|d|d|d|�}t|�S(	u�
    Submits an import command to the specified handler using specified options.
    This command can only be run if the minion is configured with
    solr.type: 'master'

    handler : str
        The name of the data import handler.
    host : str (None)
        The solr host to query. __opts__['host'] is default.
    core : str (None)
        The core the handler belongs to.
    verbose : boolean (False)
        Specifies verbose output

    Return : dict<str,obj>::

        {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    .. code-block:: bash

        salt '*' solr.import_status dataimport None music False
    u9solr.import_status can only be called by "master" minionsRucommand=statusuverbose=trueR#R$R%N(RERRRR
RSR(R?(R"R#R$R}RR%R2((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyROs		(9t__doc__t
__future__RRRRntsalt.extRt!salt.ext.six.moves.urllib.requestRR9RR-RR/RR1RR0tsalt.utils.jsonR	tsalt.utils.pathRRRR:RRRR(R6R?RBRDRERNRRRUR[R^R_R`RgRkRlR
RrRsRvRxR{R|R~RR�R�RO(((s5/usr/lib/python2.7/site-packages/salt/modules/solr.pyt<module><sL(
			
'			0'+-3%J\&=.0/*+)96

Zerion Mini Shell 1.0