Browse Source

allow multiple values if all pool values are included

pull/738/head
Viranch Mehta 5 years ago
parent
commit
6f5df26e88
No known key found for this signature in database GPG Key ID: D83D1392AE9F93B4
2 changed files with 26 additions and 8 deletions
  1. +15
    -4
      octodns/provider/azuredns.py
  2. +11
    -4
      tests/test_octodns_provider_azuredns.py

+ 15
- 4
octodns/provider/azuredns.py View File

@ -302,10 +302,21 @@ def _get_monitor(record):
def _check_valid_dynamic(record):
typ = record._type
if typ in ['A', 'AAAA']:
if len(record.values) > 1:
# we don't yet support multi-value defaults
msg = '{} {}: A/AAAA dynamic records can only have a single value'
raise AzureException(msg.format(record.fqdn, record._type))
defaults = set(record.values)
if len(defaults) > 1:
pools = record.dynamic.pools
vals = set(
v['value']
for _, pool in pools.items()
for v in pool._data()['values']
)
if defaults != vals:
# we don't yet support multi-value defaults, specifying all
# pool values allows for Traffic Manager profile optimization
msg = ('{} {}: Values of A/AAAA dynamic records must either '
'have a single value or contain all values from all '
'pools')
raise AzureException(msg.format(record.fqdn, record._type))
elif typ != 'CNAME':
# dynamic records of unsupported type
msg = '{}: Dynamic records in Azure must be of type A/AAAA/CNAME'


+ 11
- 4
tests/test_octodns_provider_azuredns.py View File

@ -1873,12 +1873,13 @@ class TestAzureDnsProvider(TestCase):
record = Record.new(zone, 'foo', data={
'type': 'AAAA',
'ttl': 60,
'values': ['1::1'],
'values': ['1::1', '2::2'],
'dynamic': {
'pools': {
'one': {
'values': [
{'value': '1::1'},
{'value': '2::2'},
],
},
},
@ -1892,16 +1893,22 @@ class TestAzureDnsProvider(TestCase):
self.assertEqual(len(profiles), 1)
self.assertTrue(_profile_is_match(profiles[0], Profile(
name='foo--unit--tests-AAAA',
traffic_routing_method='Geographic',
traffic_routing_method='Weighted',
dns_config=DnsConfig(
relative_name='foo--unit--tests-aaaa', ttl=record.ttl),
monitor_config=_get_monitor(record),
endpoints=[
Endpoint(
name='one--default--',
name='one--1--1--default--',
type=external,
target='1::1',
geo_mapping=['WORLD'],
weight=1,
),
Endpoint(
name='one--2--2--default--',
type=external,
target='2::2',
weight=1,
),
],
)))


Loading…
Cancel
Save