octodns.processor.base
Classes
|
Base class for all octoDNS processors. |
Exceptions
Exception raised when a processor encounters an error during processing. |
- exception octodns.processor.base.ProcessorException[source]
Bases:
ExceptionException raised when a processor encounters an error during processing.
A subclass of this exception can be raised by processors when they encounter invalid configurations, unsupported operations, or other processing errors.
- class octodns.processor.base.BaseProcessor(name, lenient=False)[source]
Bases:
objectBase class for all octoDNS processors.
Processors provide hooks into the octoDNS sync process to modify zones and records at various stages. They can be used to filter, transform, or validate DNS records before planning and applying changes.
Processors are executed in the order they are configured and can modify:
Source zones (after sources populate, before planning)
Target zones (after target populates, before planning)
Source and target zones (just before computing changes)
Plans (after planning, before applying)
Subclasses should override one or more of the
process_*methods to implement custom processing logic.Example usage:
processors: my-processor: class: my.custom.processor.MyProcessor # processor-specific configuration zones: example.com.: sources: - config processors: - my-processor targets: - route53
See also
- __init__(name, lenient=False)[source]
Initialize the processor.
- Parameters:
Note
The
nameparameter is deprecated and will be removed in version 2.0. Useidinstead.
- process_source_zone(desired, sources, lenient=False)[source]
Process the desired zone after all sources have populated.
Called after all sources have completed populate. Provides an opportunity for the processor to modify the desired zone that targets will receive.
- Parameters:
desired (octodns.zone.Zone) – The desired zone state after all sources have populated. This zone will be used as the target state for planning.
sources (list[octodns.provider.base.BaseProvider]) – List of source providers that populated the zone. May be empty for aliased zones.
lenient (bool) – When True, relaxed validation rules should be applied when modifying zone records.
- Returns:
The modified desired zone, typically the same object passed in.
- Return type:
Important
Will see
desiredafter any modifications done byProvider._process_desired_zoneand processors configured to run before this one.May modify
desireddirectly.Must return
desiredwhich will normally be thedesiredparam.Must not modify records directly;
record.copyshould be called, the results of which can be modified, and thenZone.add_recordmay be used withreplace=True.May call
Zone.remove_recordto remove records fromdesired.Sources may be empty, as will be the case for aliased zones.
Implementations should combine
self.lenient or lenientand pass the result to any record and zone calls that acceptlenientas a parameter, e.g.zone.add_record(..., lenient=lenient).
- process_target_zone(existing, target, lenient=False)[source]
Process the existing zone after the target has populated.
Called after a target has completed
populate, before changes are computed betweenexistinganddesired. This provides an opportunity to modify the existing zone state.- Parameters:
existing (octodns.zone.Zone) – The current zone state from the target provider.
target (octodns.provider.base.BaseProvider) – The target provider that populated the existing zone.
lenient (bool) – When True, relaxed validation rules should be applied when modifying zone records.
- Returns:
The modified existing zone, typically the same object passed in.
- Return type:
Important
Will see
existingafter any modifications done by processors configured to run before this one.May modify
existingdirectly.Must return
existingwhich will normally be theexistingparam.Must not modify records directly;
record.copyshould be called, the results of which can be modified, and thenZone.add_recordmay be used withreplace=True.May call
Zone.remove_recordto remove records fromexisting.Implementations should combine
self.lenient or lenientand pass the result to any record and zone calls that acceptlenientas a parameter, e.g.zone.add_record(..., lenient=lenient).
- process_source_and_target_zones(desired, existing, target, lenient=False)[source]
Process both desired and existing zones before computing changes.
Called just prior to computing changes for the target provider between
desiredandexisting. Provides an opportunity for the processor to modify either or both zones that will be used to compute the changes and create the initial plan.- Parameters:
desired (octodns.zone.Zone) – The desired zone state after all source processing.
existing (octodns.zone.Zone) – The existing zone state after all target processing.
target (octodns.provider.base.BaseProvider) – The target provider for which changes will be computed.
lenient (bool) – When True, relaxed validation rules should be applied when modifying zone records.
- Returns:
A tuple of (desired, existing) zones, typically the same objects passed in.
- Return type:
Important
Will see
desiredafter any modifications done byProvider._process_desired_zoneand all processors viaProcessor.process_source_zone.Will see
existingafter any modifications done by all processors viaProcessor.process_target_zone.Will see both
desiredandexistingafter any modifications done by any processors configured to run before this one viaProcessor.process_source_and_target_zones.May modify
desireddirectly.Must return
desiredwhich will normally be thedesiredparam.May modify
existingdirectly.Must return
existingwhich will normally be theexistingparam.Must not modify records directly;
record.copyshould be called, the results of which can be modified, and thenZone.add_recordmay be used withreplace=True.May call
Zone.remove_recordto remove records fromdesired.May call
Zone.remove_recordto remove records fromexisting.Implementations should combine
self.lenient or lenientand pass the result to any record and zone calls that acceptlenientas a parameter, e.g.zone.add_record(..., lenient=lenient).
- process_plan(plan, sources, target, lenient=False)[source]
Process the plan after it has been computed.
Called after the planning phase has completed. Provides an opportunity for the processor to modify the plan, thus changing the actions that will be displayed and potentially applied.
- Parameters:
plan (octodns.provider.plan.Plan or None) – The computed plan containing the changes to be applied. May be None if no changes were detected.
sources (list[octodns.provider.base.BaseProvider]) – List of source providers for this zone. May be empty for aliased zones.
target (octodns.provider.base.BaseProvider) – The target provider for which the plan was created.
lenient (bool) – When True, relaxed validation rules should be applied when modifying zone records.
- Returns:
The modified plan, which may be the same object passed in, a newly created Plan, or None if no changes are needed.
- Return type:
octodns.provider.plan.Plan or None
Important
planmay be None if no changes were detected; if so, aPlanmay still be created and returned.May modify
plan.changesdirectly or create a newPlan.Does not have to modify
plan.desiredand/orplan.existingto line up with any modifications made toplan.changes.Should copy over
plan.exists,plan.update_pcent_threshold, andplan.delete_pcent_thresholdwhen creating a newPlan.Must return a
Planwhich may beplanor can be a newly created one withplan.desiredandplan.existingcopied over as-is or modified.Sources may be empty, as will be the case for aliased zones.
Implementations should combine
self.lenient or lenientand pass the result to any record and zone calls that acceptlenientas a parameter, e.g.zone.add_record(..., lenient=lenient).