OpenStack Service Types Authority Client
Python library for consuming OpenStack sevice-types-authority data. It provides easy consumption of official OpenStack service types and their historical aliases, including a built-in version of the data for offline use. Current version is 1.8.2. Being an OpenStack project, its releases typically align with OpenStack development cycles.
Warnings
- gotcha When initializing `ServiceTypes`, if `only_remote=True` is set, the library will not fall back to built-in data upon network failures. This can lead to an `IOError` if remote data cannot be fetched or a `ValueError` if no session object is provided.
- gotcha The `ServiceTypes` constructor accepts a `warn=True` parameter. If enabled, the library will emit warnings when a non-official service type is provided to its methods. This is useful for identifying deprecated or custom service types that might not conform to the official registry.
- breaking The OpenStack Service Types Authority strongly discourages changing official `service-type` names due to the significant breaking implications for users and existing deployments. While the library handles aliases, relying on new alias additions or changes to existing official types can lead to instability. A requested alias cannot match a different alias directly because of historical versioning implications.
Install
-
pip install os-service-types
Imports
- ServiceTypes
from os_service_types import ServiceTypes
Quickstart
from os_service_types import ServiceTypes
# Initialize with built-in data (no network access required)
service_types = ServiceTypes()
# Get data for an official service type
compute_service = service_types.get_official_service_data("compute")
if compute_service:
print(f"Official compute service name: {compute_service.name}")
print(f"Compute project: {compute_service.project}")
print(f"Aliases for compute: {service_types.get_aliases('compute')}")
else:
print("Compute service not found in built-in data.")
# Check if a type is an alias
if service_types.is_alias("nova"): # 'nova' is an alias for 'compute'
print("'nova' is an alias.")
# To fetch remote data, pass a requests.Session or keystoneauth1.session.Session instance:
# import requests
# session = requests.Session()
# remote_service_types = ServiceTypes(session=session)
# remote_image_service = remote_service_types.get_official_service_data("image")
# if remote_image_service:
# print(f"Remote image service name: {remote_image_service.name}")