neutron_lib.utils.runtime module¶
-
class
neutron_lib.utils.runtime.
NamespacedPlugins
(namespace)¶ Bases:
object
Wraps a stevedore plugin namespace to load/access its plugins.
-
get_plugin_class
(plugin_name)¶ Gets a reference to a loaded plugin’s class.
- Parameters
plugin_name – The name of the plugin to get the class for.
- Returns
A reference to the loaded plugin’s class.
- Raises
KeyError if plugin_name is not loaded.
-
property
loaded_plugin_names
¶
-
new_plugin_instance
(plugin_name, *args, **kwargs)¶ Create a new instance of a plugin.
- Parameters
plugin_name – The name of the plugin to instantiate.
args – Any args to pass onto the constructor.
kwargs – Any kwargs to pass onto the constructor.
- Returns
A new instance of plugin_name.
- Raises
KeyError if plugin_name is not loaded.
-
reload
()¶ Force a reload of the plugins for this instances namespace.
- Returns
None.
-
-
neutron_lib.utils.runtime.
list_package_modules
(package_name)¶ Get a list of the modules for a given package.
- Parameters
package_name – The package name to get modules for.
- Returns
A list of module objects for the said package name.
-
neutron_lib.utils.runtime.
load_class_by_alias_or_classname
(namespace, name)¶ Load a class using stevedore alias or the class name.
- Parameters
namespace – The namespace where the alias is defined.
name – The alias or class name of the class to be loaded.
- Returns
Class if it can be loaded.
- Raises
ImportError – if class cannot be loaded.