Registry / database / neutron-lib

neutron-lib

JSON →
library4.1.0pypypi✓ verified 84d ago

neutron-lib is a library of shared routines and utilities for OpenStack Neutron. It provides common code (exceptions, DB models, API definitions, extensions) used by neutron and neutron sub-projects. Version 3.25.0 supports Python >=3.10. Release cadence follows OpenStack coordinated releases, often with multiple minor releases per cycle.

pip install neutron-lib
INSTALL
IMPORT
SIG · NEUTRON-LIB
N
neutron-lib
databasepythonv4.1.0
Install
17.8s avg
Import
3509ms
Disk
188MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.1.0 · 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 3.580s · 180.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 17.8s · import 3.438s · 180MB
188MB installed
● package 188MB
Code
Verified usage

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

context
from neutron_lib import context
from neutron import context
neutron-lib was extracted from neutron; direct imports from 'neutron' may break.
exceptions
from neutron_lib import exceptions
from neutron.common import exceptions
Old path from monolithic neutron; use neutron_lib.exceptions.

Creates a RequestContext and demonstrates using exceptions.

from neutron_lib import context from neutron_lib import exceptions # Create a request context req_context = context.RequestContext(user_id='admin', tenant_id='admin', roles=['admin']) print(req_context.to_dict()) # Raise a NeutronException try: raise exceptions.NeutronException(message='example') except exceptions.NeutronException as e: print(e)
Debug
Known issues
breakingIn neutron-lib >= 2.0.0, the DB model classes were moved into separate database backend modules. Direct imports from neutron_lib.db.model_base may be deprecated or changed.
fix
If using neutron_lib.db.model_base, check the OpenStack release notes for the exact new import path, e.g., from neutron_lib.db import model_base as mb.
affects: >=2.0.0
breakingThe api.attributes module was refactored in some versions; constants like ATTR_NOT_SPECIFIED were moved to neutron_lib.api.definitions.
fix
Use from neutron_lib.api.definitions import ATTR_NOT_SPECIFIED instead.
affects: >=2.0.0
gotchaDo not install both neutron and neutron-lib from different versions in the same environment. They must be from the same OpenStack release series to avoid API incompatibility.
fix
Ensure that the versions of neutron and neutron-lib are consistent (e.g., both from the same OpenStack release).
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'NeutronException' from 'neutron_lib'
NeutronException is in neutron_lib.exceptions, not directly in neutron_lib.
fix
Use: from neutron_lib import exceptions
try:
    raise exceptions.NeutronException(...)
AttributeError: module 'neutron_lib' has no attribute 'context'
Common mistake: trying to use 'neutron_lib.context' but context module is not automatically imported. You need an explicit import.
fix
Add: from neutron_lib import context
neutron_lib.exceptions.NeutronException: Object not found
This error is raised when a resource is not found (like a port, network, etc.) but the caller may not realize it's an exception from neutron-lib.
fix
Catch neutron_lib.exceptions.NeutronException or a more specific subclass like PortNotFound, NetworkNotFound.
Upgrade
Version history
4.1.0latest on PyPI · released Jun 17, 2026
Audit
Dependencies
oslo.logrequiredLogging utilities used throughout
Agent activity
6 hits · last 30 days
node
6
Resources
neutron-lib — pip install neutron-lib · libregistry