| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Author: Chris Moyer | 2 # Author: Chris Moyer |
| 3 # | 3 # |
| 4 # route53 is similar to sdbadmin for Route53, it's a simple | 4 # route53 is similar to sdbadmin for Route53, it's a simple |
| 5 # console utility to perform the most frequent tasks with Route53 | 5 # console utility to perform the most frequent tasks with Route53 |
| 6 # | 6 # |
| 7 # Example usage. Use route53 get after each command to see how the | 7 # Example usage. Use route53 get after each command to see how the |
| 8 # zone changes. | 8 # zone changes. |
| 9 # | 9 # |
| 10 # Add a non-weighted record, change its value, then delete. Default TTL: | 10 # Add a non-weighted record, change its value, then delete. Default TTL: |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 if response.name != name or response.type != type: | 124 if response.name != name or response.type != type: |
| 125 continue | 125 continue |
| 126 if response.identifier != identifier or response.weight != weight: | 126 if response.identifier != identifier or response.weight != weight: |
| 127 continue | 127 continue |
| 128 change1 = changes.add_change("DELETE", name, type, response.ttl, | 128 change1 = changes.add_change("DELETE", name, type, response.ttl, |
| 129 identifier=response.identifier, | 129 identifier=response.identifier, |
| 130 weight=response.weight) | 130 weight=response.weight) |
| 131 for old_value in response.resource_records: | 131 for old_value in response.resource_records: |
| 132 change1.add_value(old_value) | 132 change1.add_value(old_value) |
| 133 | 133 |
| 134 change2 = changes.add_change("CREATE", name, type, ttl, | 134 change2 = changes.add_change("UPSERT", name, type, ttl, |
| 135 identifier=identifier, weight=weight) | 135 identifier=identifier, weight=weight) |
| 136 for new_value in newvalues.split(','): | 136 for new_value in newvalues.split(','): |
| 137 change2.add_value(new_value) | 137 change2.add_value(new_value) |
| 138 print changes.commit() | 138 print changes.commit() |
| 139 | 139 |
| 140 def change_alias(conn, hosted_zone_id, name, type, new_alias_hosted_zone_id, new
_alias_dns_name, identifier=None, weight=None, comment=""): | 140 def change_alias(conn, hosted_zone_id, name, type, new_alias_hosted_zone_id, new
_alias_dns_name, identifier=None, weight=None, comment=""): |
| 141 """Delete and then add an alias to a zone. identifier and weight are option
al.""" | 141 """Delete and then add an alias to a zone. identifier and weight are option
al.""" |
| 142 from boto.route53.record import ResourceRecordSets | 142 from boto.route53.record import ResourceRecordSets |
| 143 changes = ResourceRecordSets(conn, hosted_zone_id, comment) | 143 changes = ResourceRecordSets(conn, hosted_zone_id, comment) |
| 144 # Assume there are not more than 10 WRRs for a given (name, type) | 144 # Assume there are not more than 10 WRRs for a given (name, type) |
| 145 responses = conn.get_all_rrsets(hosted_zone_id, type, name, maxitems=10) | 145 responses = conn.get_all_rrsets(hosted_zone_id, type, name, maxitems=10) |
| 146 for response in responses: | 146 for response in responses: |
| 147 if response.name != name or response.type != type: | 147 if response.name != name or response.type != type: |
| 148 continue | 148 continue |
| 149 if response.identifier != identifier or response.weight != weight: | 149 if response.identifier != identifier or response.weight != weight: |
| 150 continue | 150 continue |
| 151 change1 = changes.add_change("DELETE", name, type, | 151 change1 = changes.add_change("DELETE", name, type, |
| 152 identifier=response.identifier, | 152 identifier=response.identifier, |
| 153 weight=response.weight) | 153 weight=response.weight) |
| 154 change1.set_alias(response.alias_hosted_zone_id, response.alias_dns_name
) | 154 change1.set_alias(response.alias_hosted_zone_id, response.alias_dns_name
) |
| 155 change2 = changes.add_change("CREATE", name, type, identifier=identifier, we
ight=weight) | 155 change2 = changes.add_change("UPSERT", name, type, identifier=identifier, we
ight=weight) |
| 156 change2.set_alias(new_alias_hosted_zone_id, new_alias_dns_name) | 156 change2.set_alias(new_alias_hosted_zone_id, new_alias_dns_name) |
| 157 print changes.commit() | 157 print changes.commit() |
| 158 | 158 |
| 159 def help(conn, fnc=None): | 159 def help(conn, fnc=None): |
| 160 """Prints this help message""" | 160 """Prints this help message""" |
| 161 import inspect | 161 import inspect |
| 162 self = sys.modules['__main__'] | 162 self = sys.modules['__main__'] |
| 163 if fnc: | 163 if fnc: |
| 164 try: | 164 try: |
| 165 cmd = getattr(self, fnc) | 165 cmd = getattr(self, fnc) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 196 else: | 196 else: |
| 197 cmd = help | 197 cmd = help |
| 198 args = [] | 198 args = [] |
| 199 if not cmd: | 199 if not cmd: |
| 200 cmd = help | 200 cmd = help |
| 201 try: | 201 try: |
| 202 cmd(conn, *args) | 202 cmd(conn, *args) |
| 203 except TypeError, e: | 203 except TypeError, e: |
| 204 print e | 204 print e |
| 205 help(conn, cmd.__name__) | 205 help(conn, cmd.__name__) |
| OLD | NEW |