035541c6f2
- Implement logs model using Elasticsearch with tests - Implement transition model using both elasticsearch and database model - Add LOGS_MODEL configuration to choose which to use. Co-authored-by: Sida Chen <sidchen@redhat.com> Co-authored-by: Kenny Lee Sin Cheong <kenny.lee@redhat.com>
29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
import logging
|
|
|
|
from data import model
|
|
from data.logs_model.table_logs_model import TableLogsModel
|
|
from data.logs_model.document_logs_model import DocumentLogsModel
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class TableDocumentTransitionLogsModel(TableLogsModel):
|
|
"""
|
|
TableDocumentTransitionLogsModel implements the data model that logs to both a database table and
|
|
document store, but reads exclusively from the database tables.
|
|
|
|
This implementation is part of the migration path to move the logs from the database.
|
|
"""
|
|
|
|
def __init__(self, **kwargs):
|
|
super(TableDocumentTransitionLogsModel, self).__init__()
|
|
self.document_logs_model = DocumentLogsModel(**kwargs)
|
|
|
|
def log_action(self, kind_name, namespace_name=None, performer=None, ip=None, metadata=None,
|
|
repository=None, repository_name=None, timestamp=None):
|
|
super(TableDocumentTransitionLogsModel, self).log_action(kind_name, namespace_name, performer=performer, repository=repository, repository_name=repository_name,
|
|
ip=ip, metadata=metadata, timestamp=timestamp)
|
|
|
|
self.document_logs_model.log_action(kind_name, namespace_name, performer=performer, repository=repository, repository_name=repository_name,
|
|
ip=ip, metadata=metadata, timestamp=timestamp)
|
|
|