1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Add meta record support with provider id to zone

Support replace=True in zone.add_record
This commit is contained in:
Ross McFarland
2017-06-24 17:14:48 -07:00
parent 3ca64c4e08
commit 5e4d68094f
4 changed files with 31 additions and 2 deletions

View File

@@ -49,9 +49,13 @@ class Zone(object):
def hostname_from_fqdn(self, fqdn):
return self._name_re.sub('', fqdn)
def add_record(self, record):
def add_record(self, record, replace=False):
name = record.name
last = name.split('.')[-1]
if replace and record in self.records:
self.records.remove(record)
if last in self.sub_zones:
if name != last:
# it's a record for something under a sub-zone
@@ -63,6 +67,7 @@ class Zone(object):
raise SubzoneRecordException('Record {} a managed sub-zone '
'and not of type NS'
.format(record.fqdn))
# TODO: this is pretty inefficent
for existing in self.records:
if record == existing:
raise DuplicateRecordException('Duplicate record {}, type {}'