This activity has been put on hold due to the reprioritization of resources. We have documented the steps we have taken so far here, for those that may want to continue this work.
This place is to document the development of the Python POC for Security Logging.
Tentative Plan to develop Python POC
- Create a new repository for Python Logging Library
- You should create a ticket on LF IT Jira to create a new repository Project Support Services | Help Center (linuxfoundation.org)
- Create a Security Logging Python library and commit to an ONAP gerrit repository
- Make the it available to install using pip from ONAP’s nexusmake it available to install using pip from ONAP’s nexus
- I don’t know any working example of using ONAP nexus as a pip index, but for sure LF can also support on that.
- Create Python library hosted on gerrit repository
- I think that this is the Nexus repo Michal refers to: https://nexus3.onap.org/#browse/search/pypi
- Integration Team (PTL Michal) will create a version of base Python image with Logging Python Library
- DCAE Team (PTL Vijay and Tony Hansen) will provide DCAE Integration Validation
Technical Approach
- Most fields from Jakarta Best Practice Proposal for Standardized Logging Fields page can be configured using Python logging standard library
- Some fields are already defined logging — Logging facility for Python — Python 3.10.7 documentation)
- The rest is to create a proper configuration that could be reused by all projects (the question is if that should be done by some package or kept in one place in wiki or something).
- Configuration could be a part of the ONAP Python base image and developers can only load it from a file stored on the container, which is explained there (Logging HOWTO — Python 3.10.7 documentation).
- That would be the easiest part but… we are going to have some custom fields on record so looks like we have to define our own logging (Logging facility for Python — Python 3.10.7 documentation) LogRecord class.
- So probably the best way is to create a package with that and install it on all base containers, so developers could import it.
ONAP Related Resources
- Developing ONAP
- Configuring Gerrit
- Configure and customize pip
- How to PIP install from the ONAP Nexus repo
- Setting up git-review for python
Python 3 min version 3.10.4, PIP target 22.1.2, Database, Java, Python, Docker, Kubernetes, and Image Versions
- How can I use the Python baseline image?
- https://git.onap.org/integration/docker/onap-python/tree/
DCAE Python Based Modules
- heartbeat: https://github.com/onap/dcaegen2-services-heartbeat/tree/master/miss_htbt_service
- pm-service-handler: https://github.com/onap/dcaegen2-services/tree/master/components/pm-subscription-handler/pmsh_service/mod
- smnptrap: https://github.com/onap/dcaegen2-collectors-snmptrap/tree/master/snmptrap
pylog (onaplogging module)
- https://git.onap.org/logging-analytics/tree/pylog/onaplogging
Interesting Functions
There is an interesting function in https://github.com/onap/dcaegen2-services/blob/master/components/pm-subscription-handler/pmsh_service/mod/__init__.py lines 39 - 50
def mdc_handler(func):
@wraps(func)
def wrapper(*args, **kwargs):
request_id = str(uuid.uuid1())
invocation_id = str(uuid.uuid1())
MDC.put('ServiceName', getenv('HOSTNAME'))
MDC.put('RequestID', request_id)
MDC.put('InvocationID', invocation_id)
kwargs['request_id'] = request_id
kwargs['invocation_id'] = invocation_id
return func(*args, **kwargs)