The passive components to version discovery.
The Discover object in discover.py contains functions that can create objects on your behalf. These functions are not usable from within the keystoneauth1 library because you will get dependency resolution issues.
The Discover object in this file provides the querying components of Discovery. This includes functions like url_for which allow you to retrieve URLs and the raw data specified in version discovery responses.
Bases: object
Return endpoint data for a version.
kept for backwards compatability. New code should use versioned_data_for instead.
version (tuple) – The version is always a minimum version in the same major release as there should be no compatibility issues with using a version newer than the one asked for.
the endpoint data for a URL that matches the required version (the format is described in version_data) or None if no match.
dict
Get raw version information from URL.
Raw data indicates that only minimal validation processing is performed on the data, so what is returned here will be the data in the same format it was received from the endpoint.
allow_experimental (bool) – Allow experimental version endpoints.
allow_deprecated (bool) – Allow deprecated version endpoints.
allow_unknown (bool) – Allow endpoints with an unrecognised status.
The endpoints returned from the server that match the criteria.
list
Get the endpoint url for a version.
kept for backwards compatability. New code should use versioned_url_for instead.
version (tuple) – The version is always a minimum version in the same major release as there should be no compatibility issues with using a version newer than the one asked for.
The url for the specified version or None if no match.
str
Get normalized version data.
Return version data in a structured way.
reverse (bool) – Reverse the list. reverse=true will mean the returned list is sorted from newest to oldest version.
A list of VersionData
sorted by version number.
list(VersionData)
Get normalized version data with versions as strings.
Return version data in a structured way.
reverse (bool) – Reverse the list. reverse=true will mean the returned list is sorted from newest to oldest version.
A list of VersionData
sorted by version number.
list(VersionData)
Return endpoint data for the service at a url.
min_version and max_version can be given either as strings or tuples.
url (string) – If url is given, the data will be returned for the endpoint data that has a self link matching the url.
min_version – The minimum endpoint version that is acceptable. If min_version is given with no max_version it is as if max version is ‘latest’. If min_version is ‘latest’, max_version may only be ‘latest’ or None.
max_version – The maximum endpoint version that is acceptable. If min_version is given with no max_version it is as if max version is ‘latest’. If min_version is ‘latest’, max_version may only be ‘latest’ or None.
the endpoint data for a URL that matches the required version (the format is described in version_data) or None if no match.
dict
Get the endpoint url for a version.
min_version and max_version can be given either as strings or tuples.
min_version – The minimum version that is acceptable. If min_version is given with no max_version it is as if max version is ‘latest’.
max_version – The maximum version that is acceptable. If min_version is given with no max_version it is as if max version is ‘latest’.
The url for the specified version or None if no match.
str
Bases: object
Normalized information about a discovered endpoint.
Contains url, version, microversion, interface and region information. This is essentially the data contained in the catalog and the version discovery documents about an endpoint that is used to select the endpoint desired by the user. It is returned so that a user can know which qualities a discovered endpoint had, in case their request allowed for a range of possibilities.
Return version data for all versions discovery can find.
project_id (string) – ID of the currently scoped project. Used for removing project_id components of URLs from the catalog. (optional)
A list of VersionData
sorted by version number.
list(VersionData)
Run version discovery on the current endpoint.
A simplified version of get_versioned_data, get_current_versioned_data runs discovery but only on the endpoint that has been found already.
It can be useful in some workflows where the user wants version information about the endpoint they have.
session (keystoneauth1.session.Session) – A session object that can be used for communication.
allow (dict) – Extra filters to pass when discovering API versions. (optional)
cache (dict) – A dict to be used for caching results in addition to caching them on the Session. (optional)
project_id (string) – ID of the currently scoped project. Used for removing project_id components of URLs from the catalog. (optional)
A new EndpointData with the requested versioned data.
keystoneauth1.exceptions.discovery.DiscoveryFailure – If the appropriate versioned data could not be discovered.
Run version discovery for the service described.
Performs Version Discovery and returns a new EndpointData object with information found.
min_version and max_version can be given either as strings or tuples.
session (keystoneauth1.session.Session) – A session object that can be used for communication.
allow (dict) – Extra filters to pass when discovering API versions. (optional)
cache (dict) – A dict to be used for caching results in addition to caching them on the Session. (optional)
allow_version_hack (bool) – Allow keystoneauth to hack up catalog URLS to support older schemes. (optional, default True)
project_id (string) – ID of the currently scoped project. Used for removing project_id components of URLs from the catalog. (optional)
discover_versions (bool) – Whether to get version metadata from the version discovery document even if it’s not neccessary to fulfill the major version request. (optional, defaults to True)
min_version – The minimum version that is acceptable. If min_version is given with no max_version it is as if max version is ‘latest’.
max_version – The maximum version that is acceptable. If min_version is given with no max_version it is as if max version is ‘latest’.
A new EndpointData with the requested versioned data.
keystoneauth1.exceptions.discovery.DiscoveryFailure – If the appropriate versioned data could not be discovered.
Bases: object
Turn a status into a canonical status value.
If the status from the version discovery document does not match one of the known values, it will be set to ‘UNKNOWN’.
raw_status (str) – Status value from a discovery document.
A canonicalized version of the status. Valid values are CURRENT, SUPPORTED, DEPRECATED, EXPERIMENTAL and UNKNOWN
str
Bases: dict
Normalized Version Data about an endpoint.
The URL for the discovery document.
May be None.
The maximum microversion supported by the endpoint.
May be None.
The minimum microversion supported by the endpoint.
May be None.
The status as provided by the server.
A canonicalized version of the status.
Valid values are CURRENT, SUPPORTED, DEPRECATED and EXPERIMENTAL.
The url for the endpoint.
The normalized version of the endpoint.
Add a version removal rule for a particular service.
Originally deployments of OpenStack would contain a versioned endpoint in
the catalog for different services. E.g. an identity service might look
like http://localhost:5000/v2.0
. This is a problem when we want to use
a different version like v3.0 as there is no way to tell where it is
located. We cannot simply change all service catalogs either so there must
be a way to handle the older style of catalog.
This function adds a rule for a given service type that if part of the URL matches a given regular expression in old then it will be replaced with the new value. This will replace all instances of old with new. It should therefore contain a regex anchor.
For example the included rule states:
add_catalog_version_hack('identity', re.compile('/v2.0/?$'), '/')
so if the catalog retrieves an identity URL that ends with /v2.0 or /v2.0/ then it should replace it simply with / to fix the user’s catalog.
service_type (str) – The service type as defined in the catalog that the rule will apply to.
old (re.RegexObject) – The regular expression to search for and replace if found.
new (str) – The new string to replace the pattern with.
Return the discovery object for a URL.
Check the session and the plugin cache to see if we have already performed discovery on the URL and if so return it, otherwise create a new discovery object, cache it and return it.
NOTE: This function is expected to be used by keystoneauth and should not be needed by users part of normal usage. A normal user should use get_endpoint or get_endpoint_data on keystoneauth.session.Session or endpoint_filters on keystoneauth.session.Session or keystoneauth.session.Session. However, should the user need to perform direct discovery for some reason, this function should be used so that the discovery caching is used.
session (keystoneauth1.session.Session) – A session object to discover with.
url (str) – The url to lookup.
cache (dict) – A dict to be used for caching results, in addition to caching them on the Session. (optional) Defaults to None.
authenticated (bool) – Include a token in the discovery call. (optional) Defaults to None, which will use a token if an auth plugin is installed.
keystoneauth1.exceptions.discovery.DiscoveryFailure – if for some reason the lookup fails.
keystoneauth1.exceptions.http.HttpError – An error from an invalid HTTP response.
A discovery object with the results of looking up that URL.
keystoneauth1.discover.Discovery
Retrieve raw version data from a url.
The return is a list of dicts of the form:
[{
'status': 'STABLE',
'id': 'v2.3',
'links': [
{
'href': 'http://network.example.com/v2.3',
'rel': 'self',
},
{
'href': 'http://network.example.com/',
'rel': 'collection',
},
],
'min_version': '2.0',
'max_version': '2.7',
},
...,
]
Note: The maximum microversion may be specified by max_version or version, the former superseding the latter. All *version keys are optional. Other keys and ‘links’ entries are permitted, but ignored.
session (keystoneauth1.session.Session) – A Session object that can be used for communication.
url (string) – Endpoint or discovery URL from which to retrieve data.
authenticated (bool) – Include a token in the discovery call. (optional) Defaults to None.
A list of dicts containing version information.
list(dict)
Turn a version representation into a tuple.
Examples:
The following all produce a return value of (1, 0):
1, '1', 'v1', [1], (1,), ['1'], 1.0, '1.0', 'v1.0', (1, 0)
The following all produce a return value of (1, 20, 3):
'v1.20.3', '1.20.3', (1, 20, 3), ['1', '20', '3']
The following all produce a return value of (LATEST, LATEST):
'latest', 'vlatest', ('latest', 'latest'), (LATEST, LATEST)
The following all produce a return value of (2, LATEST):
'2.latest', 'v2.latest', (2, LATEST), ('2', 'latest')
version – A version specifier in any of the following forms: String, possibly prefixed with ‘v’, containing one or more numbers or the string ‘latest’, separated by periods. Examples: ‘v1’, ‘v1.2’, ‘1.2.3’, ‘123’, ‘latest’, ‘1.latest’, ‘v1.latest’. Integer. This will be assumed to be the major version, with a minor version of 0. Float. The integer part is assumed to be the major version; the decimal part the minor version. Non-string iterable comprising integers, integer strings, the string ‘latest’, or the special value LATEST. Examples: (1,), [1, 2], (‘12’, ‘34’, ‘56’), (LATEST,), (2, ‘latest’)
A tuple of len >= 2 comprising integers and/or LATEST.
TypeError – If the input version cannot be interpreted.
Determine whether a candidate version is within a specified range.
min_version – The minimum version that is acceptable. None/empty indicates no lower bound.
max_version – The maximum version that is acceptable. None/empty indicates no upper bound.
candidate – Candidate version to test. May not be None/empty.
True if candidate is between min_version and max_version; False otherwise.
ValueError – If candidate is None.
TypeError – If any input cannot be normalized.
Test that an available version satisfies the required version.
To be suitable a version must be of the same major version as required and be at least a match in minor/patch level.
eg. 3.3 is a match for a required 3.1 but 4.1 is not.
required (tuple) – the version that must be met.
candidate (tuple) – the version to test against required.
True if candidate is suitable False otherwise.
bool
Turn a version tuple into a string.
version (tuple) – A version represented as a tuple of ints. As a special case, a tuple member may be LATEST, which translates to ‘latest’.
A version represented as a period-delimited string.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.