octodns.source.base
Classes
|
Base class for all octoDNS sources and providers. |
- class octodns.source.base.BaseSource(id)[source]
Bases:
objectBase class for all octoDNS sources and providers.
Sources are responsible for loading DNS records from various backends into octoDNS zones. They implement the
populatemethod to read DNS data from their respective data stores (YAML files, APIs, databases, etc.) and add records to the provided zone.Subclasses must define the following class attributes either statically or prior to calling
super().__init__:SUPPORTS: Set of supported record types (e.g.,
{'A', 'AAAA', 'CNAME'})SUPPORTS_GEO: Boolean indicating if the source supports GeoDNS records
log: Logger instance for the source
Optional class attributes:
SUPPORTS_MULTIVALUE_PTR: Support for multiple PTR records (default: False)
SUPPORTS_POOL_VALUE_STATUS: Support for pool value status flags (default: False)
SUPPORTS_ROOT_NS: Support for root NS records (default: False)
SUPPORTS_DYNAMIC_SUBNETS: Support for dynamic subnet-based routing (default: False)
Example usage:
sources: config: class: octodns.provider.yaml.YamlProvider directory: ./config zones: example.com.: sources: - config targets: - route53
See also
- SUPPORTS_MULTIVALUE_PTR = False
- SUPPORTS_POOL_VALUE_STATUS = False
- SUPPORTS_ROOT_NS = False
- SUPPORTS_DYNAMIC_SUBNETS = False
- __init__(id)[source]
Initialize the source.
- Parameters:
id (str) – Unique identifier for this source instance. Used in logging and configuration references.
- Raises:
NotImplementedError – If required class attributes (
log,SUPPORTS_GEO, orSUPPORTS) are not defined in the subclass.
- property SUPPORTS_DYNAMIC
Indicates whether this source supports dynamic records.
Dynamic records include advanced routing features like GeoDNS pools, health checks, and weighted responses. Most sources do not support dynamic records.
- Returns:
True if dynamic records are supported, False otherwise.
- Return type:
- populate(zone, target=False, lenient=False)[source]
Load DNS records from the source into the provided zone.
This method is responsible for reading DNS data from the source’s backend and adding records to the zone using
zone.add_record(). Subclasses must implement this method.- Parameters:
zone (octodns.zone.Zone) – The zone to populate with records from this source.
target (bool) – If True, the populate call is loading the current state from a target provider (for comparison during sync). If False, loading desired state from a source.
lenient (bool) – If True, skip strict record validation and do a “best effort” load of data. This allows some non-best-practice configurations through (e.g., missing trailing dots or unescaped semicolons).
- Returns:
When
targetis True (loading current state), should return True if the zone exists in the target or False if it does not. Whentargetis False (loading desired state), return value is ignored and may be None.- Return type:
bool or None
- Raises:
NotImplementedError – This base class method must be overridden by subclasses.
Important
Must use
zone.add_record()to add records to the zone.Should not modify the zone name or other zone properties.
When
target=True, must return a boolean indicating zone existence.When
lenient=True, should relax validation to handle common non-standard configurations.
- supports(record)[source]
Check if this source supports the given record type.
- Parameters:
record (octodns.record.base.Record) – The DNS record to check for support.
- Returns:
True if the record type is supported, False otherwise.
- Return type: