Browse Source

Record.healtcheck_(host|path)

pull/67/head
Ross McFarland 9 years ago
parent
commit
670d7eef17
2 changed files with 67 additions and 2 deletions
  1. +19
    -2
      octodns/record.py
  2. +48
    -0
      tests/test_octodns_record.py

+ 19
- 2
octodns/record.py 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:


+ 48
- 0
tests/test_octodns_record.py 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)

Loading…
Cancel
Save