Beispiel #1
0
def elastic(request):
    INDEX = settings.ES_INDEXES['default']
    es = elasticutils.get_es()
    mappings = {
        'addons': reindex_addons,
        'apps': reindex_apps,
        'collections': reindex_collections,
        'compat': compatibility_report,
        'users': reindex_users,
        'stats_latest': index_latest_stats,
        'mkt_stats': index_mkt_stats,
        'mkt_stats_latest': index_latest_mkt_stats
    }
    if request.method == 'POST':
        if request.POST.get('recreate'):
            es.delete_index_if_exists(INDEX)
            # We must set up the mappings before we create the index again.
            setup_mapping()
            setup_indexes()
            if setup_mkt_indexes:
                setup_mkt_indexes()
            create_es_index_if_missing(INDEX)
            messages.info(request, 'Deleting %s index.' % INDEX)
        if request.POST.get('reindex') in mappings:
            name = request.POST['reindex']
            # Reindex.
            if mappings.get(name):
                mappings[name]()
            messages.info(request, 'Reindexing %s.' % name)
        return redirect('zadmin.elastic')

    indexes = set(settings.ES_INDEXES.values())
    es_mappings = es.get_mapping(None, indexes)
    ctx = {
        'index': INDEX,
        'nodes': es.cluster_nodes(),
        'health': es.cluster_health(),
        'state': es.cluster_state(),
        'mappings': [(index, es_mappings.get(index, {})) for index in indexes],
        'choices': mappings,
    }
    return jingo.render(request, 'zadmin/elastic.html', ctx)
Beispiel #2
0
def elastic(request):
    INDEX = settings.ES_INDEXES["default"]
    es = elasticutils.get_es()
    mappings = {
        "addons": reindex_addons,
        "apps": reindex_apps,
        "collections": reindex_collections,
        "compat": compatibility_report,
        "users": reindex_users,
        "stats_latest": index_latest_stats,
        "mkt_stats": index_mkt_stats,
        "mkt_stats_latest": index_latest_mkt_stats,
    }
    if request.method == "POST":
        if request.POST.get("recreate"):
            es.delete_index_if_exists(INDEX)
            # We must set up the mappings before we create the index again.
            setup_mapping()
            setup_indexes()
            if setup_mkt_indexes:
                setup_mkt_indexes()
            create_es_index_if_missing(INDEX)
            messages.info(request, "Deleting %s index." % INDEX)
        if request.POST.get("reindex") in mappings:
            name = request.POST["reindex"]
            # Reindex.
            if mappings.get(name):
                mappings[name]()
            messages.info(request, "Reindexing %s." % name)
        return redirect("zadmin.elastic")

    indexes = set(settings.ES_INDEXES.values())
    es_mappings = es.get_mapping(None, indexes)
    ctx = {
        "index": INDEX,
        "nodes": es.cluster_nodes(),
        "health": es.cluster_health(),
        "state": es.cluster_state(),
        "mappings": [(index, es_mappings.get(index, {})) for index in indexes],
        "choices": mappings,
    }
    return jingo.render(request, "zadmin/elastic.html", ctx)
Beispiel #3
0
def elastic(request):
    INDEX = settings.ES_INDEXES['default']
    es = elasticutils.get_es()
    mappings = {'addons': reindex_addons,
                'apps': reindex_apps,
                'collections': reindex_collections,
                'compat': compatibility_report,
                'users': reindex_users,
                'stats_latest': index_latest_stats,
                'mkt_stats': index_mkt_stats,
                'mkt_stats_latest': index_latest_mkt_stats}
    if request.method == 'POST':
        if request.POST.get('recreate'):
            es.delete_index_if_exists(INDEX)
            # We must set up the mappings before we create the index again.
            setup_mapping()
            setup_indexes()
            if setup_mkt_indexes:
                setup_mkt_indexes()
            create_es_index_if_missing(INDEX)
            messages.info(request, 'Deleting %s index.' % INDEX)
        if request.POST.get('reindex') in mappings:
            name = request.POST['reindex']
            # Reindex.
            if mappings.get(name):
                mappings[name]()
            messages.info(request, 'Reindexing %s.' % name)
        return redirect('zadmin.elastic')

    indexes = set(settings.ES_INDEXES.values())
    es_mappings = es.get_mapping(None, indexes)
    ctx = {
        'index': INDEX,
        'nodes': es.cluster_nodes(),
        'health': es.cluster_health(),
        'state': es.cluster_state(),
        'mappings': [(index, es_mappings.get(index, {})) for index in indexes],
        'choices': mappings,
    }
    return jingo.render(request, 'zadmin/elastic.html', ctx)