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

33 lines
826 B
Python
Raw Normal View History

2018-01-21 09:27:27 +00:00
# -*- coding: utf-8 -*-
#
from .base import CommandBase
class CommandStore(CommandBase):
def __init__(self, storage_list):
self.storage_list = storage_list
def filter(self, **kwargs):
2019-07-02 14:08:50 +00:00
if len(self.storage_list) == 1:
storage = list(self.storage_list)[0]
queryset = storage.filter(**kwargs)
return queryset
2018-03-28 07:47:20 +00:00
2019-07-02 14:08:50 +00:00
queryset = []
2018-01-21 09:27:27 +00:00
for storage in self.storage_list:
queryset.extend(storage.filter(**kwargs))
2018-03-28 07:47:20 +00:00
return sorted(queryset, key=lambda command: command.timestamp, reverse=True)
2018-01-21 09:27:27 +00:00
def count(self, **kwargs):
amount = 0
for storage in self.storage_list:
amount += storage.count(**kwargs)
return amount
def save(self, command):
pass
def bulk_save(self, commands):
2018-01-22 10:48:16 +00:00
pass