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 def _print_zone_info(zoneinfo): | 7 def _print_zone_info(zoneinfo): |
8 print "="*80 | 8 print "="*80 |
9 print "| ID: %s" % zoneinfo['Id'].split("/")[-1] | 9 print "| ID: %s" % zoneinfo['Id'].split("/")[-1] |
10 print "| Name: %s" % zoneinfo['Name'] | 10 print "| Name: %s" % zoneinfo['Name'] |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 changes = ResourceRecordSets(conn, hosted_zone_id, comment) | 85 changes = ResourceRecordSets(conn, hosted_zone_id, comment) |
86 response = conn.get_all_rrsets(hosted_zone_id, type, name, maxitems=1)[0] | 86 response = conn.get_all_rrsets(hosted_zone_id, type, name, maxitems=1)[0] |
87 change1 = changes.add_change("DELETE", name, type, response.ttl) | 87 change1 = changes.add_change("DELETE", name, type, response.ttl) |
88 for old_value in response.resource_records: | 88 for old_value in response.resource_records: |
89 change1.add_value(old_value) | 89 change1.add_value(old_value) |
90 change2 = changes.add_change("CREATE", name, type, ttl) | 90 change2 = changes.add_change("CREATE", name, type, ttl) |
91 for new_value in values.split(','): | 91 for new_value in values.split(','): |
92 change2.add_value(new_value) | 92 change2.add_value(new_value) |
93 print changes.commit() | 93 print changes.commit() |
94 | 94 |
| 95 def change_alias(conn, hosted_zone_id, name, type, alias_hosted_zone_id, alias_d
ns_name, comment=""): |
| 96 """Delete and then add an alias to a zone""" |
| 97 from boto.route53.record import ResourceRecordSets |
| 98 changes = ResourceRecordSets(conn, hosted_zone_id, comment) |
| 99 response = conn.get_all_rrsets(hosted_zone_id, type, name, maxitems=1)[0] |
| 100 change1 = changes.add_change("DELETE", name, type) |
| 101 change1.set_alias(response.alias_hosted_zone_id, response.alias_dns_name) |
| 102 change2 = changes.add_change("CREATE", name, type) |
| 103 change2.set_alias(alias_hosted_zone_id, alias_dns_name) |
| 104 print changes.commit() |
| 105 |
95 def help(conn, fnc=None): | 106 def help(conn, fnc=None): |
96 """Prints this help message""" | 107 """Prints this help message""" |
97 import inspect | 108 import inspect |
98 self = sys.modules['__main__'] | 109 self = sys.modules['__main__'] |
99 if fnc: | 110 if fnc: |
100 try: | 111 try: |
101 cmd = getattr(self, fnc) | 112 cmd = getattr(self, fnc) |
102 except: | 113 except: |
103 cmd = None | 114 cmd = None |
104 if not inspect.isfunction(cmd): | 115 if not inspect.isfunction(cmd): |
(...skipping 27 matching lines...) Expand all Loading... |
132 else: | 143 else: |
133 cmd = help | 144 cmd = help |
134 args = [] | 145 args = [] |
135 if not cmd: | 146 if not cmd: |
136 cmd = help | 147 cmd = help |
137 try: | 148 try: |
138 cmd(conn, *args) | 149 cmd(conn, *args) |
139 except TypeError, e: | 150 except TypeError, e: |
140 print e | 151 print e |
141 help(conn, cmd.__name__) | 152 help(conn, cmd.__name__) |
OLD | NEW |