Exemple #1
0
def execute(command):
    """ Execute a command
    """
    hostname = request.args.get('hostname')
    core = request.args.get('core')
    params = {}
    if core not in app.config['CORES']:
        abort(400, 'Invalid core')

    if command == 'filelist':
        params['indexversion'] = request.args.get('indexversion')
    elif command == 'select':
        params['q'] = request.args.get('q')
        params['fl'] = request.args.get('fl', '')
    # TODO: check validity of command name
    try:
        host = [obj for obj in app.config['HOSTS'] if obj['hostname'] == hostname][0]
    except KeyError:
        abort(400, 'Invalid hostname')
    # TODO: Error checking from Solr
    retval = h.query_solr(host, command, core, params=params)
    if command in ['filelist', 'select']:
        return jsonify(retval)
    return redirect('/')
Exemple #2
0
        core = None
    auth = {}
    params = {}
    try:
        auth = {'username': request.form['username'],
                'password': request.form['password']}
    except KeyError, e:
        pass
    try:
        params = {'indexversion': request.form['indexversion']}
    except KeyError, e:
        pass
    host = {'hostname': hostname,
            'port': port,
            'auth': auth}
    return jsonify(query_solr(host, command, core, params=params))

@app.route('/solr_versions', methods=['GET'])
def solr_versions():
    ''' Get the versions of all Solr daemons configured in 
    soldash.settings.HOSTS.
    
    Returns the output in JSON form.
    '''
    
    return jsonify({'data': get_solr_versions()})

@app.route('/details', methods=['GET'])
def details():
    ''' Get details about the current state of all Solr instances.