LetsDNS functionality can be extended with the help of dynamically loaded action classes. This allows users to execute actions which are not part of the official package, e.g. to update domain name servers with some proprietary mechanism, accessing databases, and so forth.
Dynamic action classes need to be derived from the letsdns.action.Action abstract base class, and be available via Python’s sys.path or PYTHONPATH.
As an example, consider the following file/directory structure:
# Activate your project's Python virtualenv cd ~/projects/custom-actions source .venv/bin/activate # Link to your local copy of the LetsDNS source code pip install --editable /path/to/letsdns # Structure of ~/projects/custom-actions # # . # └── sample # ├── __init__.py # └── action.py
Assume further that the Python file action.py contains the following:
from letsdns.action import Action from letsdns.configuration import Config class MyCustomAction(Action): """Do nothing, but return zero to indicate success.""" def execute(self, conf: Config, *args, **kwargs) -> int: return 0
You can reference this dynamic action using
action = dynamic:sample.action.MyCustomAction
in your configuration files.