Browse Source

Add customizable NS1 monitor tcp timout settings

pull/806/head
Benjamin Kane 4 years ago
parent
commit
dd45f74d30
2 changed files with 29 additions and 3 deletions
  1. +14
    -2
      octodns/provider/ns1.py
  2. +15
    -1
      tests/test_octodns_provider_ns1.py

+ 14
- 2
octodns/provider/ns1.py View File

@ -1053,6 +1053,16 @@ class Ns1Provider(BaseProvider):
return monitor_id, self._feed_create(monitor)
def _healthcheck_tcp_connect_timeout(self, record):
return record._octodns.get('ns1', {}) \
.get('healthcheck', {}) \
.get('tcp_connect_timeout', 2000)
def _healthcheck_tcp_response_timeout(self, record):
return record._octodns.get('ns1', {}) \
.get('healthcheck', {}) \
.get('tcp_response_timeout', 10000)
def _monitor_gen(self, record, value):
host = record.fqdn[:-1]
_type = record._type
@ -1064,10 +1074,12 @@ class Ns1Provider(BaseProvider):
ret = {
'active': True,
'config': {
'connect_timeout': 2000,
'connect_timeout':
self._healthcheck_tcp_connect_timeout(record),
'host': value,
'port': record.healthcheck_port,
'response_timeout': 10000,
'response_timeout':
self._healthcheck_tcp_response_timeout(record),
'ssl': record.healthcheck_protocol == 'HTTPS',
},
'frequency': 60,


+ 15
- 1
tests/test_octodns_provider_ns1.py View File

@ -599,7 +599,13 @@ class TestNs1ProviderDynamic(TestCase):
'path': '/_ping',
'port': 80,
'protocol': 'HTTP',
}
},
'ns1': {
'healthcheck': {
'tcp_connect_timeout': 5000,
'tcp_response_timeout': 6000,
},
},
},
'ttl': 32,
'type': 'A',
@ -919,6 +925,14 @@ class TestNs1ProviderDynamic(TestCase):
# No http response expected
self.assertFalse('rules' in monitor)
record._octodns['ns1']['healthcheck']['tcp_connect_timeout'] = 1234
monitor = provider._monitor_gen(record, value)
self.assertEquals(1234, monitor['config']['connect_timeout'])
record._octodns['ns1']['healthcheck']['tcp_response_timeout'] = 5678
monitor = provider._monitor_gen(record, value)
self.assertEquals(5678, monitor['config']['response_timeout'])
def test_monitor_gen_AAAA(self):
provider = Ns1Provider('test', 'api-key')


Loading…
Cancel
Save