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

map Oceania to Australia/Pacific in Azure

This commit is contained in:
Viranch Mehta
2021-05-18 10:12:59 -07:00
parent a79e2f3abd
commit 5f57b52d07
2 changed files with 22 additions and 5 deletions

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(

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'},
],
})