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

Record.healtcheck_(host|path)

This commit is contained in:
Ross McFarland
2017-06-15 09:04:35 -07:00
parent a7c538dcd6
commit 670d7eef17
2 changed files with 67 additions and 2 deletions

View File

@@ -112,8 +112,7 @@ class Record(object):
raise Exception('Invalid record {}, missing ttl'.format(self.fqdn))
self.source = source
octodns = data.get('octodns', {})
self.ignored = octodns.get('ignored', False)
self._octodns = data.get('octodns', {})
def _data(self):
return {'ttl': self.ttl}
@@ -128,6 +127,24 @@ class Record(object):
return '{}.{}'.format(self.name, self.zone.name)
return self.zone.name
@property
def ignored(self):
return self._octodns.get('ignored', False)
@property
def healthcheck_path(self):
try:
return self._octodns['healthcheck']['path']
except KeyError:
return '/_dns'
@property
def healthcheck_host(self):
try:
return self._octodns['healthcheck']['host']
except KeyError:
return self.fqdn[:-1]
def changes(self, other, target):
# We're assuming we have the same name and type if we're being compared
if self.ttl != other.ttl:

View File

@@ -794,3 +794,51 @@ class TestRecord(TestCase):
self.assertEquals('CA', geo.subdivision_code)
self.assertEquals(values, geo.values)
self.assertEquals(['NA-US', 'NA'], list(geo.parents))
def test_inored(self):
new = Record.new(self.zone, 'txt', {
'ttl': 44,
'type': 'TXT',
'value': 'some change',
'octodns': {
'ignored': True,
}
})
self.assertTrue(new.ignored)
new = Record.new(self.zone, 'txt', {
'ttl': 44,
'type': 'TXT',
'value': 'some change',
'octodns': {
'ignored': False,
}
})
self.assertFalse(new.ignored)
new = Record.new(self.zone, 'txt', {
'ttl': 44,
'type': 'TXT',
'value': 'some change',
})
self.assertFalse(new.ignored)
def test_healthcheck(self):
new = Record.new(self.zone, 'a', {
'ttl': 44,
'type': 'A',
'value': '1.2.3.4',
'octodns': {
'healthcheck': {
'path': '/_ready',
'host': 'bleep.bloop',
}
}
})
self.assertEquals('/_ready', new.healthcheck_path)
self.assertEquals('bleep.bloop', new.healthcheck_host)
new = Record.new(self.zone, 'a', {
'ttl': 44,
'type': 'A',
'value': '1.2.3.4',
})
self.assertEquals('/_dns', new.healthcheck_path)
self.assertEquals('a.unit.tests', new.healthcheck_host)