mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-10 03:39:59 +00:00
fix: ES 自动创建索引
This commit is contained in:
@@ -10,6 +10,7 @@ import inspect
|
||||
from django.db.models import QuerySet as DJQuerySet
|
||||
from elasticsearch import Elasticsearch
|
||||
from elasticsearch.helpers import bulk
|
||||
from elasticsearch.exceptions import RequestError
|
||||
|
||||
from common.utils.common import lazyproperty
|
||||
from common.utils import get_logger
|
||||
@@ -31,6 +32,15 @@ class CommandStore():
|
||||
kwargs['verify_certs'] = None
|
||||
self.es = Elasticsearch(hosts=hosts, max_retries=0, **kwargs)
|
||||
|
||||
def pre_use_check(self):
|
||||
self._ensure_index_exists()
|
||||
|
||||
def _ensure_index_exists(self):
|
||||
try:
|
||||
self.es.indices.create(self.index)
|
||||
except RequestError:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def make_data(command):
|
||||
data = dict(
|
||||
@@ -234,6 +244,7 @@ class QuerySet(DJQuerySet):
|
||||
uqs = QuerySet(self._command_store_config)
|
||||
uqs._method_calls = self._method_calls.copy()
|
||||
uqs._slice = self._slice
|
||||
uqs.model = self.model
|
||||
return uqs
|
||||
|
||||
def count(self, limit_to_max_result_window=True):
|
||||
|
Reference in New Issue
Block a user