support route53 HostedZone PrivateZone=True #627
This commit is contained in:
parent
4372c346d9
commit
8fa53c1453
3 changed files with 64 additions and 6 deletions
|
|
@ -147,12 +147,12 @@ class RecordSet(object):
|
|||
|
||||
class FakeZone(object):
|
||||
|
||||
def __init__(self, name, id_, comment=None):
|
||||
def __init__(self, name, id_, private_zone, comment=None):
|
||||
self.name = name
|
||||
self.id = id_
|
||||
if comment is not None:
|
||||
self.comment = comment
|
||||
self.private_zone = False
|
||||
self.private_zone = private_zone
|
||||
self.rrsets = []
|
||||
|
||||
def add_rrset(self, record_set):
|
||||
|
|
@ -194,7 +194,7 @@ class FakeZone(object):
|
|||
properties = cloudformation_json['Properties']
|
||||
name = properties["Name"]
|
||||
|
||||
hosted_zone = route53_backend.create_hosted_zone(name)
|
||||
hosted_zone = route53_backend.create_hosted_zone(name, private_zone=False)
|
||||
return hosted_zone
|
||||
|
||||
|
||||
|
|
@ -227,9 +227,9 @@ class Route53Backend(BaseBackend):
|
|||
self.zones = {}
|
||||
self.health_checks = {}
|
||||
|
||||
def create_hosted_zone(self, name, comment=None):
|
||||
def create_hosted_zone(self, name, private_zone, comment=None):
|
||||
new_id = get_random_hex()
|
||||
new_zone = FakeZone(name, new_id, comment=comment)
|
||||
new_zone = FakeZone(name, new_id, private_zone=private_zone, comment=comment)
|
||||
self.zones[new_id] = new_zone
|
||||
return new_zone
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,21 @@ def list_or_create_hostzone_response(request, full_url, headers):
|
|||
elements = xmltodict.parse(request.body)
|
||||
if "HostedZoneConfig" in elements["CreateHostedZoneRequest"]:
|
||||
comment = elements["CreateHostedZoneRequest"]["HostedZoneConfig"]["Comment"]
|
||||
try:
|
||||
# in boto3, this field is set directly in the xml
|
||||
private_zone = elements["CreateHostedZoneRequest"]["HostedZoneConfig"]["PrivateZone"]
|
||||
except KeyError:
|
||||
# if a VPC subsection is only included in xmls params when private_zone=True,
|
||||
# see boto: boto/route53/connection.py
|
||||
private_zone = 'VPC' in elements["CreateHostedZoneRequest"]
|
||||
else:
|
||||
comment = None
|
||||
new_zone = route53_backend.create_hosted_zone(elements["CreateHostedZoneRequest"]["Name"], comment=comment)
|
||||
private_zone = False
|
||||
new_zone = route53_backend.create_hosted_zone(
|
||||
elements["CreateHostedZoneRequest"]["Name"],
|
||||
comment=comment,
|
||||
private_zone=private_zone,
|
||||
)
|
||||
template = Template(CREATE_HOSTED_ZONE_RESPONSE)
|
||||
return 201, headers, template.render(zone=new_zone)
|
||||
|
||||
|
|
@ -32,6 +44,7 @@ def get_or_delete_hostzone_response(request, full_url, headers):
|
|||
|
||||
if request.method == "GET":
|
||||
template = Template(GET_HOSTED_ZONE_RESPONSE)
|
||||
|
||||
return 200, headers, template.render(zone=the_zone)
|
||||
elif request.method == "DELETE":
|
||||
route53_backend.delete_hosted_zone(zoneid)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue