Browse Source

pick first PTR value instead of erroring out

pull/754/head
Viranch Mehta 4 years ago
parent
commit
6e9ce3ac3c
No known key found for this signature in database GPG Key ID: D83D1392AE9F93B4
6 changed files with 29 additions and 16 deletions
  1. +24
    -2
      octodns/manager.py
  2. +1
    -0
      octodns/provider/azuredns.py
  3. +1
    -0
      octodns/provider/ns1.py
  4. +1
    -4
      octodns/record/__init__.py
  5. +2
    -0
      octodns/source/base.py
  6. +0
    -10
      tests/test_octodns_record.py

+ 24
- 2
octodns/manager.py View File

@ -294,8 +294,30 @@ class Manager(object):
for processor in processors:
plan = processor.process_plan(plan, sources=sources,
target=target)
if plan:
plans.append((target, plan))
if not plan:
continue
# Multi value PTR check
for change in plan.changes:
record = change.new
if not record:
# Delete - doesn't need to be checked
continue
if record._type == 'PTR' and len(record.values) > 1 and not \
target.SUPPORTS_MUTLIVALUE_PTR:
self.log.warn('target=%s does not support multi-value PTR '
'record %s; using %s as its only answer',
target, record.fqdn, record.value)
# Make a new copy of the record so as to not change a
# potentially shared object
change.new = Record.new(record.zone, record.name, {
'type': record._type,
'ttl': record.ttl,
'value': record.value,
}, source=record.source, lenient=lenient)
plans.append((target, plan))
# Return the zone as it's the desired state
return plans, zone


+ 1
- 0
octodns/provider/azuredns.py View File

@ -456,6 +456,7 @@ class AzureProvider(BaseProvider):
'''
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = True
SUPPORTS_MUTLIVALUE_PTR = True
SUPPORTS = set(('A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SRV',
'TXT'))


+ 1
- 0
octodns/provider/ns1.py View File

@ -261,6 +261,7 @@ class Ns1Provider(BaseProvider):
'''
SUPPORTS_GEO = True
SUPPORTS_DYNAMIC = True
SUPPORTS_MUTLIVALUE_PTR = True
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'MX', 'NAPTR',
'NS', 'PTR', 'SPF', 'SRV', 'TXT', 'URLFWD'))


+ 1
- 4
octodns/record/__init__.py View File

@ -1285,10 +1285,7 @@ class PtrRecord(_ValuesMixin, Record):
# multi-value PTR records.
@property
def value(self):
if len(self.values) == 1:
return self.data['value']
raise AttributeError("Multi-value PTR record has no attribute 'value'")
return self.values[0]
class SshfpValue(EqualityTupleMixin):


+ 2
- 0
octodns/source/base.py View File

@ -8,6 +8,8 @@ from __future__ import absolute_import, division, print_function, \
class BaseSource(object):
SUPPORTS_MUTLIVALUE_PTR = False
def __init__(self, id):
self.id = id
if not getattr(self, 'log', False):


+ 0
- 10
tests/test_octodns_record.py View File

@ -2755,16 +2755,6 @@ class TestRecordValidation(TestCase):
self.assertEquals(['PTR value "foo.bar" missing trailing .'],
ctx.exception.reasons)
# multi-value requesting single-value
with self.assertRaises(AttributeError) as ctx:
Record.new(self.zone, '', {
'type': 'PTR',
'ttl': 600,
'values': ['foo.com.', 'bar.net.'],
}).value
self.assertEquals("Multi-value PTR record has no attribute 'value'",
text_type(ctx.exception))
def test_SSHFP(self):
# doesn't blow up
Record.new(self.zone, '', {


Loading…
Cancel
Save