Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fixed a couple of annoyances in Route53 #1084

Open
wants to merge 4 commits into
from
View
@@ -123,6 +123,7 @@ def get_hosted_zone(self, hosted_zone_id):
:param hosted_zone_id: The unique identifier for the Hosted Zone
"""
+ hosted_zone_id = self._sanitize_zone_id(hosted_zone_id)
uri = '/%s/hostedzone/%s' % (self.Version, hosted_zone_id)
response = self.make_request('GET', uri)
body = response.read()
@@ -206,6 +207,7 @@ def create_hosted_zone(self, domain_name, caller_ref=None, comment=''):
body)
def delete_hosted_zone(self, hosted_zone_id):
+ hosted_zone_id = self._sanitize_zone_id(hosted_zone_id)
uri = '/%s/hostedzone/%s' % (self.Version, hosted_zone_id)
response = self.make_request('DELETE', uri)
body = response.read()
@@ -273,6 +275,8 @@ def get_all_rrsets(self, hosted_zone_id, type=None,
:param maxitems: The maximum number of records
"""
+ from boto.route53.record import ResourceRecordSets
@garnaat

garnaat Jan 8, 2013

Owner

Why is this here?

+ hosted_zone_id = self._sanitize_zone_id(hosted_zone_id)
params = {'type': type, 'name': name,
'Identifier': identifier, 'maxitems': maxitems}
uri = '/%s/hostedzone/%s/rrset' % (self.Version, hosted_zone_id)
@@ -303,6 +307,7 @@ def change_rrsets(self, hosted_zone_id, xml_body):
XML schema defined by the Route53 service.
"""
+ hosted_zone_id = self._sanitize_zone_id(hosted_zone_id)
uri = '/%s/hostedzone/%s/rrset' % (self.Version, hosted_zone_id)
response = self.make_request('POST', uri,
{'Content-Type': 'text/xml'},
@@ -343,6 +348,15 @@ def get_change(self, change_id):
h.parse(body)
return e
+ def _sanitize_zone_id(self , zone_id):
+ """
+ The "Id" value of a hosted zone is actually returned as
+ "/hostedzone/<Id>". This breaks any calls that use that zone id
+ if it is not removed outside of this library. This method
+ simply removes that.
+ """
+ return zone_id.replace('/hostedzone/' , '')
+
def create_zone(self, name):
"""
Create a new Hosted Zone. Returns a Zone object for the newly
View
@@ -66,7 +66,7 @@ def __repr__(self):
def add_change(self, action, name, type, ttl=600,
alias_hosted_zone_id=None, alias_dns_name=None, identifier=None,
- weight=None, region=None):
+ weight=None, region=None , resource_records=None):
"""
Add a change request to the set.
@@ -118,11 +118,16 @@ def add_change(self, action, name, type, ttl=600,
record sets that have the same combination of DNS name and type,
a value that determines which region this should be associated with
for the latency-based routing
+
+ :type resource_records list
+ :param resource_records *An optional list of the resource records for
+ this record
"""
change = Record(name, type, ttl,
alias_hosted_zone_id=alias_hosted_zone_id,
alias_dns_name=alias_dns_name, identifier=identifier,
- weight=weight, region=region)
+ weight=weight, region=region ,
+ resource_records=resource_records)
self.changes.append([action, change])
return change