HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/solr.cpython-310.pyc
o

�N�g���@s\dZddlZddlZddlZddlZdd�Zdd�Zdd�Z	dEd
d�Z
dFdd
�ZdGdd�Zdd�Z
dHdd�ZdGdd�ZdFdd�Zdd�Zdd�ZdFdd�ZdHdd�ZdHd d!�ZdHd"d#�ZdFd$d%�ZdFd&d'�ZdFd(d)�ZdFd*d+�ZdFd,d-�ZdId/d0�ZdFd1d2�ZdFd3d4�ZdHd5d6�ZdFd7d8�Z dFd9d:�Z!dId;d<�Z"dId=d>�Z#dJd?d@�Z$dJdAdB�Z%dIdCdD�Z&dS)Ka�
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
�NcCs(tjj�d�r	dStjj�d�rdSdS)zZ
    PRIVATE METHOD
    Solr needs to be installed to use this.

    Return: str/bool
    Zsolrzapache-solr)FzfThe solr execution module failed to load: requires both the solr and apache-solr binaries in the path.)�salt�utils�path�which�rr�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/solr.py�__virtual__Fs
rcCs6|durdS|s
|St|t�r|��dkrdS|SdS)ag
    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
    NZnone)�
isinstance�str�lower)�valuerrr�_get_none_or_valueXs
r
cCsttdd��dkS)z�
    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']
    �
config.option�
solr.coresr)�len�__salt__rrrr�_check_for_coresrs
rTcCsB|durin|}|durgn|}|durgn|}||||d�}|S)a
    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}
    N)�success�data�errors�warningsr)rrrr�retrrr�_get_return_dicts
rcCsZ|durgn|}|durgn|}||d<|d�|�|d||d<|d||d<|S)a�
    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}
    Nrrrr)�update)rrrrrrrr�_update_return_dict�src
Cs�|durgn|}t|�dus|dkrtdd�}tdd�}tdd�}t|�durN|dus4t|�dkrBd|�d	|�|�d
|�d�Sd�||||d
�|��S|dusXt|�dkrad�|||||�Sd�|||||d
�|��S)aR
    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>)
    N�Nonerz	solr.hostz	solr.portzsolr.baseurlrzhttp://�:�/z?wt=jsonzhttp://{}:{}{}/{}?wt=json&{}�&zhttp://{}:{}{}/{}/{}?wt=jsonzhttp://{}:{}{}/{}/{}?wt=json&{})r
rr�format�join)�handler�host�	core_name�extra�portZbaseurlrrr�_format_url�s$�
��r&cCs�tddd�}tddd�}tddd�}|rB|rDtj��}|j||||d�tj��}|j||||d�tj�tj�||��dSdSdS)	z-
    Install an auth handler for urllib2
    z
config.getz	solr.userFzsolr.passwdzsolr.auth_realmZSolr)�realmZuri�user�passwdN)r�urllib�requestZHTTPBasicAuthHandlerZadd_passwordZHTTPDigestAuthHandlerZinstall_openerZbuild_opener)�urlr(�passwordr'Zbasic�digestrrr�_auth�s

�r/c
Cs�t|�z&tdd�}|durind|i}tjj�tjj|fi|���}t	d|g�WSt
yH}zt	di|�d|��g�WYd}~Sd}~ww)a�
    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}
    rzsolr.request_timeoutN�timeoutTFz : )r/rrr�json�loadr*r+�urlopenr�	Exception)r,Zrequest_timeout�kwargsr�errrrr�
_http_request�s$��r7cCs8|durgn|}d|��g|}td|||d�}t|�S)a�
    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}
    Nzcommand=Zreplication�r"r#r$�r&r7)�commandr"r#�paramsr$r,rrr�_replication_request
sr<cCs td|��||d�}t|�}|S)a�
    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}
    zadmin/�r#r9)r:r"r#r,�resprrr�_get_admin_info&sr?cCstdd�dkS)z�
    PRIVATE METHOD
    Simple method to determine if the minion is configured as master or slave

    Return: boolean::

        True if __opts__['solr.type'] = master
    rz	solr.type�master)rrrrr�
_is_master?s	rAcCsPtdd�}t|t�r|�|�|��D]\}}t|t�r%t|���||<q|S)a�
    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}
    rzsolr.dih.import_options)rr	�dictr�items�boolr
r)�options�defaults�key�valrrr�_merge_optionsKs


�rIcCs�t|�durt�sdg}td|�St|�dur#t�r#dg}td|d�St|||�}|drV|dd}|d	kr@d
g}td|d�S|d
krTd|�d�g}td|d|d�S|Sd|��g}td|d|d�S)a�
    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}
    N�>solr.pre_indexing_check can only be called by "master" minionsFz9solr.full_import is not safe to multiple handlers at once�rrr�statusZbusyz'An indexing process is already running.T)rZidlezUnknown status: "�")rrz'Status check failed. Response details: )r
rArr�
import_status)r!r"r#r6rr>rL�warnrrr�_pre_index_checkcs$
�rPcCs�|dur|}n|�d|��}g}|��D]3\}}||kr#|�||i�t|t�r:|D]}t|t�r9|t|||�}q*t|t�rG|t|||�}q|S)a�
    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}]
    Nr)rC�appendr	�listrB�_find_value)Zret_dictrGrrZikeyrH�itemrrrrS�s 

�
�rScCs�t�}t|�durCt�rCd}tdd�D],}td|d�}|dr/|dd	d
}|d|ii}n|ddii}d}t||||d
�}q|Std|d�}|dr_|dd	d
}tdd|i|d
�S|S)a?
    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
    NTrr�systemr=rr�lucenezlucene-spec-version�lucene_versionFr�version)rr
rrr?r)r#rr�namer>�version_numrrrrrW�s"rWcCs�t�}t|�durDt�rDd}tdD]/}td|d�}|dr-|dd}|d	|d
ii}nd}|d	dii}t||||d|d
�}q|Std|d�}|drc|ddd
}tdd	|i|d|d
�S|S)a
    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
    NTrrUr=rrrVrXzsolr-spec-versionFrr�rr
r�__opts__r?r)r#rrrYr>rVrrZrrrrX�s*��rXcCs�t�}t|�durUt�rUd}tdd�D]>}td||dgd�}t|�}|dr<|d	|d	ii}t||||d
|d�}qd}|d	|d	ii}t||||d
|d�}q|Std||dgd�}t|�S)
a�
    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
    NTrrrz
optimize=truer8rrrrF)rr
rrr&r7r)r"r#rrrYr,r>rrrr�optimizes.
���
�r]cCs�t�}t|�dur>t�r>d}tdD])}td||d�}|dr*|d|ddii}nd	}|ddii}t||||d
�}q|Std||d�}|S)a�
    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
    NTr�ping�r"r#rrLrFrr[�r"r#rrrYr>rrrrr^Ksr^cs�t�}d}t�r|durdg}|�d|d��S�fdd�}t|�dur?t�r?tdD]}td	||d
��|||�|�\}}q*|Std	||d
��|||�|�\}}|S)a
    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
    TNz5Only "slave" minions can run "is_replication_enabled"F�rrc	s��dre|ddd}d}|d}d|vr5d}d	�||d|�}|d
�|�|dur.|n|d|ii}n|ddd
}|dkrJ|d�d�d}|ddkrYd}|d�d�t||||d
|d�}||fS)Nrr�details�slave�false�	masterUrl�ERRORFz{}: {} - {}r�
masterDetailsr@ZreplicationEnabledrz"Replication is disabled on master.ZisPollingDisabled�true�warningzPolling is disabled)rrQr)	rrr>�corerc�enabled�
master_urlr6r��responserr�_checks�s(�z'is_replication_enabled.<locals>._checksrrbr_)rrArr
rr\r<)r"r#rrrrorYrrmr�is_replication_enabledps �rpcs�t�}d}t�rt|�dur|�ddgd��S�fdd�}t|�durAt�rAd}tdD]}td	||d
��|||�|�\}}q,|Std	||d
��|||�|�\}}|S)a5
    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
    TNFz?solr.match_index_versions can only be called by "slave" minionsrac
sF�dr�|ddd}|dddd}d|vr>|d}d}|�d|�d	|��}|d
�|�|dur7|n|d|ii}n?|ddd
|ddd|dgd�}	d|vr`|	�d|di�|	d|	dkrqd}|d
�d�|durw|	n|d|	ii}t||||d
|d�}||fSd}|d
}|d}t||||d�}||fS)NrrrbrcrerfFz: z - rrgr@ZreplicatableIndexVersionZindexVersionZnextExecutionAt)r@rcZnext_replication�failed_listZreplicationFailedAtListrqz-Master and Slave index versions do not match.rrK)rQrr)
rrr>rjrcrl�errorr6rZversionsrmrr�_match�sB
�����z$match_index_versions.<locals>._matchrrbr_)rrAr
rrr\r<)r"r#rrrsrYrrmr�match_index_versions�s&���
)�rtcCs�t�}t|�dur/d}tdD]}td||d�}|d|dii}t||||d|d�}q|Std||d�}|d	rLt||d	|d|d|d�}|S|S)
a�
    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
    NTrrbr_rrrr)rr
r\r<rr`rrr�replication_detailss"����ruFcCs8td}td}|dur|�tjj�s|tjj7}t�}t|�durrt�rrd}tdD]D}g}|durE|r9||n|}|�d||���|�d|���t	d|||d	�}	|	d
s[d}|d|	dii}
t
|||
|	d
|	d�}q+|S|dur�|dur�|r�||7}|dur�d|��g}|�d|���t	d|||d	�}	|	S)aP
    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
    zsolr.backup_pathzsolr.num_backupsNTrz
&location=z&numberToKeep=�backup)r"r#r;rFrrrz	location=)r\�endswith�osr�seprr
rrQr<r)r"r#Zappend_core_to_pathrZnum_backupsrrrYr;r>rrrrrv<sD���rvc
Cs�t�}t�rt|�durdg}|�d|d��S|rdnd}t|�durRt�rRd}tdD]#}t|||d	�}|d
s;d}|d|dii}	t|||	|d|d
�}q,|St|||d	�}|S)aW
    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
    Nz9solr.set_is_polling can only be called by "slave" minionsFraZ
enablepollZdisapblepollTrr_rrrr)	rrAr
rrr\�set_is_pollingrr<)
Zpollingr"r#rr6�cmdrrYr>rrrrrz|s$�rzc	Cs�t�st|�durtddgd�S|rdnd}t|�durMt�rMt�}d}tdD]"}t|||�}|d	s6d}|d
|d
ii}t||||d|d�}q(|S|rVt|||d
�St|||d
�S)a�
    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
    NFz.Only minions configured as master can run thisrKZenablereplicationZdisablereplicationTrrrrrr_)rAr
rrr\�set_replication_enabledrr<)	rLr"r#r{rrrYr>rrrrr|�s(��r|cCsPd}||vrd�|d�|dd��|d�Sd�td|�}td|d	d
�dS)a�
    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
    )�start�stopZrestartz.{} is an invalid signal. Try: one of: {} or {}z, N���z{} {}zsolr.init_scriptzcmd.runF)Zpython_shell)rr r\r)�signal�
valid_signalsr{rrrr��s�r�c
C�t�}t�sdg}|�d|d��St|�durDt�rDd}tdD]!}t||�}|ds-d}|d|dii}t||||d	|d
�}q |Sdd|��g}td
|d|d�}	t|	�S)a�
    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}
    �;solr.reload_core can only be called by "multi-core" minionsFraNTrrrrrz
action=RELOAD�core=�admin/coresr8�	rrrr
r\�reload_corerr&r7�
r"r#rr6rrYr>rr$r,rrrr��s$
�r�c
Cr�)a�
    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
    r�FraNTrrrrrz
action=STATUSr�r�r8r�r�rrr�core_status*s$
�r�cCspt�st|�durdg}td|�St|�dur"t�r"dg}td|�Sdg}|r,|�d�t||||d�}t|�S)a�
    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}
    NrJF�<No core specified when minion is configured as "multi-core".zcommand=reload-config�verbose=truer8�rAr
rrrQr&r7�r!r"r#�verboser6r;r,rrr�reload_import_configVs


r�cCsrt�st|�durdg}td|d�St|�dur#t�r#dg}td|�Sdg}|r-|�d�t||||d�}t|�S)	a�
    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}
    Nz8solr.abort_import can only be called on "master" minionsFrKr�z
command=abortr�r8r�r�rrr�abort_import�s

r�cCs�|durin|}|durgn|}t�sdg}td|d�St|�dur-t�r-dg}td|�St|||�}|ds9|St|�}|drUtd||d�}|dsUd	g}td|d�Sd
g}|��D]\}	}
|�d|	�d|
���q\t	|||||d
�}t
|�S)a�
    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}
    Nz7solr.full_import can only be called on "master" minionsFrKr�r�cleanr_�3Failed to set the replication status on the master.zcommand=full-importr�=r8)rArr
rrPrIr|rCrQr&r7�r!r"r#rEr$r6r>rr;rGrHr,rrr�full_import�s,
r�cCs�|durin|}|durgn|}t�s"t|�dur"dg}td|d�St|||d�}|ds/|St|�}|drNt�rNtd||d�}|dsNdg}td|d�Sd	g}|��D]\}	}
|�|	�d
|
���qUt	|||||d�}t
|�S)a�
    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}
    Nz8solr.delta_import can only be called on "master" minionsFrKr_rr�r�zcommand=delta-importr�r8)rAr
rrPrIrr|rCrQr&r7r�rrr�delta_import�s&r�cCsPt�st|�durdg}td|d�Sdg}|r|�d�t||||d�}t|�S)a�
    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
    Nz9solr.import_status can only be called by "master" minionsFrKzcommand=statusr�r8)rAr
rrQr&r7)r!r"r#r�rr$r,rrrrNs
rN)TNNN)NN)NNN)N)NNF)NNNN)'�__doc__rx�urllib.requestr*Zsalt.utils.jsonrZsalt.utils.pathrr
rrrr&r/r7r<r?rArIrPrSrWrXr]r^rprtrurvrzr|r�r�r�r�r�r�r�rNrrrr�<module>sJ<


)




/
(
+
/
7
%
H
\
(
@
/
2

0
,
*
)
85