Created
March 12, 2010 21:51
-
-
Save lucky/330832 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Automatically add Google MX records to a domain using Slicehost DNS. | |
Requires:: | |
PyActiveResource: http://superjared.com/projects/pyactiveresource/ | |
Edit the zone_id below, add your api password and run. To find your zone_id, | |
go to the DNS tab of the SliceManager, click the 'edit' next to your | |
domain. The URL will have the id:: | |
https://manage.slicehost.com/zones/<zone_id>/edit | |
""" | |
from pyactiveresource.activeresource import ActiveResource | |
import sys | |
zone_id = 1 | |
api_password = 'your api password' | |
api_site = 'https://%s@api.slicehost.com/' % api_password | |
class Zone(ActiveResource): | |
_site = api_site | |
class Record(ActiveResource): | |
_site = api_site | |
data = ( | |
('ASPMX.L.GOOGLE.COM.', 10), | |
('ALT1.ASPMX.L.GOOGLE.COM.', 20), | |
('ALT2.ASPMX.L.GOOGLE.COM.', 20), | |
('ASPMX2.GOOGLEMAIL.COM.', 30), | |
('ASPMX3.GOOGLEMAIL.COM.', 30), | |
('ASPMX4.GOOGLEMAIL.COM.', 30), | |
('ASPMX5.GOOGLEMAIL.COM.', 30), | |
) | |
def main(): | |
z = Zone.find(zone_id) | |
for d in data: | |
r = Record({'data': d[0], 'record_type': 'MX', 'aux': d[1], 'zone_id': z.id, 'name': z.origin}) | |
print r.save() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment