diff options
Diffstat (limited to 'boto/route53/record.py')
-rw-r--r-- | boto/route53/record.py | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/boto/route53/record.py b/boto/route53/record.py index 664739b8..d871e0bd 100644 --- a/boto/route53/record.py +++ b/boto/route53/record.py @@ -25,6 +25,8 @@ RECORD_TYPES = ['A', 'AAAA', 'TXT', 'CNAME', 'MX', 'PTR', 'SRV', 'SPF'] from boto.resultset import ResultSet + + class ResourceRecordSets(ResultSet): """ A list of resource records. @@ -54,6 +56,7 @@ class ResourceRecordSets(ResultSet): self.changes = [] self.next_record_name = None self.next_record_type = None + self.next_record_identifier = None super(ResourceRecordSets, self).__init__([('ResourceRecordSet', Record)]) def __repr__(self): @@ -65,9 +68,9 @@ class ResourceRecordSets(ResultSet): record_list) def add_change(self, action, name, type, ttl=600, - alias_hosted_zone_id=None, alias_dns_name=None, identifier=None, - weight=None, region=None, alias_evaluate_target_health=None, - health_check=None, failover=None): + alias_hosted_zone_id=None, alias_dns_name=None, identifier=None, + weight=None, region=None, alias_evaluate_target_health=None, + health_check=None, failover=None): """ Add a change request to the set. @@ -121,10 +124,10 @@ class ResourceRecordSets(ResultSet): for the latency-based routing :type alias_evaluate_target_health: Boolean - :param alias_evaluate_target_health: *Required for alias resource record sets* Indicates - whether this Resource Record Set should respect the health status of - any health checks associated with the ALIAS target record which it is - linked to. + :param alias_evaluate_target_health: *Required for alias resource record + sets* Indicates whether this Resource Record Set should respect the + health status of any health checks associated with the ALIAS target + record which it is linked to. :type health_check: str :param health_check: Health check to associate with this record @@ -134,11 +137,11 @@ class ResourceRecordSets(ResultSet): primary or secondary resource record set. """ 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, - alias_evaluate_target_health=alias_evaluate_target_health, - health_check=health_check, failover=failover) + alias_hosted_zone_id=alias_hosted_zone_id, + alias_dns_name=alias_dns_name, identifier=identifier, + weight=weight, region=region, + alias_evaluate_target_health=alias_evaluate_target_health, + health_check=health_check, failover=failover) self.changes.append([action, change]) return change @@ -165,12 +168,14 @@ class ResourceRecordSets(ResultSet): return self.connection.change_rrsets(self.hosted_zone_id, self.to_xml()) def endElement(self, name, value, connection): - """Overwritten to also add the NextRecordName and - NextRecordType to the base object""" + """Overwritten to also add the NextRecordName, + NextRecordType and NextRecordIdentifier to the base object""" if name == 'NextRecordName': self.next_record_name = value elif name == 'NextRecordType': self.next_record_type = value + elif name == 'NextRecordIdentifier': + self.next_record_identifier = value else: return super(ResourceRecordSets, self).endElement(name, value, connection) @@ -183,14 +188,14 @@ class ResourceRecordSets(ResultSet): yield obj if self.is_truncated: self.is_truncated = False - results = self.connection.get_all_rrsets(self.hosted_zone_id, name=self.next_record_name, type=self.next_record_type) + results = self.connection.get_all_rrsets(self.hosted_zone_id, name=self.next_record_name, + type=self.next_record_type, + identifier=self.next_record_identifier) else: results = None self.is_truncated = truncated - - class Record(object): """An individual ResourceRecordSet""" @@ -237,11 +242,10 @@ class Record(object): EvaluateTargetHealth = """<EvaluateTargetHealth>%s</EvaluateTargetHealth>""" - def __init__(self, name=None, type=None, ttl=600, resource_records=None, - alias_hosted_zone_id=None, alias_dns_name=None, identifier=None, - weight=None, region=None, alias_evaluate_target_health=None, - health_check=None, failover=None): + alias_hosted_zone_id=None, alias_dns_name=None, identifier=None, + weight=None, region=None, alias_evaluate_target_health=None, + health_check=None, failover=None): self.name = name self.type = type self.ttl = ttl @@ -280,9 +284,9 @@ class Record(object): else: eval_target_health = "" - body = self.AliasBody % { "hosted_zone_id": self.alias_hosted_zone_id, - "dns_name": self.alias_dns_name, - "eval_target_health": eval_target_health } + body = self.AliasBody % {"hosted_zone_id": self.alias_hosted_zone_id, + "dns_name": self.alias_dns_name, + "eval_target_health": eval_target_health} else: # Use resource record(s) records = "" @@ -298,14 +302,14 @@ class Record(object): weight = "" if self.identifier is not None and self.weight is not None: - weight = self.WRRBody % {"identifier": self.identifier, "weight": - self.weight} + weight = self.WRRBody % {"identifier": self.identifier, + "weight": self.weight} elif self.identifier is not None and self.region is not None: - weight = self.RRRBody % {"identifier": self.identifier, "region": - self.region} + weight = self.RRRBody % {"identifier": self.identifier, + "region": self.region} elif self.identifier is not None and self.failover is not None: - weight = self.FailoverBody % {"identifier": self.identifier, "failover": - self.failover} + weight = self.FailoverBody % {"identifier": self.identifier, + "failover": self.failover} health_check = "" if self.health_check is not None: @@ -329,7 +333,7 @@ class Record(object): rr += ' (EvalTarget %s)' % self.alias_evaluate_target_health else: # Show resource record(s) - rr = ",".join(self.resource_records) + rr = ",".join(self.resource_records) if self.identifier is not None and self.weight is not None: rr += ' (WRR id=%s, w=%s)' % (self.identifier, self.weight) |