diff --git a/octodns/record.py b/octodns/record.py index cacb147..e86de2d 100644 --- a/octodns/record.py +++ b/octodns/record.py @@ -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: diff --git a/tests/test_octodns_record.py b/tests/test_octodns_record.py index 52505cb..9c72413 100644 --- a/tests/test_octodns_record.py +++ b/tests/test_octodns_record.py @@ -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)