Extension Manager Classes

Extension Manager Classes

DriverManager

class stevedore.driver.DriverManager(namespace, name, invoke_on_load=False, invoke_args=(), invoke_kwds={}, on_load_failure_callback=None, verify_requirements=False, warn_on_missing_entrypoint=True)

Load a single plugin with a given name from the namespace.

Parameters:
  • namespace (str) – The namespace for the entry points.
  • name (str) – The name of the driver to load.
  • invoke_on_load (bool) – Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded.
  • invoke_args (tuple) – Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • invoke_kwds (dict) – Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • on_load_failure_callback (function) – Callback function that will be called when a entrypoint can not be loaded. The arguments that will be provided when this is called (when an entrypoint fails to load) are (manager, entrypoint, exception)
  • verify_requirements (bool) – Use setuptools to enforce the dependencies of the plugin(s) being loaded. Defaults to False.

HookManager

class stevedore.hook.HookManager(namespace, name, invoke_on_load=False, invoke_args=(), invoke_kwds={}, on_load_failure_callback=None, verify_requirements=False, on_missing_entrypoints_callback=None, warn_on_missing_entrypoint=False)

Coordinate execution of multiple extensions using a common name.

Parameters:
  • namespace (str) – The namespace for the entry points.
  • name (str) – The name of the hooks to load.
  • invoke_on_load (bool) – Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded.
  • invoke_args (tuple) – Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • invoke_kwds (dict) – Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • on_load_failure_callback (function) – Callback function that will be called when a entrypoint can not be loaded. The arguments that will be provided when this is called (when an entrypoint fails to load) are (manager, entrypoint, exception)
  • verify_requirements (bool) – Use setuptools to enforce the dependencies of the plugin(s) being loaded. Defaults to False.
  • verify_requirements – Use setuptools to enforce the dependencies of the plugin(s) being loaded. Defaults to False.
  • warn_on_missing_entrypoint (bool) – Flag to control whether failing to load a plugin is reported via a log mess. Only applies if on_missing_entrypoints_callback is None.

NamedExtensionManager

class stevedore.named.NamedExtensionManager(namespace, names, invoke_on_load=False, invoke_args=(), invoke_kwds={}, name_order=False, propagate_map_exceptions=False, on_load_failure_callback=None, on_missing_entrypoints_callback=None, verify_requirements=False, warn_on_missing_entrypoint=True)

Loads only the named extensions.

This is useful for explicitly enabling extensions in a configuration file, for example.

Parameters:
  • namespace (str) – The namespace for the entry points.
  • names (list(str)) – The names of the extensions to load.
  • invoke_on_load (bool) – Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded.
  • invoke_args (tuple) – Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • invoke_kwds (dict) – Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • name_order (bool) – If true, sort the loaded extensions to match the order used in names.
  • propagate_map_exceptions (bool) – Boolean controlling whether exceptions are propagated up through the map call or whether they are logged and then ignored
  • on_load_failure_callback (function) – Callback function that will be called when a entrypoint can not be loaded. The arguments that will be provided when this is called (when an entrypoint fails to load) are (manager, entrypoint, exception)
  • on_missing_entrypoints_callback (function) – Callback function that will be called when one or more names cannot be found. The provided argument will be a subset of the ‘names’ parameter.
  • verify_requirements (bool) – Use setuptools to enforce the dependencies of the plugin(s) being loaded. Defaults to False.
  • warn_on_missing_entrypoint (bool) – Flag to control whether failing to load a plugin is reported via a log mess. Only applies if on_missing_entrypoints_callback is None.

EnabledExtensionManager

class stevedore.enabled.EnabledExtensionManager(namespace, check_func, invoke_on_load=False, invoke_args=(), invoke_kwds={}, propagate_map_exceptions=False, on_load_failure_callback=None, verify_requirements=False)

Loads only plugins that pass a check function.

The check_func argument should return a boolean, with True indicating that the extension should be loaded and made available and False indicating that the extension should be ignored.

Parameters:
  • namespace (str) – The namespace for the entry points.
  • check_func (callable, taking an Extension instance as argument) – Function to determine which extensions to load.
  • invoke_on_load (bool) – Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded.
  • invoke_args (tuple) – Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • invoke_kwds (dict) – Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • propagate_map_exceptions (bool) – Boolean controlling whether exceptions are propagated up through the map call or whether they are logged and then ignored
  • on_load_failure_callback (function) – Callback function that will be called when a entrypoint can not be loaded. The arguments that will be provided when this is called (when an entrypoint fails to load) are (manager, entrypoint, exception)
  • verify_requirements (bool) – Use setuptools to enforce the dependencies of the plugin(s) being loaded. Defaults to False.

DispatchExtensionManager

class stevedore.dispatch.DispatchExtensionManager(namespace, check_func, invoke_on_load=False, invoke_args=(), invoke_kwds={}, propagate_map_exceptions=False, on_load_failure_callback=None, verify_requirements=False)

Loads all plugins and filters on execution.

This is useful for long-running processes that need to pass different inputs to different extensions.

Parameters:
  • namespace (str) – The namespace for the entry points.
  • check_func (callable) – Function to determine which extensions to load.
  • invoke_on_load (bool) – Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded.
  • invoke_args (tuple) – Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • invoke_kwds (dict) – Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • propagate_map_exceptions – Boolean controlling whether exceptions are propagated up through the map call or whether they are logged and then ignored

NameDispatchExtensionManager

class stevedore.dispatch.NameDispatchExtensionManager(namespace, check_func, invoke_on_load=False, invoke_args=(), invoke_kwds={}, propagate_map_exceptions=False, on_load_failure_callback=None, verify_requirements=False)

Loads all plugins and filters on execution.

This is useful for long-running processes that need to pass different inputs to different extensions and can predict the name of the extensions before calling them.

The check_func argument should return a boolean, with True indicating that the extension should be loaded and made available and False indicating that the extension should be ignored.

Parameters:
  • namespace (str) – The namespace for the entry points.
  • check_func (callable) – Function to determine which extensions to load.
  • invoke_on_load (bool) – Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded.
  • invoke_args (tuple) – Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • invoke_kwds (dict) – Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • propagate_map_exceptions – Boolean controlling whether exceptions are propagated up through the map call or whether they are logged and then ignored
  • on_load_failure_callback (function) – Callback function that will be called when a entrypoint can not be loaded. The arguments that will be provided when this is called (when an entrypoint fails to load) are (manager, entrypoint, exception)
  • verify_requirements (bool) – Use setuptools to enforce the dependencies of the plugin(s) being loaded. Defaults to False.

ExtensionManager

class stevedore.extension.ExtensionManager(namespace, invoke_on_load=False, invoke_args=(), invoke_kwds={}, propagate_map_exceptions=False, on_load_failure_callback=None, verify_requirements=False)

Base class for all of the other managers.

Parameters:
  • namespace (str) – The namespace for the entry points.
  • invoke_on_load (bool) – Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded.
  • invoke_args (tuple) – Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • invoke_kwds (dict) – Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • propagate_map_exceptions (bool) – Boolean controlling whether exceptions are propagated up through the map call or whether they are logged and then ignored
  • on_load_failure_callback (function) – Callback function that will be called when a entrypoint can not be loaded. The arguments that will be provided when this is called (when an entrypoint fails to load) are (manager, entrypoint, exception)
  • verify_requirements (bool) – Use setuptools to enforce the dependencies of the plugin(s) being loaded. Defaults to False.

Extension

class stevedore.extension.Extension(name, entry_point, plugin, obj)

Bases: object

Book-keeping object for tracking extensions.

The arguments passed to the constructor are saved as attributes of the instance using the same names, and can be accessed by the callables passed to map() or when iterating over an ExtensionManager directly.

Parameters:
  • name (str) – The entry point name.
  • entry_point (EntryPoint) – The EntryPoint instance returned by pkg_resources.
  • plugin – The value returned by entry_point.load()
  • obj – The object returned by plugin(*args, **kwds) if the manager invoked the extension on load.
entry_point_target

The module and attribute referenced by this extension’s entry_point.

Returns:A string representation of the target of the entry point in ‘dotted.module:object’ format.

TestExtensionManager

class stevedore.tests.manager.TestExtensionManager(extensions, namespace='test', invoke_on_load=False, invoke_args=(), invoke_kwds={})

ExtensionManager that is explicitly initialized for tests.

Deprecated since version 0.13: Use the make_test_instance() class method of the class being replaced by the test instance instead of using this class directly.

Parameters:
  • extensions (list of Extension) – Pre-configured Extension instances to use instead of loading them from entry points.
  • namespace (str) – The namespace for the entry points.
  • invoke_on_load (bool) – Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded.
  • invoke_args (tuple) – Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
  • invoke_kwds (dict) – Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True.
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.