Browse Source

Fix geo comparison in Azure DNS traffic manager profiles

pull/811/head
Viranch Mehta 4 years ago
parent
commit
973f88510f
No known key found for this signature in database GPG Key ID: D83D1392AE9F93B4
2 changed files with 32 additions and 11 deletions
  1. +22
    -11
      octodns/provider/azuredns.py
  2. +10
    -0
      tests/test_octodns_provider_azuredns.py

+ 22
- 11
octodns/provider/azuredns.py View File

@ -377,29 +377,39 @@ def _profile_is_match(have, desired):
for have_endpoint, desired_endpoint in endpoints:
have_status = have_endpoint.endpoint_status or 'Enabled'
desired_status = desired_endpoint.endpoint_status or 'Enabled'
# compare basic attributes
if have_endpoint.name != desired_endpoint.name or \
have_endpoint.type != desired_endpoint.type or \
have_status != desired_status:
return false(have_endpoint, desired_endpoint, have.name)
# compare geos
if method == 'Geographic':
have_geos = sorted(have_endpoint.geo_mapping)
desired_geos = sorted(desired_endpoint.geo_mapping)
if have_geos != desired_geos:
return false(have_endpoint, desired_endpoint, have.name)
# compare priorities
if method == 'Priority' and \
have_endpoint.priority != desired_endpoint.priority:
return false(have_endpoint, desired_endpoint, have.name)
# compare weights
if method == 'Weighted' and \
have_endpoint.weight != desired_endpoint.weight:
return false(have_endpoint, desired_endpoint, have.name)
# compare targets
target_type = have_endpoint.type.split('/')[-1]
if target_type == 'externalEndpoints':
# compare value, weight, priority
if have_endpoint.target != desired_endpoint.target:
return false(have_endpoint, desired_endpoint, have.name)
if method == 'Weighted' and \
have_endpoint.weight != desired_endpoint.weight:
return false(have_endpoint, desired_endpoint, have.name)
elif target_type == 'nestedEndpoints':
# compare targets
if have_endpoint.target_resource_id != \
desired_endpoint.target_resource_id:
return false(have_endpoint, desired_endpoint, have.name)
# compare geos
if method == 'Geographic':
have_geos = sorted(have_endpoint.geo_mapping)
desired_geos = sorted(desired_endpoint.geo_mapping)
if have_geos != desired_geos:
return false(have_endpoint, desired_endpoint, have.name)
else:
# unexpected, give up
return False
@ -913,6 +923,7 @@ class AzureProvider(BaseProvider):
if value['status'] == 'up':
# Azure only supports obey and down, not up
up_pools.append(name)
break
if not up_pools:
continue


+ 10
- 0
tests/test_octodns_provider_azuredns.py View File

@ -516,6 +516,16 @@ class Test_ProfileIsMatch(TestCase):
)
self.assertFalse(is_match(profile(), profile(target_id='rsrc/id2')))
self.assertFalse(is_match(profile(), profile(geos=['IN'])))
self.assertFalse(is_match(
profile(endpoint_type='profile/externalEndpoints'),
profile(
endpoint_type='profile/externalEndpoints',
geos=['IN']
)
))
self.assertFalse(is_match(profile(method='Priority'), profile(
method='Priority', priority=2
)))
def wprofile(**kwargs):
kwargs['method'] = 'Weighted'


Loading…
Cancel
Save