jumpserver/apps/terminal/backends/command/es.py

39 lines
1.2 KiB
Python
Raw Normal View History

2018-01-18 01:56:13 +00:00
# -*- coding: utf-8 -*-
#
2018-01-21 09:27:27 +00:00
from jms_es_sdk import ESStore
2018-01-18 01:56:13 +00:00
from .base import CommandBase
class CommandStore(CommandBase, ESStore):
2018-01-21 09:27:27 +00:00
def __init__(self, params):
hosts = params.get('HOSTS', ['http://localhost'])
ESStore.__init__(self, hosts=hosts)
2018-01-18 01:56:13 +00:00
def save(self, command):
return ESStore.save(self, command)
def bulk_save(self, commands):
return ESStore.bulk_save(self, commands)
def filter(self, date_from=None, date_to=None,
user=None, asset=None, system_user=None,
input=None, session=None):
data = ESStore.filter(
self, date_from=date_from, date_to=date_to,
user=user, asset=asset, system_user=system_user,
input=input, session=session
)
return [item["_source"] for item in data["hits"] if item]
2018-01-21 09:27:27 +00:00
def count(self, date_from=None, date_to=None,
user=None, asset=None, system_user=None,
input=None, session=None):
amount = ESStore.count(
self, date_from=date_from, date_to=date_to,
user=user, asset=asset, system_user=system_user,
input=input, session=session
)
return amount