neutron_lib.callbacks package

neutron_lib.callbacks package

Submodules

neutron_lib.callbacks.events module

class neutron_lib.callbacks.events.APIEventPayload(context, method_name, action, metadata=None, request_body=None, states=None, resource_id=None, collection_name=None)

Bases: neutron_lib.callbacks.events.EventPayload

The payload for API events.

class neutron_lib.callbacks.events.DBEventPayload(context, metadata=None, request_body=None, states=None, resource_id=None, desired_state=None)

Bases: neutron_lib.callbacks.events.EventPayload

The payload for data store events payloads.

is_persisted

Determine if the resource for this event payload is persisted.

Returns:True if this payload’s resource is persisted, otherwise False.
is_to_be_committed

“Determine if the event payload resource is to be committed.

Returns:True if the desired state has been populated, else False.
latest_state

Returns the latest state for the event payload resource.

Returns:If this payload has a desired_state its returned, otherwise latest_state is returned.
class neutron_lib.callbacks.events.EventPayload(context, metadata=None, request_body=None, states=None, resource_id=None)

Bases: object

Base event payload object.

This class is intended to be the super class for all event payloads. As such, it defines common attributes many events are likely to use in their payload. Note that event attributes are passed by reference; no copying of states, metadata or request_body is performed and thus consumers should not modify payload references.

For more information, see the callbacks dev-ref documentation for this project.

has_states

Determines if this event payload has any states.

Returns:True if this event payload has states, otherwise False.
latest_state

Returns the latest state for the event payload.

Returns:The last state of this event payload if has_state else None.

neutron_lib.callbacks.exceptions module

exception neutron_lib.callbacks.exceptions.CallbackFailure(errors)

Bases: neutron_lib.exceptions.MultipleExceptions

inner_exceptions

The list of unpacked errors for this exception.

Returns:A list of unpacked errors for this exception. An unpacked error is the Exception’s ‘error’ attribute if it inherits from NotificationError, otherwise it’s the exception itself.
exception neutron_lib.callbacks.exceptions.Invalid(**kwargs)

Bases: neutron_lib.exceptions.NeutronException

message = u"The value '%(value)s' for %(element)s is not valid."
class neutron_lib.callbacks.exceptions.NotificationError(callback_id, error)

Bases: object

neutron_lib.callbacks.manager module

class neutron_lib.callbacks.manager.CallbacksManager

Bases: object

A callback system that allows objects to cooperate in a loose manner.

clear()

Brings the manager to a clean slate.

notify(*args, **kwargs)

Notify all subscribed callback(s).

Dispatch the resource’s event to the subscribed callbacks.

Parameters:
  • resource – The resource for the event.
  • event – The event.
  • trigger – The trigger. A reference to the sender of the event.
  • kwargs – (deprecated) Unstructured key/value pairs to invoke the callback with. Using event objects with publish() is preferred.
Raises:

CallbackFailure – CallbackFailure is raised if the underlying callback has errors.

publish(resource, event, trigger, payload=None)

Notify all subscribed callback(s) with a payload.

Dispatch the resource’s event to the subscribed callbacks.

Parameters:
  • resource – The resource for the event.
  • event – The event.
  • trigger – The trigger. A reference to the sender of the event.
  • payload – The optional event object to send to subscribers. If passed this must be an instance of BaseEvent.
Raises:
subscribe(callback, resource, event)

Subscribe callback for a resource event.

The same callback may register for more than one event.

Parameters:
  • callback – the callback. It must raise or return a boolean.
  • resource – the resource. It must be a valid resource.
  • event – the event. It must be a valid event.
unsubscribe(callback, resource, event)

Unsubscribe callback from the registry.

Parameters:
  • callback – the callback.
  • resource – the resource.
  • event – the event.
unsubscribe_all(callback)

Unsubscribe callback for all events and all resources.

Parameters:callback – the callback.
unsubscribe_by_resource(callback, resource)

Unsubscribe callback for any event associated to the resource.

Parameters:
  • callback – the callback.
  • resource – the resource.

neutron_lib.callbacks.registry module

neutron_lib.callbacks.registry.clear()
neutron_lib.callbacks.registry.has_registry_receivers(klass)

Decorator to setup __new__ method in classes to subscribe bound methods.

Any method decorated with @receives above is an unbound method on a class. This decorator sets up the class __new__ method to subscribe the bound method in the callback registry after object instantiation.

neutron_lib.callbacks.registry.notify(resource, event, trigger, **kwargs)
neutron_lib.callbacks.registry.publish(resource, event, trigger, payload=None)
neutron_lib.callbacks.registry.receives(resource, events)

Use to decorate methods on classes before initialization.

Any classes that use this must themselves be decorated with the @has_registry_receivers decorator to setup the __new__ method to actually register the instance methods after initialization.

neutron_lib.callbacks.registry.subscribe(callback, resource, event)
neutron_lib.callbacks.registry.unsubscribe(callback, resource, event)
neutron_lib.callbacks.registry.unsubscribe_all(callback)
neutron_lib.callbacks.registry.unsubscribe_by_resource(callback, resource)

neutron_lib.callbacks.resources module

Module contents

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.