Merge pull request #544 from beeva-antonioirizar/fix_route53
Fix route53
This commit is contained in:
commit
e051fa779d
@ -95,52 +95,54 @@ 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/">
|
||||||
<MetricAlarms>
|
<DescribeAlarmsResult>
|
||||||
{% for alarm in alarms %}
|
<MetricAlarms>
|
||||||
<member>
|
{% for alarm in alarms %}
|
||||||
<ActionsEnabled>{{ alarm.actions_enabled }}</ActionsEnabled>
|
<member>
|
||||||
<AlarmActions>
|
<ActionsEnabled>{{ alarm.actions_enabled }}</ActionsEnabled>
|
||||||
{% for action in alarm.alarm_actions %}
|
<AlarmActions>
|
||||||
<member>{{ action }}</member>
|
{% for action in alarm.alarm_actions %}
|
||||||
{% endfor %}
|
<member>{{ action }}</member>
|
||||||
</AlarmActions>
|
{% endfor %}
|
||||||
<AlarmArn>{{ alarm.arn }}</AlarmArn>
|
</AlarmActions>
|
||||||
<AlarmConfigurationUpdatedTimestamp>{{ alarm.configuration_updated_timestamp }}</AlarmConfigurationUpdatedTimestamp>
|
<AlarmArn>{{ alarm.arn }}</AlarmArn>
|
||||||
<AlarmDescription>{{ alarm.description }}</AlarmDescription>
|
<AlarmConfigurationUpdatedTimestamp>{{ alarm.configuration_updated_timestamp }}</AlarmConfigurationUpdatedTimestamp>
|
||||||
<AlarmName>{{ alarm.name }}</AlarmName>
|
<AlarmDescription>{{ alarm.description }}</AlarmDescription>
|
||||||
<ComparisonOperator>{{ alarm.comparison_operator }}</ComparisonOperator>
|
<AlarmName>{{ alarm.name }}</AlarmName>
|
||||||
<Dimensions>
|
<ComparisonOperator>{{ alarm.comparison_operator }}</ComparisonOperator>
|
||||||
{% for dimension in alarm.dimensions %}
|
<Dimensions>
|
||||||
<member>
|
{% for dimension in alarm.dimensions %}
|
||||||
<Name>{{ dimension.name }}</Name>
|
<member>
|
||||||
<Value>{{ dimension.value }}</Value>
|
<Name>{{ dimension.name }}</Name>
|
||||||
</member>
|
<Value>{{ dimension.value }}</Value>
|
||||||
{% endfor %}
|
</member>
|
||||||
</Dimensions>
|
{% endfor %}
|
||||||
<EvaluationPeriods>{{ alarm.evaluation_periods }}</EvaluationPeriods>
|
</Dimensions>
|
||||||
<InsufficientDataActions>
|
<EvaluationPeriods>{{ alarm.evaluation_periods }}</EvaluationPeriods>
|
||||||
{% for action in alarm.insufficient_data_actions %}
|
<InsufficientDataActions>
|
||||||
<member>{{ action }}</member>
|
{% for action in alarm.insufficient_data_actions %}
|
||||||
{% endfor %}
|
<member>{{ action }}</member>
|
||||||
</InsufficientDataActions>
|
{% endfor %}
|
||||||
<MetricName>{{ alarm.metric_name }}</MetricName>
|
</InsufficientDataActions>
|
||||||
<Namespace>{{ alarm.namespace }}</Namespace>
|
<MetricName>{{ alarm.metric_name }}</MetricName>
|
||||||
<OKActions>
|
<Namespace>{{ alarm.namespace }}</Namespace>
|
||||||
{% for action in alarm.ok_actions %}
|
<OKActions>
|
||||||
<member>{{ action }}</member>
|
{% for action in alarm.ok_actions %}
|
||||||
{% endfor %}
|
<member>{{ action }}</member>
|
||||||
</OKActions>
|
{% endfor %}
|
||||||
<Period>{{ alarm.period }}</Period>
|
</OKActions>
|
||||||
<StateReason>{{ alarm.state_reason }}</StateReason>
|
<Period>{{ alarm.period }}</Period>
|
||||||
<StateReasonData>{{ alarm.state_reason_data }}</StateReasonData>
|
<StateReason>{{ alarm.state_reason }}</StateReason>
|
||||||
<StateUpdatedTimestamp>{{ alarm.state_updated_timestamp }}</StateUpdatedTimestamp>
|
<StateReasonData>{{ alarm.state_reason_data }}</StateReasonData>
|
||||||
<StateValue>{{ alarm.state_value }}</StateValue>
|
<StateUpdatedTimestamp>{{ alarm.state_updated_timestamp }}</StateUpdatedTimestamp>
|
||||||
<Statistic>{{ alarm.statistic }}</Statistic>
|
<StateValue>{{ alarm.state_value }}</StateValue>
|
||||||
<Threshold>{{ alarm.threshold }}</Threshold>
|
<Statistic>{{ alarm.statistic }}</Statistic>
|
||||||
<Unit>{{ alarm.unit }}</Unit>
|
<Threshold>{{ alarm.threshold }}</Threshold>
|
||||||
</member>
|
<Unit>{{ alarm.unit }}</Unit>
|
||||||
{% endfor %}
|
</member>
|
||||||
</MetricAlarms>
|
{% endfor %}
|
||||||
|
</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/">
|
||||||
|
@ -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_
|
||||||
self.comment = comment
|
if comment is not None:
|
||||||
|
self.comment = comment
|
||||||
|
self.private_zone = False
|
||||||
self.rrsets = []
|
self.rrsets = []
|
||||||
|
|
||||||
def add_rrset(self, record_set):
|
def add_rrset(self, record_set):
|
||||||
|
@ -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)
|
||||||
comment = elements["CreateHostedZoneRequest"]["HostedZoneConfig"]["Comment"]
|
if "HostedZoneConfig" in elements["CreateHostedZoneRequest"]:
|
||||||
|
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>
|
||||||
<Comment>{{ zone.comment }}</Comment>
|
{% if zone.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>
|
||||||
<Comment>{{ zone.comment }}</Comment>
|
{% if zone.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"?>
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user