mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Add replace param to AutoArpa processor/provider
This commit is contained in:
@@ -14,6 +14,10 @@ Alternatively the value can be a dictionary with configuration options for the A
|
|||||||
---
|
---
|
||||||
manager:
|
manager:
|
||||||
auto_arpa:
|
auto_arpa:
|
||||||
|
# Replace duplicate records rather than throw an error, default is False
|
||||||
|
# which throws an error
|
||||||
|
replace: False
|
||||||
|
# Explicitly set the TTL of auto-created records, default is 3600s, 1hr
|
||||||
ttl: 1800
|
ttl: 1800
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -11,10 +11,12 @@ from .base import BaseProcessor
|
|||||||
|
|
||||||
|
|
||||||
class AutoArpa(BaseProcessor):
|
class AutoArpa(BaseProcessor):
|
||||||
def __init__(self, name, ttl=3600):
|
def __init__(self, name, ttl=3600, replace=False):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
self.log = getLogger(f'AutoArpa[{name}]')
|
self.log = getLogger(f'AutoArpa[{name}]')
|
||||||
|
self.log.info('__init__: ttl=%d, replace=%s', ttl, replace)
|
||||||
self.ttl = ttl
|
self.ttl = ttl
|
||||||
|
self.replace = replace
|
||||||
self._records = defaultdict(set)
|
self._records = defaultdict(set)
|
||||||
|
|
||||||
def process_source_zone(self, desired, sources):
|
def process_source_zone(self, desired, sources):
|
||||||
@@ -56,7 +58,7 @@ class AutoArpa(BaseProcessor):
|
|||||||
name,
|
name,
|
||||||
{'ttl': self.ttl, 'type': 'PTR', 'values': fqdns},
|
{'ttl': self.ttl, 'type': 'PTR', 'values': fqdns},
|
||||||
)
|
)
|
||||||
zone.add_record(record)
|
zone.add_record(record, replace=self.replace)
|
||||||
|
|
||||||
self.log.info(
|
self.log.info(
|
||||||
'populate: found %s records', len(zone.records) - before
|
'populate: found %s records', len(zone.records) - before
|
||||||
|
Reference in New Issue
Block a user