Oslo Reports Library
oslo.reports is an OpenStack library that provides a general-purpose framework for generating detailed error and system reports, often referred to as 'Guru Meditation Reports'. It helps administrators obtain an accurate view of the current live state of a system, including running threads, configuration parameters, and package versions. The current version is 3.7.0, and it follows the OpenStack project's regular release cadence.
Common errors
-
ModuleNotFoundError: No module named 'oslo.reports'
cause The Python import statement uses `oslo.reports` (with a dot) instead of `oslo_reports` (with an underscore), or the package is not installed.fixChange your import statement to `import oslo_reports` or `from oslo_reports...` and ensure the package is installed via `pip install oslo.reports`. -
jinja2.exceptions.TemplateNotFound: ...
cause A report view configured to use Jinja2 templates cannot find the necessary templates, likely because the `jinja2` package is not installed.fixInstall the Jinja2 templating engine: `pip install jinja2`. If using a specific `oslo.reports` view that relies on Jinja, ensure it's available. -
AttributeError: 'GuruMeditationReport' object has no attribute 'render_html_report'
cause Attempting to use a specific report rendering method (e.g., for HTML) that is not supported by default or requires a particular optional dependency or custom view setup.fixCheck the documentation for available `render_report` formats. If a specific format is desired, ensure the necessary view classes and their dependencies (like Jinja2 for HTML/templated text) are installed and correctly configured with the `GuruMeditationReport` instance.
Warnings
- breaking The library explicitly requires Python 3.10 or newer. Attempting to install or run oslo.reports on older Python versions will result in installation failures or runtime errors.
- gotcha Module import paths use underscores (`oslo_reports`) while the PyPI package name uses a dash (`oslo-reports`). A common mistake is to try `import oslo.reports`.
- gotcha Generating reports with specific output formats (e.g., templated text via Jinja2) or incorporating configuration data requires installing optional dependencies like `jinja2` or having `oslo.config` properly set up.
Install
-
pip install oslo.reports
Imports
- GuruMeditationReport
from oslo.reports.guru_meditation_report import GuruMeditationReport
from oslo_reports.guru_meditation_report import GuruMeditationReport
- ReportModel
from oslo_reports.models.base import ReportModel
- ModelWithDefaultViews
from oslo_reports.models.with_default_views import ModelWithDefaultViews
Quickstart
from oslo_reports.guru_meditation_report import GuruMeditationReport
# Create a Guru Meditation Report instance.
# By default, it gathers extensive system information.
# Additional generators can be registered for custom data.
gmr = GuruMeditationReport()
# Generate the report as a plain text string.
# Other rendering methods (e.g., to JSON, XML) may be available
# depending on installed optional dependencies and specific views.
report_text = gmr.render_report(output_format='text')
print("--- Guru Meditation Report ---")
print(report_text)
print("----------------------------")