This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/logs_model/table_document_transition_logs_model.py
Kenny Lee Sin Cheong 035541c6f2 Implement logs model using Elasticsearch
- 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>
2019-02-12 16:33:42 -05:00

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)