Registry / devops / oslo-utils

oslo-utils

JSON →
library10.2.0pypypi✓ verified 22d ago

The oslo.utils library provides support for common utility functions such as encoding, exception handling, string manipulation, and time handling. It is an integral part of the OpenStack ecosystem. The current stable version is 10.0.1, with releases typically tied to the OpenStack development cycles.

pip install oslo.utils
INSTALL
IMPORT
SIG · OSLO-UTILS
O
oslo-utils
devopspythonv10.2.0
Install
3.3s avg
Import
19ms
Disk
38MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v10.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.022s · 35MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.3s · import 0.016s · 36MB
38MB installed
● package 38MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

generate_uuid
from oslo_utils import uuidutils
Used for generating UUIDs.
utcnow
from oslo_utils import timeutils
Provides timezone-aware UTC datetime objects.
safe_decode
from oslo_utils import encodeutils
Handles safe decoding of bytes to strings.
raise_without_exc_info
from oslo_utils import excutils
Utility for re-raising exceptions without retaining full traceback information, common in OpenStack for error handling.
constant_time_compare
from oslo_utils import secretutils
Provides a constant-time comparison function suitable for cryptography.

This quickstart demonstrates how to generate a UUID and get the current UTC time using two common modules from oslo.utils: `uuidutils` and `timeutils`.

from oslo_utils import uuidutils from oslo_utils import timeutils # Generate a UUID uuid = uuidutils.generate_uuid() print(f"Generated UUID: {uuid}") # Get current UTC time now = timeutils.utcnow() print(f"Current UTC time: {now}")
Debug
Known issues
breakingDropped Python 2.x support in major versions. `oslo.utils` versions 10.x and later explicitly require Python 3.10 or newer. Older codebases running on Python 2 will need to be migrated to Python 3.
fix
Upgrade your Python environment to 3.10+ and ensure all dependencies are compatible. Review and update any Python 2 specific code patterns.
affects: < 10.0.0
gotchaOther libraries or OpenStack components might have implicit runtime dependencies on `oslo.utils` submodules. For example, `keystoneauth1` previously had an issue where it would fail without `oslo.utils` being explicitly installed, despite not declaring it as a direct dependency.
fix
When installing OpenStack clients or other 'oslo' ecosystem libraries, ensure `oslo.utils` is explicitly installed if `ModuleNotFoundError` issues arise, even if not explicitly listed in `requirements.txt` of the primary application.
affects: All versions
gotchaThe behavior of string encoding/decoding utilities like `encodeutils.safe_decode` and `encodeutils.safe_encode` changed significantly between Python 2 and Python 3. While current versions of `oslo.utils` only support Python 3, older codebases being migrated may contain assumptions or usage patterns from Python 2 that are no longer valid, particularly regarding `unicode` vs `str` types.
fix
Thoroughly review all calls to `encodeutils.safe_decode`, `safe_encode`, and `to_utf8` in migrated Python 2 code. Ensure that expected input types (bytes or str) and output types (str or bytes) align with Python 3 string semantics.
affects: All versions (when migrating from Python 2)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'oslo.utils'
The `oslo.utils` library is not installed in the Python environment, or the environment where the application is running does not have access to the installed library.
fix
Install the library using pip: `pip install oslo.utils` or `pip install 'oslo.utils<11'` for older projects, ensuring it's installed in the correct virtual environment if one is being used.
TypeError: unicode argument expected, got bytes
This error commonly occurs when migrating Python 2 code to Python 3, where string handling changed. Functions like `oslo_utils.encodeutils.safe_decode` and `safe_encode` expect different types (bytes vs. str) in Python 3 compared to Python 2, leading to type mismatches.
fix
Review calls to `encodeutils.safe_decode`, `safe_encode`, and `to_utf8` in your code. Ensure that inputs are of the expected string (str) or bytes type for Python 3. For example, explicitly decode bytes to strings or encode strings to bytes where necessary.
ImportError: cannot import name 'versionutils'
This typically indicates a version incompatibility or a dependency conflict within the OpenStack `oslo` libraries (e.g., `oslo_log` attempting to import `versionutils` from `oslo.utils` in a way that is no longer supported by the installed versions).
fix
Ensure that all `oslo` libraries (including `oslo.utils`, `oslo.log`, etc.) are compatible and updated to versions that work together, or explicitly manage dependency versions to resolve conflicts. Check the release notes for breaking changes related to `versionutils` imports.
AttributeError: 'oslo_utils.timeutils' object has no attribute 'strtime'
The `strtime` function from `oslo_utils.timeutils` has been deprecated and removed in newer versions of `oslo.utils`.
fix
Replace usages of `oslo_utils.timeutils.strtime` with `isoformat()` or other standard Python datetime formatting methods.
Upgrade
Version history
10.2.0latest on PyPI · released Aug 24, 2026
Audit
Dependencies
iso8601requiredDate and time parsing.
oslo.i18nrequiredInternationalization utilities.
netaddrrequiredNetwork address manipulation.
packagingrequiredCore utilities for Python packages.
psutilrequiredProcess and system utility information.
pyparsingrequiredGrammar and parsing tools.
PyYAMLrequiredYAML parsing and emitting.
debtcollectorrequiredUtilities for collecting technical debt (e.g., deprecation warnings).
Agent activity
3 hits · last 30 days
node
2
Resources
oslo-utils — pip install oslo-utils · libregistry