os-service-types(1)

OS-SERVICE-TYPES(1) os-service-types OS-SERVICE-TYPES(1)

NAME

os-service-types - os-service-types 1.7.0

Contents:

OS-SERVICE-TYPES

Python library for consuming OpenStack sevice-types-authority data

The OpenStack Service Types Authority contains information about official OpenStack services and their historical service-type aliases.

The data is in JSON and the latest data should always be used. This simple library exists to allow for easy consumption of the data, along with a built-in version of the data to use in case network access is for some reason not possible and local caching of the fetched data.

  • Free software: Apache license
  • Documentation: https://docs.openstack.org/os-service-types/latest/
  • Source: https://opendev.org/openstack/os-service-types
  • Bugs: https://storyboard.openstack.org/#!/project/904
  • Release notes: https://docs.openstack.org/releasenotes/os-service-types/

INSTALLATION

At the command line:

$ pip install os-service-types


Or, if you have virtualenvwrapper installed:

$ mkvirtualenv os-service-types
$ pip install os-service-types


USAGE

The most basic use of os-service-types in a project:

import os_service_types
service_types = os_service_types.ServiceTypes()


However, os-service-types expects to be able to fetch remote data, so it's better to pass in a Session object. Both requests.sessions.Session and keystoneauth1.session.Session objects are supported. A keystoneauth1.session.Session object does not need auth information attached, although it will not break anything if it does.

import keystoneauth1.session
import os_service_types
session = keystoneauth1.session.Session()
service_types = os_service_types.ServiceTypes(session=session)


CONTRIBUTOR DOCUMENTATION

Contributing

If you would like to contribute to the development of OpenStack, you must follow the steps in this page:

http://docs.openstack.org/infra/manual/developers.html


If you already have a good understanding of how the system works and your OpenStack accounts are set up, you can skip to the development workflow section of this documentation to learn how changes to OpenStack should be submitted for review via the Gerrit tool:

http://docs.openstack.org/infra/manual/developers.html#development-workflow


Pull requests submitted through GitHub will be ignored.

Bugs should be filed on Storyboard:

https://storyboard.openstack.org/#!/project/904


API REFERENCE

class os_service_types.ServiceTypes(session=None, only_remote=False, warn=False)
Encapsulation of the OpenStack Service Types Authority data.

The Service Types Authority data will be either pulled from its remote location or from local files as is appropriate.

If the user passes a Session, remote data will be fetched. If the user does not do that, local builtin data will be used.

Parameters
  • session -- An object that behaves like a requests.sessions.Session or a keystoneauth1.session.Session that provides a get method and returns an object that behaves like a requests.models.Response. Optional. If session is omitted, no remote actions will be performed.
  • only_remote (bool) -- By default if there is a problem fetching data remotely the builtin data will be returned as a fallback. only_remote will cause remote failures to raise an error instead of falling back. Optional, defaults to False.
  • warn (bool) -- Emit warnings when a non-official service_type is provided. This provides an easy way for consuming applications to warn users when they are using old types.

Raises
  • ValueError -- If session is None and only_remote is True
  • IOError -- If session is given and only_remote is True and there is an error fetching remote data.


property all_types_by_service_type
Mapping of official service type to official type and aliases.

property forward
Mapping service-type names to their aliases.

get_aliases(service_type)
Returns the list of aliases for a given official service-type.
Parameters
service_type (str) -- An official service-type.
Returns list
List of aliases, or empty list if there are none.


get_all_service_data_for_project(project_name)
Return the information for every service associated with a project.
Parameters
name (str) -- A repository or project name in the form 'openstack/{project}' or just '{project}'.
Raises
ValueError -- If project_name is None
Returns
list of dicts


get_all_types(service_type)
Get a list of official types and all known aliases.
Parameters
service_type (str) -- The service-type or alias to get data for.
Returns dict
Service data for the service or None if not found.


get_official_service_data(service_type)
Get the service data for an official service_type.
Parameters
service_type (str) -- The official service-type to get data for.
Returns dict
Service data for the service or None if not found.


get_project_name(service_type)
Return the OpenStack project name for a given service_type.
Parameters
service_type (str) -- An official service-type or alias.
Returns str
The OpenStack project name or None if there is no match.


get_service_data(service_type)
Get the service data for a given service_type.
Parameters
service_type (str) -- The service-type or alias to get data for.
Returns dict
Service data for the service or None if not found.


get_service_data_for_project(project_name)
Return the service information associated with a project.
Parameters
name (str) -- A repository or project name in the form 'openstack/{project}' or just '{project}'.
Raises
ValueError -- If project_name is None
Returns
dict or None if not found


get_service_type(service_type, permissive=False)
Given a possible service_type, return the official type.
Parameters
  • service_type (str) -- A potential service-type.
  • permissive (bool) -- Return the original type if the given service_type is not found.

Returns str
The official service-type, or None if there is no match.


is_alias(service_type)
Is the given service-type an alias?
Parameters
service_type (str) -- The service-type to test.
Returns bool
True if it's an alias type, False otherwise.


is_known(service_type)
Is the given service-type an official type or an alias?
Parameters
service_type (str) -- The service-type to test.
Returns bool
True if it's a known type, False otherwise.


is_match(requested, found)
Does a requested service-type match one found in the catalog?

A requested service-type matches a service-type in the catalog if it is either a direct match, if the service-type in the catalog is an official type and the requested type is one of its aliases, or if the requested type is an official type and the type in the catalog is one of its aliases.

A requested alias cannot match a different alias because there are historical implications related to versioning to some historical aliases that cannot be safely reasoned about in an automatic fashion.

Parameters
  • requested (str) -- A service-type that someone is looking for.
  • found (str) -- A service-type found in a catalog

Returns bool
True if the service-type being requested matches the entry in the catalog. False if it does not.


is_official(service_type)
Is the given service-type an official service-type?
Parameters
service_type (str) -- The service-type to test.
Returns bool
True if it's an official type, False otherwise.


property primary_service_by_project
Mapping of project name to the primary associated service.

property reverse
Mapping aliases to their service-type names.

property service_types_by_project
Mapping of project name to a list of all associated service-types.

property services
Full service-type data listing.

property url
The URL from which the data was retrieved.

property version
The version of the data.


  • Index
  • Search Page

AUTHOR

unknown

COPYRIGHT

2023, OpenStack Developers

October 16, 2023 1.7.0