Move RRSet parsing inside models so that cloudformation works better.

This commit is contained in:
Steve Pulec 2015-07-14 23:26:49 -04:00
parent e5caaf5913
commit c7090a2b54
2 changed files with 10 additions and 9 deletions

View File

@ -113,6 +113,16 @@ class FakeZone(object):
self.rrsets = []
def add_rrset(self, record_set):
if 'ResourceRecords' in record_set:
resource_records = list(record_set['ResourceRecords'].values())[0]
if not isinstance(resource_records, list):
# Depending on how many records there are, this may or may not be a list
resource_records = [resource_records]
record_values = [x['Value'] for x in resource_records]
elif 'AliasTarget' in record_set:
record_values = [record_set['AliasTarget']['DNSName']]
record_set['ResourceRecords'] = record_values
record_set = RecordSet(record_set)
self.rrsets.append(record_set)
return record_set

View File

@ -55,15 +55,6 @@ def rrset_response(request, full_url, headers):
action = value['Action']
record_set = value['ResourceRecordSet']
if action == 'CREATE':
if 'ResourceRecords' in record_set:
resource_records = list(record_set['ResourceRecords'].values())[0]
if not isinstance(resource_records, list):
# Depending on how many records there are, this may or may not be a list
resource_records = [resource_records]
record_values = [x['Value'] for x in resource_records]
elif 'AliasTarget' in record_set:
record_values = [record_set['AliasTarget']['DNSName']]
record_set['ResourceRecords'] = record_values
the_zone.add_rrset(record_set)
elif action == "DELETE":
if 'SetIdentifier' in record_set: