Merge pull request #544 from beeva-antonioirizar/fix_route53

Fix route53
This commit is contained in:
Steve Pulec 2016-02-17 16:43:33 -05:00
commit e051fa779d
4 changed files with 79 additions and 50 deletions

View File

@ -95,6 +95,7 @@ PUT_METRIC_ALARM_TEMPLATE = """<PutMetricAlarmResponse xmlns="http://monitoring.
</PutMetricAlarmResponse>""" </PutMetricAlarmResponse>"""
DESCRIBE_ALARMS_TEMPLATE = """<DescribeAlarmsResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/"> DESCRIBE_ALARMS_TEMPLATE = """<DescribeAlarmsResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/">
<DescribeAlarmsResult>
<MetricAlarms> <MetricAlarms>
{% for alarm in alarms %} {% for alarm in alarms %}
<member> <member>
@ -141,6 +142,7 @@ DESCRIBE_ALARMS_TEMPLATE = """<DescribeAlarmsResponse xmlns="http://monitoring.a
</member> </member>
{% endfor %} {% endfor %}
</MetricAlarms> </MetricAlarms>
</DescribeAlarmsResult>
</DescribeAlarmsResponse>""" </DescribeAlarmsResponse>"""
DELETE_METRIC_ALARMS_TEMPLATE = """<DeleteMetricAlarmResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/"> DELETE_METRIC_ALARMS_TEMPLATE = """<DeleteMetricAlarmResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/">

View File

@ -113,7 +113,9 @@ class FakeZone(object):
def __init__(self, name, id_, comment=None): def __init__(self, name, id_, comment=None):
self.name = name self.name = name
self.id = id_ self.id = id_
if comment is not None:
self.comment = comment self.comment = comment
self.private_zone = False
self.rrsets = [] self.rrsets = []
def add_rrset(self, record_set): def add_rrset(self, record_set):

View File

@ -9,7 +9,10 @@ def list_or_create_hostzone_response(request, full_url, headers):
if request.method == "POST": if request.method == "POST":
elements = xmltodict.parse(request.body) elements = xmltodict.parse(request.body)
if "HostedZoneConfig" in elements["CreateHostedZoneRequest"]:
comment = elements["CreateHostedZoneRequest"]["HostedZoneConfig"]["Comment"] comment = elements["CreateHostedZoneRequest"]["HostedZoneConfig"]["Comment"]
else:
comment = None
new_zone = route53_backend.create_hosted_zone(elements["CreateHostedZoneRequest"]["Name"], comment=comment) new_zone = route53_backend.create_hosted_zone(elements["CreateHostedZoneRequest"]["Name"], comment=comment)
template = Template(CREATE_HOSTED_ZONE_RESPONSE) template = Template(CREATE_HOSTED_ZONE_RESPONSE)
return 201, headers, template.render(zone=new_zone) return 201, headers, template.render(zone=new_zone)
@ -110,6 +113,14 @@ def health_check_response(request, full_url, headers):
health_checks = route53_backend.get_health_checks() health_checks = route53_backend.get_health_checks()
return 200, headers, template.render(health_checks=health_checks) return 200, headers, template.render(health_checks=health_checks)
def not_implemented_response(request, full_url, headers):
action = ''
if 'tags' in full_url:
action = 'tags'
elif 'trafficpolicyinstances' in full_url:
action = 'policies'
raise NotImplementedError("The action for {0} has not been implemented for route 53".format(action))
LIST_RRSET_REPONSE = """<ListResourceRecordSetsResponse xmlns="https://route53.amazonaws.com/doc/2012-12-12/"> LIST_RRSET_REPONSE = """<ListResourceRecordSetsResponse xmlns="https://route53.amazonaws.com/doc/2012-12-12/">
<ResourceRecordSets> <ResourceRecordSets>
@ -138,7 +149,10 @@ GET_HOSTED_ZONE_RESPONSE = """<GetHostedZoneResponse xmlns="https://route53.amaz
<Name>{{ zone.name }}</Name> <Name>{{ zone.name }}</Name>
<ResourceRecordSetCount>{{ zone.rrsets|count }}</ResourceRecordSetCount> <ResourceRecordSetCount>{{ zone.rrsets|count }}</ResourceRecordSetCount>
<Config> <Config>
{% if zone.comment %}
<Comment>{{ zone.comment }}</Comment> <Comment>{{ zone.comment }}</Comment>
{% endif %}
<PrivateZone>{{ zone.private_zone }}</PrivateZone>
</Config> </Config>
</HostedZone> </HostedZone>
<DelegationSet> <DelegationSet>
@ -153,6 +167,12 @@ CREATE_HOSTED_ZONE_RESPONSE = """<CreateHostedZoneResponse xmlns="https://route5
<Id>/hostedzone/{{ zone.id }}</Id> <Id>/hostedzone/{{ zone.id }}</Id>
<Name>{{ zone.name }}</Name> <Name>{{ zone.name }}</Name>
<ResourceRecordSetCount>0</ResourceRecordSetCount> <ResourceRecordSetCount>0</ResourceRecordSetCount>
<Config>
{% if zone.comment %}
<Comment>{{ zone.comment }}</Comment>
{% endif %}
<PrivateZone>{{ zone.private_zone }}</PrivateZone>
</Config>
</HostedZone> </HostedZone>
<DelegationSet> <DelegationSet>
<NameServers> <NameServers>
@ -168,12 +188,16 @@ LIST_HOSTED_ZONES_RESPONSE = """<ListHostedZonesResponse xmlns="https://route53.
<Id>{{ zone.id }}</Id> <Id>{{ zone.id }}</Id>
<Name>{{ zone.name }}</Name> <Name>{{ zone.name }}</Name>
<Config> <Config>
{% if zone.comment %}
<Comment>{{ zone.comment }}</Comment> <Comment>{{ zone.comment }}</Comment>
{% endif %}
<PrivateZone>{{ zone.private_zone }}</PrivateZone>
</Config> </Config>
<ResourceRecordSetCount>{{ zone.rrsets|count }}</ResourceRecordSetCount> <ResourceRecordSetCount>{{ zone.rrsets|count }}</ResourceRecordSetCount>
</HostedZone> </HostedZone>
{% endfor %} {% endfor %}
</HostedZones> </HostedZones>
<IsTruncated>false</IsTruncated>
</ListHostedZonesResponse>""" </ListHostedZonesResponse>"""
CREATE_HEALTH_CHECK_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?> CREATE_HEALTH_CHECK_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>

View File

@ -10,4 +10,5 @@ url_paths = {
'{0}hostedzone/[^/]+$': responses.get_or_delete_hostzone_response, '{0}hostedzone/[^/]+$': responses.get_or_delete_hostzone_response,
'{0}hostedzone/[^/]+/rrset$': responses.rrset_response, '{0}hostedzone/[^/]+/rrset$': responses.rrset_response,
'{0}healthcheck': responses.health_check_response, '{0}healthcheck': responses.health_check_response,
'{0}tags|trafficpolicyinstances/*': responses.not_implemented_response,
} }