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

Add custom healtcheck host & path to Dyn geo records

This commit is contained in:
Ross McFarland
2017-06-15 10:12:17 -07:00
parent 4761da9c33
commit 0c1a8fe964
2 changed files with 27 additions and 9 deletions

View File

@@ -447,19 +447,20 @@ class DynProvider(BaseProvider):
_kwargs_for_TXT = _kwargs_for_SPF
def _traffic_director_monitor(self, fqdn):
def _traffic_director_monitor(self, record):
if self._traffic_director_monitors is None:
self._traffic_director_monitors = \
{m.label: m for m in get_all_dsf_monitors()}
fqdn = record.fqdn
try:
return self._traffic_director_monitors[fqdn]
except KeyError:
monitor = DSFMonitor(fqdn, protocol='HTTPS', response_count=2,
probe_interval=60, retries=2, port=443,
active='Y', host=fqdn[:-1], timeout=10,
header='User-Agent: Dyn Monitor',
path='/_dns')
active='Y', host=record.healthcheck_host,
timeout=10, header='User-Agent: Dyn Monitor',
path=record.healthcheck_path)
self._traffic_director_monitors[fqdn] = monitor
return monitor
@@ -533,7 +534,7 @@ class DynProvider(BaseProvider):
}
ruleset.add_response_pool(pool.response_pool_id)
monitor_id = self._traffic_director_monitor(new.fqdn).dsf_monitor_id
monitor_id = self._traffic_director_monitor(new).dsf_monitor_id
# Geos ordered least to most specific so that parents will always be
# created before their children (and thus can be referenced
geos = sorted(new.geo.items(), key=lambda d: d[0])

View File

@@ -637,6 +637,7 @@ class TestDynProviderGeo(TestCase):
provider = DynProvider('test', 'cust', 'user', 'pass', True)
# short-circuit session checking
provider._dyn_sess = True
existing = Zone('unit.tests.', [])
# no monitors, will try and create
geo_monitor_id = '42x'
@@ -669,7 +670,18 @@ class TestDynProviderGeo(TestCase):
}]
# ask for a monitor that doesn't exist
monitor = provider._traffic_director_monitor('geo.unit.tests.')
record = Record.new(existing, 'geo', {
'ttl': 60,
'type': 'A',
'value': '1.2.3.4',
'octodns': {
'healthcheck': {
'host': 'foo.bar',
'path': '/_ready'
}
}
})
monitor = provider._traffic_director_monitor(record)
self.assertEquals(geo_monitor_id, monitor.dsf_monitor_id)
# should see a request for the list and a create
mock.assert_has_calls([
@@ -682,8 +694,8 @@ class TestDynProviderGeo(TestCase):
'probe_interval': 60,
'active': 'Y',
'options': {
'path': '/_dns',
'host': 'geo.unit.tests',
'path': '/_ready',
'host': 'foo.bar',
'header': 'User-Agent: Dyn Monitor',
'port': 443,
'timeout': 10
@@ -698,8 +710,13 @@ class TestDynProviderGeo(TestCase):
provider._traffic_director_monitors)
# now ask for a monitor that does exist
record = Record.new(existing, '', {
'ttl': 60,
'type': 'A',
'value': '1.2.3.4'
})
mock.reset_mock()
monitor = provider._traffic_director_monitor('unit.tests.')
monitor = provider._traffic_director_monitor(record)
self.assertEquals(self.monitor_id, monitor.dsf_monitor_id)
# should have resulted in no calls b/c exists & we've cached the list
mock.assert_not_called()