|
|
@ -14,16 +14,27 @@ from .base import BaseProcessor |
|
|
# and thus "own" them going forward. |
|
|
# and thus "own" them going forward. |
|
|
class OwnershipProcessor(BaseProcessor): |
|
|
class OwnershipProcessor(BaseProcessor): |
|
|
def __init__( |
|
|
def __init__( |
|
|
self, name, txt_name='_owner', txt_value='*octodns*', txt_ttl=60 |
|
|
|
|
|
|
|
|
self, |
|
|
|
|
|
name, |
|
|
|
|
|
txt_name='_owner', |
|
|
|
|
|
txt_value='*octodns*', |
|
|
|
|
|
txt_ttl=60, |
|
|
|
|
|
should_replace=False, |
|
|
): |
|
|
): |
|
|
super().__init__(name) |
|
|
super().__init__(name) |
|
|
self.txt_name = txt_name |
|
|
self.txt_name = txt_name |
|
|
self.txt_value = txt_value |
|
|
self.txt_value = txt_value |
|
|
self.txt_ttl = txt_ttl |
|
|
self.txt_ttl = txt_ttl |
|
|
self._txt_values = [txt_value] |
|
|
self._txt_values = [txt_value] |
|
|
|
|
|
self.should_replace = should_replace |
|
|
|
|
|
|
|
|
def process_source_zone(self, desired, *args, **kwargs): |
|
|
def process_source_zone(self, desired, *args, **kwargs): |
|
|
for record in desired.records: |
|
|
for record in desired.records: |
|
|
|
|
|
if self._is_ownership(record): |
|
|
|
|
|
# don't apply ownership to existing ownership recorcs, most |
|
|
|
|
|
# likely to see this in an alias zone that will be proccessed |
|
|
|
|
|
# once as the original and a 2nd time as the alias |
|
|
|
|
|
continue |
|
|
# Then create and add an ownership TXT for each of them |
|
|
# Then create and add an ownership TXT for each of them |
|
|
record_name = record.name.replace('*', '_wildcard') |
|
|
record_name = record.name.replace('*', '_wildcard') |
|
|
if record.name: |
|
|
if record.name: |
|
|
@ -37,7 +48,7 @@ class OwnershipProcessor(BaseProcessor): |
|
|
) |
|
|
) |
|
|
# add these w/lenient to cover the case when the ownership record |
|
|
# add these w/lenient to cover the case when the ownership record |
|
|
# for a NS delegation record should technically live in the subzone |
|
|
# for a NS delegation record should technically live in the subzone |
|
|
desired.add_record(txt, lenient=True) |
|
|
|
|
|
|
|
|
desired.add_record(txt, lenient=True, replace=self.should_replace) |
|
|
|
|
|
|
|
|
return desired |
|
|
return desired |
|
|
|
|
|
|
|
|
|