keystoneauth1.loading package

Submodules

keystoneauth1.loading.base module

keystoneauth1.loading.base.get_available_plugin_names()

Get the names of all the plugins that are available on the system.

This is particularly useful for help and error text to prompt a user for example what plugins they may specify.

Returns:A list of names.
Return type:frozenset
keystoneauth1.loading.base.get_available_plugin_loaders()

Retrieve all the plugin classes available on the system.

Returns:A dict with plugin entrypoint name as the key and the plugin loader as the value.
Return type:dict
keystoneauth1.loading.base.get_plugin_loader(name)

Retrieve a plugin class by its entrypoint name.

Parameters:name (str) – The name of the object to get.
Returns:An auth plugin class.
Return type:keystoneauth1.loading.BaseLoader
Raises keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin:
 if a plugin cannot be created.
keystoneauth1.loading.base.get_plugin_options(name)

Get the options for a specific plugin.

This will be the list of options that is registered and loaded by the specified plugin.

Returns:A list of keystoneauth1.loading.Opt options.
Raises keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin:
 if a plugin cannot be created.
class keystoneauth1.loading.base.BaseLoader

Bases: object

available

Return if the plugin is available for loading.

If a plugin is missing dependencies or for some other reason should not be available to the current system it should override this property and return False to exclude itself from the plugin list.

Return type:bool
create_plugin(**kwargs)

Create a plugin from the options available for the loader.

Given the options that were specified by the loader create an appropriate plugin. You can override this function in your loader.

This used to be specified by providing the plugin_class property and this is still supported, however specifying a property didn’t let you choose a plugin type based upon the options that were presented.

Override this function if you wish to return different plugins based on the options presented, otherwise you can simply provide the plugin_class property.

Added 2.9

get_options()

Return the list of parameters associated with the auth plugin.

This list may be used to generate CLI or config arguments.

Returns:A list of Param objects describing available plugin parameters.
Return type:list
load_from_options(**kwargs)

Create a plugin from the arguments retrieved from get_options.

A client can override this function to do argument validation or to handle differences between the registered options and what is required to create the plugin.

load_from_options_getter(getter, **kwargs)

Load a plugin from getter function that returns appropriate values.

To handle cases other than the provided CONF and CLI loading you can specify a custom loader function that will be queried for the option value. The getter is a function that takes a keystoneauth1.loading.Opt and returns a value to load with.

Parameters:getter (callable) – A function that returns a value for the given opt.
Returns:An authentication Plugin.
Return type:keystoneauth1.plugin.BaseAuthPlugin
plugin_class

keystoneauth1.loading.cli module

keystoneauth1.loading.cli.register_argparse_arguments(parser, argv, default=None)

Register CLI options needed to create a plugin.

The function inspects the provided arguments so that it can also register the options required for that specific plugin if available.

Parameters:
  • parser (argparse.ArgumentParser) – the parser to attach argparse options to.
  • argv (list) – the arguments provided to the appliation.
  • default (str/class) – a default plugin name or a plugin object to use if one isn’t specified by the CLI. default: None.
Returns:

The plugin class that will be loaded or None if not provided.

Return type:

keystoneauth1.plugin.BaseAuthPlugin

Raises keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin:
 

if a plugin cannot be created.

keystoneauth1.loading.cli.load_from_argparse_arguments(namespace, **kwargs)

Retrieve the created plugin from the completed argparse results.

Loads and creates the auth plugin from the information parsed from the command line by argparse.

Parameters:namespace (Namespace) – The result from CLI parsing.
Returns:An auth plugin, or None if a name is not provided.
Return type:keystoneauth1.plugin.BaseAuthPlugin
Raises keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin:
 if a plugin cannot be created.

keystoneauth1.loading.conf module

keystoneauth1.loading.conf.get_common_conf_options()

Get the oslo_config options common for all auth plugins.

These may be useful without being registered for config file generation or to manipulate the options before registering them yourself.

The options that are set are:
auth_type:The name of the plugin to load.
auth_section:The config file section to load options from.
Returns:A list of oslo_config options.
keystoneauth1.loading.conf.get_plugin_conf_options(plugin)

Get the oslo_config options for a specific plugin.

This will be the list of config options that is registered and loaded by the specified plugin.

Parameters:plugin (str or keystoneauth1._loading.BaseLoader) – The name of the plugin loader or a plugin loader object
Returns:A list of oslo_config options.
keystoneauth1.loading.conf.register_conf_options(conf, group)

Register the oslo_config options that are needed for a plugin.

This only registers the basic options shared by all plugins. Options that are specific to a plugin are loaded just before they are read.

The defined options are:

  • auth_type: the name of the auth plugin that will be used for
    authentication.
  • auth_section: the group from which further auth plugin options should be
    taken. If section is not provided then the auth plugin options will be taken from the same group as provided in the parameters.
Parameters:
keystoneauth1.loading.conf.load_from_conf_options(conf, group, **kwargs)

Load a plugin from an oslo_config CONF object.

Each plugin will register their own required options and so there is no standard list and the plugin should be consulted.

The base options should have been registered with register_conf_options before this function is called.

Parameters:
Returns:

An authentication Plugin or None if a name is not provided

Return type:

keystoneauth1.plugin.BaseAuthPlugin

Raises keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin:
 

if a plugin cannot be created.

keystoneauth1.loading.identity module

class keystoneauth1.loading.identity.BaseIdentityLoader

Bases: keystoneauth1.loading.base.BaseLoader

Base Option handling for identity plugins.

This class defines options and handling that should be common across all plugins that are developed against the OpenStack identity service. It provides the options expected by the keystoneauth1.identity.BaseIdentityPlugin class.

get_options()
class keystoneauth1.loading.identity.BaseV2Loader

Bases: keystoneauth1.loading.identity.BaseIdentityLoader

Base Option handling for identity plugins.

This class defines options and handling that should be common to the V2 identity API. It provides the options expected by the keystoneauth1.identity.v2.Auth class.

get_options()
class keystoneauth1.loading.identity.BaseV3Loader

Bases: keystoneauth1.loading.identity.BaseIdentityLoader

Base Option handling for identity plugins.

This class defines options and handling that should be common to the V3 identity API. It provides the options expected by the keystoneauth1.identity.v3.Auth class.

get_options()
load_from_options(**kwargs)
class keystoneauth1.loading.identity.BaseFederationLoader

Bases: keystoneauth1.loading.identity.BaseV3Loader

Base Option handling for federation plugins.

This class defines options and handling that should be common to the V3 identity federation API. It provides the options expected by the keystoneauth1.identity.v3.FederationBaseAuth class.

get_options()
class keystoneauth1.loading.identity.BaseGenericLoader

Bases: keystoneauth1.loading.identity.BaseIdentityLoader

Base Option handling for generic plugins.

This class defines options and handling that should be common to generic plugins. These plugins target the OpenStack identity service however are designed to be independent of API version. It provides the options expected by the keystoneauth1.identity.v3.BaseGenericPlugin class.

get_options()

keystoneauth1.loading.opts module

class keystoneauth1.loading.opts.Opt(name, type=<type 'str'>, help=None, secret=False, dest=None, deprecated=None, default=None, metavar=None, required=False, prompt=None)

Bases: object

An option required by an authentication plugin.

Opts provide a means for authentication plugins that are going to be dynamically loaded to specify the parameters that are to be passed to the plugin on initialization.

The Opt specifies information about the way the plugin parameter is to be represented in different loading mechanisms.

When defining an Opt with a - the - should be present in the name parameter. This will automatically be converted to an _ when passing to the plugin initialization. For example, you should specify:

Opt('user-domain-id')

which will pass the value as user_domain_id to the plugin’s initialization.

Parameters:
  • name (str) – The name of the option.
  • type (callable) – The type of the option. This is a callable which is passed the raw option that was loaded (often a string) and is required to return the parameter in the type expected by __init__.
  • help (str) – The help text that is shown along with the option.
  • secret (bool) – If the parameter is secret it should not be printed or logged in debug output.
  • dest (str) – the name of the argument that will be passed to __init__. This allows you to have a different name in loading than is used by the __init__ function. Defaults to the the value of name.
  • opt (list(Opt)) – A list of other options that are deprecated in favour of this one. This ensures the old options are still registered.
  • default – A default value that can be used if one is not provided.
  • metavar (str) – The <metavar> that should be printed in CLI help text.
  • required (bool) – If the option is required to load the plugin. If a required option is not present loading should fail.
  • prompt (str) – If the option can be requested via a prompt (where appropriate) set the string that should be used to prompt with.
argparse_args
argparse_default

keystoneauth1.loading.session module

keystoneauth1.loading.session.register_argparse_arguments(*args, **kwargs)
keystoneauth1.loading.session.load_from_argparse_arguments(*args, **kwargs)
keystoneauth1.loading.session.register_conf_options(*args, **kwargs)
keystoneauth1.loading.session.load_from_conf_options(*args, **kwargs)
keystoneauth1.loading.session.get_conf_options(*args, **kwargs)

Module contents

class keystoneauth1.loading.BaseLoader

Bases: object

available

Return if the plugin is available for loading.

If a plugin is missing dependencies or for some other reason should not be available to the current system it should override this property and return False to exclude itself from the plugin list.

Return type:bool
create_plugin(**kwargs)

Create a plugin from the options available for the loader.

Given the options that were specified by the loader create an appropriate plugin. You can override this function in your loader.

This used to be specified by providing the plugin_class property and this is still supported, however specifying a property didn’t let you choose a plugin type based upon the options that were presented.

Override this function if you wish to return different plugins based on the options presented, otherwise you can simply provide the plugin_class property.

Added 2.9

get_options()

Return the list of parameters associated with the auth plugin.

This list may be used to generate CLI or config arguments.

Returns:A list of Param objects describing available plugin parameters.
Return type:list
load_from_options(**kwargs)

Create a plugin from the arguments retrieved from get_options.

A client can override this function to do argument validation or to handle differences between the registered options and what is required to create the plugin.

load_from_options_getter(getter, **kwargs)

Load a plugin from getter function that returns appropriate values.

To handle cases other than the provided CONF and CLI loading you can specify a custom loader function that will be queried for the option value. The getter is a function that takes a keystoneauth1.loading.Opt and returns a value to load with.

Parameters:getter (callable) – A function that returns a value for the given opt.
Returns:An authentication Plugin.
Return type:keystoneauth1.plugin.BaseAuthPlugin
plugin_class
keystoneauth1.loading.get_available_plugin_names()

Get the names of all the plugins that are available on the system.

This is particularly useful for help and error text to prompt a user for example what plugins they may specify.

Returns:A list of names.
Return type:frozenset
keystoneauth1.loading.get_available_plugin_loaders()

Retrieve all the plugin classes available on the system.

Returns:A dict with plugin entrypoint name as the key and the plugin loader as the value.
Return type:dict
keystoneauth1.loading.get_plugin_loader(name)

Retrieve a plugin class by its entrypoint name.

Parameters:name (str) – The name of the object to get.
Returns:An auth plugin class.
Return type:keystoneauth1.loading.BaseLoader
Raises keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin:
 if a plugin cannot be created.
class keystoneauth1.loading.BaseIdentityLoader

Bases: keystoneauth1.loading.base.BaseLoader

Base Option handling for identity plugins.

This class defines options and handling that should be common across all plugins that are developed against the OpenStack identity service. It provides the options expected by the keystoneauth1.identity.BaseIdentityPlugin class.

get_options()
class keystoneauth1.loading.BaseV2Loader

Bases: keystoneauth1.loading.identity.BaseIdentityLoader

Base Option handling for identity plugins.

This class defines options and handling that should be common to the V2 identity API. It provides the options expected by the keystoneauth1.identity.v2.Auth class.

get_options()
class keystoneauth1.loading.BaseV3Loader

Bases: keystoneauth1.loading.identity.BaseIdentityLoader

Base Option handling for identity plugins.

This class defines options and handling that should be common to the V3 identity API. It provides the options expected by the keystoneauth1.identity.v3.Auth class.

get_options()
load_from_options(**kwargs)
class keystoneauth1.loading.BaseFederationLoader

Bases: keystoneauth1.loading.identity.BaseV3Loader

Base Option handling for federation plugins.

This class defines options and handling that should be common to the V3 identity federation API. It provides the options expected by the keystoneauth1.identity.v3.FederationBaseAuth class.

get_options()
class keystoneauth1.loading.BaseGenericLoader

Bases: keystoneauth1.loading.identity.BaseIdentityLoader

Base Option handling for generic plugins.

This class defines options and handling that should be common to generic plugins. These plugins target the OpenStack identity service however are designed to be independent of API version. It provides the options expected by the keystoneauth1.identity.v3.BaseGenericPlugin class.

get_options()
keystoneauth1.loading.register_auth_argparse_arguments(parser, argv, default=None)

Register CLI options needed to create a plugin.

The function inspects the provided arguments so that it can also register the options required for that specific plugin if available.

Parameters:
  • parser (argparse.ArgumentParser) – the parser to attach argparse options to.
  • argv (list) – the arguments provided to the appliation.
  • default (str/class) – a default plugin name or a plugin object to use if one isn’t specified by the CLI. default: None.
Returns:

The plugin class that will be loaded or None if not provided.

Return type:

keystoneauth1.plugin.BaseAuthPlugin

Raises keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin:
 

if a plugin cannot be created.

keystoneauth1.loading.load_auth_from_argparse_arguments(namespace, **kwargs)

Retrieve the created plugin from the completed argparse results.

Loads and creates the auth plugin from the information parsed from the command line by argparse.

Parameters:namespace (Namespace) – The result from CLI parsing.
Returns:An auth plugin, or None if a name is not provided.
Return type:keystoneauth1.plugin.BaseAuthPlugin
Raises keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin:
 if a plugin cannot be created.
keystoneauth1.loading.get_auth_common_conf_options()

Get the oslo_config options common for all auth plugins.

These may be useful without being registered for config file generation or to manipulate the options before registering them yourself.

The options that are set are:
auth_type:The name of the plugin to load.
auth_section:The config file section to load options from.
Returns:A list of oslo_config options.
keystoneauth1.loading.get_auth_plugin_conf_options(plugin)

Get the oslo_config options for a specific plugin.

This will be the list of config options that is registered and loaded by the specified plugin.

Parameters:plugin (str or keystoneauth1._loading.BaseLoader) – The name of the plugin loader or a plugin loader object
Returns:A list of oslo_config options.
keystoneauth1.loading.register_auth_conf_options(conf, group)

Register the oslo_config options that are needed for a plugin.

This only registers the basic options shared by all plugins. Options that are specific to a plugin are loaded just before they are read.

The defined options are:

  • auth_type: the name of the auth plugin that will be used for
    authentication.
  • auth_section: the group from which further auth plugin options should be
    taken. If section is not provided then the auth plugin options will be taken from the same group as provided in the parameters.
Parameters:
keystoneauth1.loading.load_auth_from_conf_options(conf, group, **kwargs)

Load a plugin from an oslo_config CONF object.

Each plugin will register their own required options and so there is no standard list and the plugin should be consulted.

The base options should have been registered with register_conf_options before this function is called.

Parameters:
Returns:

An authentication Plugin or None if a name is not provided

Return type:

keystoneauth1.plugin.BaseAuthPlugin

Raises keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin:
 

if a plugin cannot be created.

keystoneauth1.loading.register_session_argparse_arguments(*args, **kwargs)
keystoneauth1.loading.load_session_from_argparse_arguments(*args, **kwargs)
keystoneauth1.loading.register_session_conf_options(*args, **kwargs)
keystoneauth1.loading.load_session_from_conf_options(*args, **kwargs)
keystoneauth1.loading.get_session_conf_options(*args, **kwargs)
class keystoneauth1.loading.Opt(name, type=<type 'str'>, help=None, secret=False, dest=None, deprecated=None, default=None, metavar=None, required=False, prompt=None)

Bases: object

An option required by an authentication plugin.

Opts provide a means for authentication plugins that are going to be dynamically loaded to specify the parameters that are to be passed to the plugin on initialization.

The Opt specifies information about the way the plugin parameter is to be represented in different loading mechanisms.

When defining an Opt with a - the - should be present in the name parameter. This will automatically be converted to an _ when passing to the plugin initialization. For example, you should specify:

Opt('user-domain-id')

which will pass the value as user_domain_id to the plugin’s initialization.

Parameters:
  • name (str) – The name of the option.
  • type (callable) – The type of the option. This is a callable which is passed the raw option that was loaded (often a string) and is required to return the parameter in the type expected by __init__.
  • help (str) – The help text that is shown along with the option.
  • secret (bool) – If the parameter is secret it should not be printed or logged in debug output.
  • dest (str) – the name of the argument that will be passed to __init__. This allows you to have a different name in loading than is used by the __init__ function. Defaults to the the value of name.
  • opt (list(Opt)) – A list of other options that are deprecated in favour of this one. This ensures the old options are still registered.
  • default – A default value that can be used if one is not provided.
  • metavar (str) – The <metavar> that should be printed in CLI help text.
  • required (bool) – If the option is required to load the plugin. If a required option is not present loading should fail.
  • prompt (str) – If the option can be requested via a prompt (where appropriate) set the string that should be used to prompt with.
argparse_args
argparse_default