mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Update rackspace provider with new names and interfaces.
This commit is contained in:
@@ -38,6 +38,8 @@ def unescape_semicolon(s):
|
||||
|
||||
class RackspaceProvider(BaseProvider):
|
||||
SUPPORTS_GEO = False
|
||||
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CNAME', 'MX', 'NS', 'PTR', 'SPF',
|
||||
'TXT'))
|
||||
TIMEOUT = 5
|
||||
|
||||
def __init__(self, id, username, api_key, ratelimit_delay, *args,
|
||||
@@ -153,7 +155,6 @@ class RackspaceProvider(BaseProvider):
|
||||
_data_for_AAAA = _data_for_multiple
|
||||
|
||||
def _data_for_NS(self, rrset):
|
||||
# TODO: geo not supported
|
||||
return {
|
||||
'type': rrset[0]['type'],
|
||||
'values': [add_trailing_dot(r['data']) for r in rrset],
|
||||
@@ -194,7 +195,7 @@ class RackspaceProvider(BaseProvider):
|
||||
'ttl': rrset[0]['ttl']
|
||||
}
|
||||
|
||||
def populate(self, zone, target=False):
|
||||
def populate(self, zone, target=False, lenient=False):
|
||||
self.log.debug('populate: name=%s', zone.name)
|
||||
resp_data = None
|
||||
try:
|
||||
@@ -279,21 +280,11 @@ class RackspaceProvider(BaseProvider):
|
||||
return {
|
||||
'name': remove_trailing_dot(record.fqdn),
|
||||
'type': record._type,
|
||||
'data': remove_trailing_dot(value.value),
|
||||
'data': remove_trailing_dot(value.exchange),
|
||||
'ttl': max(record.ttl, 300),
|
||||
'priority': value.priority
|
||||
'priority': value.preference
|
||||
}
|
||||
|
||||
def _record_for_unsupported(self, record, value):
|
||||
raise NotImplementedError(
|
||||
"Missing support for writing {} records".format(
|
||||
record.__class__.__name__))
|
||||
|
||||
_record_for_SOA = _record_for_unsupported
|
||||
_record_for_SRV = _record_for_unsupported
|
||||
_record_for_NAPTR = _record_for_unsupported
|
||||
_record_for_SSHFP = _record_for_unsupported
|
||||
|
||||
def _get_values(self, record):
|
||||
try:
|
||||
return record.values
|
||||
|
||||
@@ -94,30 +94,6 @@ class TestRackspaceProvider(TestCase):
|
||||
self.provider.populate(zone)
|
||||
self.assertEquals(5, len(zone.records))
|
||||
|
||||
def _load_full_config(self):
|
||||
expected = Zone('unit.tests.', [])
|
||||
source = YamlProvider('test', join(dirname(__file__), 'config'))
|
||||
source.populate(expected)
|
||||
self.assertEquals(15, len(expected.records))
|
||||
return expected
|
||||
|
||||
def test_changes_are_formatted_correctly(self):
|
||||
expected = self._load_full_config()
|
||||
|
||||
# No diffs == no changes
|
||||
with requests_mock() as mock:
|
||||
mock.get(re.compile('domains$'), status_code=200,
|
||||
text=LIST_DOMAINS_RESPONSE)
|
||||
mock.get(re.compile('records'), status_code=200,
|
||||
text=RECORDS_PAGE_1)
|
||||
mock.get(re.compile('records.*offset=3'), status_code=200,
|
||||
text=RECORDS_PAGE_2)
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
self.provider.populate(zone)
|
||||
changes = expected.changes(zone, self.provider)
|
||||
self.assertEquals(18, len(changes))
|
||||
|
||||
def test_plan_disappearing_ns_records(self):
|
||||
expected = Zone('unit.tests.', [])
|
||||
expected.add_record(Record.new(expected, '', {
|
||||
@@ -417,35 +393,6 @@ class TestRackspaceProvider(TestCase):
|
||||
|
||||
return self._test_apply_with_data(TestData)
|
||||
|
||||
def test_apply_create_SRV(self):
|
||||
class TestData(object):
|
||||
OtherRecords = [
|
||||
{
|
||||
"subdomain": '_a.b',
|
||||
"data": {
|
||||
'type': 'SRV',
|
||||
'ttl': 300,
|
||||
'value': {
|
||||
'priority': 20,
|
||||
'weight': 999,
|
||||
'port': 999,
|
||||
'target': 'foo'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
OwnRecords = {
|
||||
"totalEntries": 0,
|
||||
"records": []
|
||||
}
|
||||
ExpectChanges = True
|
||||
ExpectedAdditions = [{}]
|
||||
ExpectedDeletions = None
|
||||
ExpectedUpdates = None
|
||||
|
||||
assert_raises(NotImplementedError, self._test_apply_with_data,
|
||||
TestData)
|
||||
|
||||
def test_apply_multiple_additions_splatting(self):
|
||||
class TestData(object):
|
||||
OtherRecords = [
|
||||
|
||||
Reference in New Issue
Block a user