c7n.registry module

class c7n.registry.PluginRegistry(plugin_type)[source]

Bases: object

A plugin registry

Custodian is intended to be innately pluggable both internally and externally, for resource types and their filters and actions.

This plugin registry abstraction provides the core mechanism for that. Its a simple string to class map, with python package entry_point loading for external plugins.

As an example of defining an external plugin using a python package

setup(
    name="custodian_cmdb",
    description="Custodian filters for interacting with internal CMDB"
    version='1.0',
    packages=find_packages(),
    entry_points={
         'console_scripts': [
              'custodian.ec2.filters = custodian_cmdb:filter_ec2']},
    )

For loading the plugins we can simply invoke method:load_plugins like so:

PluginRegistry('ec2.filters').load_plugins()
EVENTS = (0, 1)
EVENT_FINAL = 1
EVENT_REGISTER = 0
get(name)[source]
items()[source]
keys()[source]
load_plugins()[source]

Load external plugins.

Custodian is intended to interact with internal and external systems that are not suitable for embedding into the custodian code base.

notify(event, key=None)[source]
register(name, klass=None, condition=True, condition_message='Missing dependency for {}')[source]
subscribe(event, func)[source]
unregister(name)[source]
values()[source]