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.