The nova.loadables Module

Generic Loadable class support.

Meant to be used by such things as scheduler filters and weights where we want to load modules from certain directories and find certain types of classes within those modules. Note that this is quite different than generic plugins and the pluginmanager code that exists elsewhere.

Usage:

Create a directory with an __init__.py with code such as:

class SomeLoadableClass(object):
pass
class MyLoader(nova.loadables.BaseLoader)
def __init__(self):
super(MyLoader, self).__init__(SomeLoadableClass)

If you create modules in the same directory and subclass SomeLoadableClass within them, MyLoader().get_all_classes() will return a list of such classes.

class BaseLoader(loadable_cls_type)

Bases: object

get_all_classes()

Get the classes of the type we want from all modules found in the directory that defines this class.

get_matching_classes(loadable_class_names)

Get loadable classes from a list of names. Each name can be a full module path or the full path to a method that returns classes to use. The latter behavior is useful to specify a method that returns a list of classes to use in a default case.

Previous topic

The nova.keymgr.single_key_mgr Module

Next topic

The nova.manager Module

Project Source

This Page