fix: 有无效的 ES 时,创建 Session 失败

pull/5793/head
xinwen 2021-03-18 14:23:24 +08:00 committed by Jiangjie.Bai
parent a47a9c0345
commit 33952b2333
1 changed files with 7 additions and 0 deletions

View File

@ -2,9 +2,12 @@ from importlib import import_module
from django.conf import settings
from django.utils.functional import LazyObject
from common.utils import get_logger
from .command.serializers import SessionCommandSerializer
logger = get_logger(__file__)
TYPE_ENGINE_MAPPING = {
'elasticsearch': 'terminal.backends.command.es',
'es': 'terminal.backends.command.es',
@ -29,6 +32,10 @@ def get_terminal_command_storages():
from ..models import CommandStorage
storage_list = {}
for s in CommandStorage.objects.all():
if not s.is_valid():
logger.warn(f'Command storage invalid: storage={s}')
continue
if s.type_server:
storage = get_command_storage()
else: