ncs.dp Module
Callback module for connecting data providers to ConfD/NCS.
Functions
return_worker_socket
return_worker_socket(state, key)Return worker socket associated with a worker thread from Daemon/state.
Return worker socket to pool.
take_worker_socket
take_worker_socket(state, name, key=None, action_key=None)Take worker socket associated with a worker thread from Daemon/state.
Take worker socket from pool, must be returned with dp.return_worker_socket after use.
If action_key is provided, the _Wsock is also tracked in state['action_wsocks'] so the abort wrapper can find and flag it.
Classes
class Action
Action callback.
This class makes it easy to create and register action callbacks by sub-classing it and implementing cb_action in the derived class.
Initialize this object.
The 'daemon' argument should be a Daemon instance. 'actionpoint' is the name of the tailf:actionpoint to manage. 'log' can be any log object, and if not set the Daemon logger will be used. 'init_args' may be any object that will be passed into init() when this object is constructed. Lastly, the low-level function dp.register_action_cbs() will be called.
When using this class together with ncs.application.Application there is no need to manually initialize this object as it is done by the Application.register_action() method.
Arguments:
daemon -- Daemon instance (dp.Daemon)
actionpoint -- actionpoint name (str)
log -- logging object (optional)
init_args -- additional arguments (optional)
Members:
class Daemon
Manage a data provider connection towards ConfD/NCS.
Initialize a Daemon object.
The 'name' argument should be unique. It will show up in the CLI and in error messages. All other arguments are optional. Argument 'log' can be any log object, and if not set the standard logging mechanism will be used. Set 'ip' and 'port' to where your Confd/NCS server is. 'path' is a filename to a unix domain socket to be used in place of 'ip' and 'port'. If 'path' is provided, 'ip' and 'port' arguments are ignored.
Daemon supports automatic restarting in case of error if a state manager is provided using the state_mgr parameter.
Members:
class StateManager
Base class for state managers used with Daemon
Members:
class TransValidateCallback
Default transaction validation callback implementation class.
When registering validation points in ConfD/NCS a transaction validation callback handler must be provided. This class is a generic implementation of such a handler. It implements the required callbacks 'cb_init' and 'cb_stop'.
Initialize a TransValidateCallback object.
The argument 'state' is the dict representation of a daemon.
Members:
class TransactionCallback
Default transaction callback implementation class.
When connecting data providers to ConfD/NCS a transaction callback handler must be provided. This class is a generic implementation of such a handler. It implements the only required callback 'cb_init'.
Initialize a TransactionCallback object.
The argument 'wsock' is the connected worker socket and 'log' is a log object.
Members:
class ValidationError
Exception raised to indicate a failed validation
Members:
class ValidationPoint
Validation Point callback.
This class makes it easy to create and register validation point callbacks by subclassing it and implementing cb_validate with the @validate or @validate_with_trans decorator.
Members:
Predefined Values
Last updated
Was this helpful?

