keystoneauth1.adapter module

keystoneauth1.adapter module

class keystoneauth1.adapter.Adapter(session, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None)

Bases: object

An instance of a session with local variables.

A session is a global object that is shared around amongst many clients. It therefore contains state that is relevant to everyone. There is a lot of state such as the service type and region_name that are only relevant to a particular client that is using the session. An adapter provides a wrapper of client local data around the global session object.

version, min_version, max_version and default_microversion can all be given either as a string or a tuple.

Parameters
  • session (keystoneauth1.session.Session) – The session object to wrap.

  • service_type (str) – The default service_type for URL discovery.

  • service_name (str) – The default service_name for URL discovery.

  • interface (str) – The default interface for URL discovery.

  • region_name (str) – The default region_name for URL discovery.

  • endpoint_override (str) – Always use this endpoint URL for requests for this client.

  • version – The minimum version restricted to a given Major API. Mutually exclusive with min_version and max_version. (optional)

  • auth (keystoneauth1.plugin.BaseAuthPlugin) – An auth plugin to use instead of the session one.

  • user_agent (str) – The User-Agent string to set.

  • connect_retries (int) – The maximum number of retries that should be attempted for connection errors. Default None - use session default which is don’t retry.

  • logger (logging.Logger) – A logging object to use for requests that pass through this adapter.

  • allow (dict) – Extra filters to pass when discovering API versions. (optional)

  • additional_headers (dict) – Additional headers that should be attached to every request passing through the adapter. Headers of the same name specified per request will take priority.

  • client_name (str) – The name of the client that created the adapter. This will be used to create the user_agent.

  • client_version (str) – The version of the client that created the adapter. This will be used to create the user_agent.

  • allow_version_hack (bool) – Allow keystoneauth to hack up catalog URLS to support older schemes. (optional, default True)

  • global_request_id (str) – A global_request_id (in the form of req-$uuid) that will be passed on all requests. Enables cross project request id tracking.

  • min_version – The minimum major version of a given API, intended to be used as the lower bound of a range with max_version. Mutually exclusive with version. If min_version is given with no max_version it is as if max version is ‘latest’. (optional)

  • max_version – The maximum major version of a given API, intended to be used as the upper bound of a range with min_version. Mutually exclusive with version. (optional)

  • default_microversion – The default microversion value to send with API requests. While microversions are a per-request feature, a user may know they want to default to sending a specific value. (optional)

  • status_code_retries (int) – The maximum number of retries that should be attempted for retriable HTTP status codes (optional, defaults to 0 - never retry).

  • retriable_status_codes (list) – List of HTTP status codes that should be retried (optional, defaults to HTTP 503, has no effect when status_code_retries is 0).

  • raise_exc (bool) – If True, requests returning failing HTTP responses will raise an exception; if False, the response is returned. This can be overridden on a per-request basis via the kwarg of the same name.

  • rate_limit (float) – A client-side rate limit to impose on requests made through this adapter in requests per second. For instance, a rate_limit of 2 means to allow no more than 2 requests per second, and a rate_limit of 0.5 means to allow no more than 1 request every two seconds. (optional, defaults to None, which means no rate limiting will be applied).

  • concurrency (int) – How many simultaneous http requests this Adapter can be used for. (optional, defaults to None, which means no limit).

  • connect_retry_delay (float) – Delay (in seconds) between two connect retries (if enabled). By default exponential retry starting with 0.5 seconds up to a maximum of 60 seconds is used.

  • status_code_retry_delay (float) – Delay (in seconds) between two status code retries (if enabled). By default exponential retry starting with 0.5 seconds up to a maximum of 60 seconds is used.

client_name = None
client_version = None
delete(url, **kwargs)
get(url, **kwargs)
get_all_version_data(interface='public', region_name=None)

Get data about all versions of a service.

Parameters
  • interface – Type of endpoint to get version data for. Can be a single value or a list of values. A value of None indicates that all interfaces should be queried. (optional, defaults to public)

  • region_name (string) – Region of endpoints to get version data for. A valueof None indicates that all regions should be queried. (optional, defaults to None)

Returns

A dictionary keyed by region_name with values containing dictionaries keyed by interface with values being a list of VersionData.

get_api_major_version(auth=None, **kwargs)

Get the major API version as provided by the auth plugin.

Parameters

auth (keystoneauth1.plugin.BaseAuthPlugin) – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises

keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – if a plugin is not available.

Returns

The major version of the API of the service discovered.

Return type

tuple or None

get_endpoint(auth=None, **kwargs)

Get an endpoint as provided by the auth plugin.

Parameters

auth (keystoneauth1.plugin.BaseAuthPlugin) – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises

keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – if a plugin is not available.

Returns

An endpoint if available or None.

Return type

str

get_endpoint_data(auth=None)

Get the endpoint data for this Adapter’s endpoint.

Parameters

auth (keystoneauth1.plugin.BaseAuthPlugin) – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises
Returns

Endpoint data if available or None.

Return type

keystoneauth1.discover.EndpointData

get_project_id(auth=None)

Return the authenticated project_id as provided by the auth plugin.

Parameters

auth (keystoneauth1.plugin.BaseAuthPlugin) – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises
Returns

Current project_id or None if not supported by plugin.

Return type

str

get_token(auth=None)

Return a token as provided by the auth plugin.

Parameters

auth (keystoneauth1.plugin.BaseAuthPlugin) – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises

keystoneauth1.exceptions.auth.AuthorizationFailure – if a new token fetch fails.

Returns

A valid token.

Return type

str

get_user_id(auth=None)

Return the authenticated user_id as provided by the auth plugin.

Parameters

auth (keystoneauth1.plugin.BaseAuthPlugin) – The auth plugin to use for token. Overrides the plugin on the session. (optional)

Raises
Returns

Current user_id or None if not supported by plugin.

Return type

str

head(url, **kwargs)
invalidate(auth=None)

Invalidate an authentication plugin.

patch(url, **kwargs)
post(url, **kwargs)
put(url, **kwargs)
classmethod register_argparse_arguments(parser, service_type=None)

Attach arguments to a given argparse Parser for Adapters.

Parameters
  • parser (argparse.ArgumentParser) – The argparse parser to attach options to.

  • service_type (str) – Default service_type value. (optional)

classmethod register_service_argparse_arguments(parser, service_type)

Attach arguments to a given argparse Parser for Adapters.

Parameters
  • parser (argparse.ArgumentParser) – The argparse parser to attach options to.

  • service_type (str) – Name of a service to generate additional arguments for.

request(url, method, **kwargs)
class keystoneauth1.adapter.LegacyJsonAdapter(session, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None)

Bases: keystoneauth1.adapter.Adapter

Make something that looks like an old HTTPClient.

A common case when using an adapter is that we want an interface similar to the HTTPClients of old which returned the body as JSON as well.

You probably don’t want this if you are starting from scratch.

request(*args, **kwargs)
keystoneauth1.adapter.register_adapter_argparse_arguments(*args, **kwargs)
keystoneauth1.adapter.register_service_adapter_argparse_arguments(*args, **kwargs)
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.