Browse Source

map Oceania to Australia/Pacific in Azure

pull/717/head
Viranch Mehta 5 years ago
parent
commit
5f57b52d07
No known key found for this signature in database GPG Key ID: D83D1392AE9F93B4
2 changed files with 22 additions and 5 deletions
  1. +19
    -2
      octodns/provider/azuredns.py
  2. +3
    -3
      tests/test_octodns_provider_azuredns.py

+ 19
- 2
octodns/provider/azuredns.py View File

@ -655,12 +655,22 @@ class AzureProvider(BaseProvider):
geos = rule.setdefault('geos', [])
for code in geo_map:
if code.startswith('GEO-'):
geos.append(code[len('GEO-'):])
# continent
if code == 'GEO-AP':
# Azure uses Australia/Pacific (AP) instead of
# Oceania https://docs.microsoft.com/en-us/azure/
# traffic-manager/
# traffic-manager-geographic-regions
geos.append('OC')
else:
geos.append(code[len('GEO-'):])
elif '-' in code:
# state
country, province = code.split('-', 1)
country = GeoCodes.country_to_code(country)
geos.append('{}-{}'.format(country, province))
else:
# country
geos.append(GeoCodes.country_to_code(code))
# second level priority profile
@ -872,15 +882,22 @@ class AzureProvider(BaseProvider):
if len(rule_geos) > 0:
for geo in rule_geos:
if '-' in geo:
# country or state
geos.append(geo.split('-', 1)[-1])
else:
geos.append('GEO-{}'.format(geo))
# continent
if geo == 'AS':
# Middle East is part of Asia in octoDNS, but
# Azure treats it as a separate "group", so let's
# add it in the list of geo mappings. We will drop
# it when we later parse the list of regions.
geos.append('GEO-ME')
elif geo == 'OC':
# Azure uses Australia/Pacific (AP) instead of
# Oceania
geo = 'AP'
geos.append('GEO-{}'.format(geo))
else:
geos.append('WORLD')
geo_endpoints.append(Endpoint(


+ 3
- 3
tests/test_octodns_provider_azuredns.py View File

@ -573,7 +573,7 @@ class TestAzureDnsProvider(TestCase):
},
},
'rules': [
{'geos': ['AF', 'EU-DE', 'NA-US-CA'], 'pool': 'one'},
{'geos': ['AF', 'EU-DE', 'NA-US-CA', 'OC'], 'pool': 'one'},
{'pool': 'two'},
],
},
@ -694,7 +694,7 @@ class TestAzureDnsProvider(TestCase):
monitor_config=monitor,
endpoints=[
Endpoint(
geo_mapping=['GEO-AF', 'DE', 'US-CA'],
geo_mapping=['GEO-AF', 'DE', 'US-CA', 'GEO-AP'],
name='rule-one',
type=nested,
target_resource_id=id_format.format('rule-one'),
@ -944,7 +944,7 @@ class TestAzureDnsProvider(TestCase):
},
},
'rules': [
{'geos': ['AF', 'EU-DE', 'NA-US-CA'], 'pool': 'one'},
{'geos': ['AF', 'EU-DE', 'NA-US-CA', 'OC'], 'pool': 'one'},
{'pool': 'two'},
],
})


Loading…
Cancel
Save