Browse Source

Add custom healtcheck host & path to Dyn geo records

pull/67/head
Ross McFarland 9 years ago
parent
commit
0c1a8fe964
2 changed files with 27 additions and 9 deletions
  1. +6
    -5
      octodns/provider/dyn.py
  2. +21
    -4
      tests/test_octodns_provider_dyn.py

+ 6
- 5
octodns/provider/dyn.py View File

@ -447,19 +447,20 @@ class DynProvider(BaseProvider):
_kwargs_for_TXT = _kwargs_for_SPF _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: if self._traffic_director_monitors is None:
self._traffic_director_monitors = \ self._traffic_director_monitors = \
{m.label: m for m in get_all_dsf_monitors()} {m.label: m for m in get_all_dsf_monitors()}
fqdn = record.fqdn
try: try:
return self._traffic_director_monitors[fqdn] return self._traffic_director_monitors[fqdn]
except KeyError: except KeyError:
monitor = DSFMonitor(fqdn, protocol='HTTPS', response_count=2, monitor = DSFMonitor(fqdn, protocol='HTTPS', response_count=2,
probe_interval=60, retries=2, port=443, 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 self._traffic_director_monitors[fqdn] = monitor
return monitor return monitor
@ -533,7 +534,7 @@ class DynProvider(BaseProvider):
} }
ruleset.add_response_pool(pool.response_pool_id) 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 # Geos ordered least to most specific so that parents will always be
# created before their children (and thus can be referenced # created before their children (and thus can be referenced
geos = sorted(new.geo.items(), key=lambda d: d[0]) geos = sorted(new.geo.items(), key=lambda d: d[0])


+ 21
- 4
tests/test_octodns_provider_dyn.py View File

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


Loading…
Cancel
Save