Implement SUPPORTS_DYNAMIC functionality, no providers

This commit is contained in:
Ross McFarland
2018-12-03 14:40:43 -08:00
parent 70c35aac26
commit 303d0532c8
22 changed files with 70 additions and 4 deletions
+7
View File
@@ -37,6 +37,13 @@ class _AggregateTarget(object):
return False
return True
@property
def SUPPORTS_DYNAMIC(self):
for target in self.targets:
if not target.SUPPORTS_DYNAMIC:
return False
return True
class MakeThreadFuture(object):
+1
View File
@@ -239,6 +239,7 @@ class AzureProvider(BaseProvider):
possible to also hard-code into the config file: eg, resource_group.
'''
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'CNAME', 'MX', 'NS', 'PTR', 'SRV', 'TXT'))
def __init__(self, id, client_id, key, directory_id, sub_id,
+1
View File
@@ -59,6 +59,7 @@ class CloudflareProvider(BaseProvider):
value: 1.2.3.4
'''
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('ALIAS', 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'SRV',
'SPF', 'TXT'))
+1
View File
@@ -116,6 +116,7 @@ class DigitalOceanProvider(BaseProvider):
token: foo
'''
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'TXT', 'SRV'))
def __init__(self, id, token, *args, **kwargs):
+1
View File
@@ -91,6 +91,7 @@ class DnsimpleProvider(BaseProvider):
account: 42
'''
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'MX', 'NAPTR', 'NS',
'PTR', 'SPF', 'SRV', 'SSHFP', 'TXT'))
+1
View File
@@ -150,6 +150,7 @@ class DnsMadeEasyProvider(BaseProvider):
sandbox: true
'''
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'CAA', 'CNAME', 'MX',
'NS', 'PTR', 'SPF', 'SRV', 'TXT'))
+5
View File
@@ -259,6 +259,11 @@ class DynProvider(BaseProvider):
def SUPPORTS_GEO(self):
return self.traffic_directors_enabled
@property
def SUPPORTS_DYNAMIC(self):
# TODO: dynamic
return False
def _check_dyn_sess(self):
# We don't have to worry about locking for the check since the
# underlying pieces are pre-thread. We can check to see if this thread
+1
View File
@@ -25,6 +25,7 @@ class EtcHostsProvider(BaseProvider):
directory: ./hosts
'''
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CNAME'))
def __init__(self, id, directory, *args, **kwargs):
+1
View File
@@ -40,6 +40,7 @@ class GoogleCloudProvider(BaseProvider):
SUPPORTS = set(('A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NAPTR',
'NS', 'PTR', 'SPF', 'SRV', 'TXT'))
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
CHANGE_LOOP_WAIT = 5
+1
View File
@@ -26,6 +26,7 @@ class Ns1Provider(BaseProvider):
api_key: env/NS1_API_KEY
'''
SUPPORTS_GEO = True
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'MX', 'NAPTR',
'NS', 'PTR', 'SPF', 'SRV', 'TXT'))
+1
View File
@@ -34,6 +34,7 @@ class OvhProvider(BaseProvider):
"""
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
ZONE_NOT_FOUND_MESSAGE = 'This service does not exist'
# This variable is also used in populate method to filter which OVH record
+1
View File
@@ -14,6 +14,7 @@ from .base import BaseProvider
class PowerDnsBaseProvider(BaseProvider):
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'MX', 'NAPTR', 'NS',
'PTR', 'SPF', 'SSHFP', 'SRV', 'TXT'))
TIMEOUT = 5
+1
View File
@@ -38,6 +38,7 @@ def unescape_semicolon(s):
class RackspaceProvider(BaseProvider):
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CNAME', 'MX', 'NS', 'PTR', 'SPF',
'TXT'))
TIMEOUT = 5
+2
View File
@@ -232,6 +232,8 @@ class Route53Provider(BaseProvider):
In general the account used will need full permissions on Route53.
'''
SUPPORTS_GEO = True
# TODO: dynamic
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NAPTR', 'NS', 'PTR',
'SPF', 'SRV', 'TXT'))
+1
View File
@@ -31,6 +31,7 @@ class YamlProvider(BaseProvider):
enforce_order: True
'''
SUPPORTS_GEO = True
SUPPORTS_DYNAMIC = True
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'MX', 'NAPTR', 'NS',
'PTR', 'SSHFP', 'SPF', 'SRV', 'TXT'))
+1
View File
@@ -24,6 +24,7 @@ from .base import BaseSource
class AxfrBaseSource(BaseSource):
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'AAAA', 'CNAME', 'MX', 'NS', 'PTR', 'SPF',
'SRV', 'TXT'))
+3
View File
@@ -16,6 +16,9 @@ class BaseSource(object):
if not hasattr(self, 'SUPPORTS_GEO'):
raise NotImplementedError('Abstract base class, SUPPORTS_GEO '
'property missing')
if not hasattr(self, 'SUPPORTS_DYNAMIC'):
raise NotImplementedError('Abstract base class, SUPPORTS_DYNAMIC '
'property missing')
if not hasattr(self, 'SUPPORTS'):
raise NotImplementedError('Abstract base class, SUPPORTS '
'property missing')
+1
View File
@@ -19,6 +19,7 @@ from .base import BaseSource
class TinyDnsBaseSource(BaseSource):
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A', 'CNAME', 'MX', 'NS'))
split_re = re.compile(r':+')
+20
View File
@@ -17,6 +17,7 @@ class SimpleSource(object):
class SimpleProvider(object):
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
SUPPORTS = set(('A',))
id = 'test'
@@ -35,6 +36,25 @@ class SimpleProvider(object):
class GeoProvider(object):
SUPPORTS_GEO = True
SUPPORTS_DYNAMIC = False
id = 'test'
def __init__(self, id='test'):
pass
def populate(self, zone, source=False, lenient=False):
pass
def supports(self, record):
return True
def __repr__(self):
return self.__class__.__name__
class DynamicProvider(object):
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = True
id = 'test'
def __init__(self, id='test'):
+8 -2
View File
@@ -14,8 +14,8 @@ from octodns.manager import _AggregateTarget, MainThreadExecutor, Manager
from octodns.yaml import safe_load
from octodns.zone import Zone
from helpers import GeoProvider, NoSshFpProvider, SimpleProvider, \
TemporaryDirectory
from helpers import DynamicProvider, GeoProvider, NoSshFpProvider, \
SimpleProvider, TemporaryDirectory
config_dir = join(dirname(__file__), 'config')
@@ -187,6 +187,7 @@ class TestManager(TestCase):
def test_aggregate_target(self):
simple = SimpleProvider()
geo = GeoProvider()
dynamic = DynamicProvider()
nosshfp = NoSshFpProvider()
self.assertFalse(_AggregateTarget([simple, simple]).SUPPORTS_GEO)
@@ -194,6 +195,11 @@ class TestManager(TestCase):
self.assertFalse(_AggregateTarget([geo, simple]).SUPPORTS_GEO)
self.assertTrue(_AggregateTarget([geo, geo]).SUPPORTS_GEO)
self.assertFalse(_AggregateTarget([simple, simple]).SUPPORTS_DYNAMIC)
self.assertFalse(_AggregateTarget([simple, dynamic]).SUPPORTS_DYNAMIC)
self.assertFalse(_AggregateTarget([dynamic, simple]).SUPPORTS_DYNAMIC)
self.assertTrue(_AggregateTarget([dynamic, dynamic]).SUPPORTS_DYNAMIC)
zone = Zone('unit.tests.', [])
record = Record.new(zone, 'sshfp', {
'ttl': 60,
+10 -2
View File
@@ -61,13 +61,21 @@ class TestBaseProvider(TestCase):
class HasSupportsGeo(HasLog):
SUPPORTS_GEO = False
with self.assertRaises(NotImplementedError) as ctx:
HasSupportsGeo('hassupportsgeo')
self.assertEquals('Abstract base class, SUPPORTS_DYNAMIC '
'property missing', ctx.exception.message)
class HasSupportsDyanmic(HasSupportsGeo):
SUPPORTS_DYNAMIC = False
zone = Zone('unit.tests.', ['sub'])
with self.assertRaises(NotImplementedError) as ctx:
HasSupportsGeo('hassupportsgeo').populate(zone)
HasSupportsDyanmic('hassupportsdynamic').populate(zone)
self.assertEquals('Abstract base class, SUPPORTS property missing',
ctx.exception.message)
class HasSupports(HasSupportsGeo):
class HasSupports(HasSupportsDyanmic):
SUPPORTS = set(('A',))
with self.assertRaises(NotImplementedError) as ctx:
HasSupports('hassupports').populate(zone)
+1
View File
@@ -111,6 +111,7 @@ class TestZone(TestCase):
class NoAaaaProvider(object):
id = 'no-aaaa'
SUPPORTS_GEO = False
SUPPORTS_DYNAMIC = False
def supports(self, record):
return record._type != 'AAAA'