43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
from __future__ import unicode_literals
|
|
from jinja2 import Template
|
|
|
|
from moto.core.responses import BaseResponse
|
|
|
|
|
|
class AvailabilityZonesAndRegions(BaseResponse):
|
|
def describe_availability_zones(self):
|
|
zones = self.ec2_backend.describe_availability_zones()
|
|
template = Template(DESCRIBE_ZONES_RESPONSE)
|
|
return template.render(zones=zones)
|
|
|
|
def describe_regions(self):
|
|
regions = self.ec2_backend.describe_regions()
|
|
template = Template(DESCRIBE_REGIONS_RESPONSE)
|
|
return template.render(regions=regions)
|
|
|
|
DESCRIBE_REGIONS_RESPONSE = """<DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2012-12-01/">
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
<regionInfo>
|
|
{% for region in regions %}
|
|
<item>
|
|
<regionName>{{ region.name }}</regionName>
|
|
<regionEndpoint>{{ region.endpoint }}</regionEndpoint>
|
|
</item>
|
|
{% endfor %}
|
|
</regionInfo>
|
|
</DescribeRegionsResponse>"""
|
|
|
|
DESCRIBE_ZONES_RESPONSE = """<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2012-12-01/">
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
<availabilityZoneInfo>
|
|
{% for zone in zones %}
|
|
<item>
|
|
<zoneName>{{ zone.name }}</zoneName>
|
|
<zoneState>available</zoneState>
|
|
<regionName>{{ zone.region_name }}</regionName>
|
|
<messageSet/>
|
|
</item>
|
|
{% endfor %}
|
|
</availabilityZoneInfo>
|
|
</DescribeAvailabilityZonesResponse>"""
|