-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-dns.py
executable file
·37 lines (29 loc) · 962 Bytes
/
setup-dns.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
import sys
from pyactiveresource import ActiveResource
if not len(sys.argv) == 3:
print 'usage: %s zone_id api_password' % sys.argv[0]
sys.exit()
zone_id = sys.argv[1]
api_password = sys.argv[2]
class Zone(ActiveResource):
class Meta:
site = api_site
class Record(ActiveResource):
class Meta:
site = api_site
data = (
('MX', 'ASPMX.L.GOOGLE.COM.', 10),
('MX', 'ALT1.ASPMX.L.GOOGLE.COM.', 20),
('MX', 'ALT2.ASPMX.L.GOOGLE.COM.', 20),
('MX', 'ASPMX2.GOOGLEMAIL.COM.', 30),
('MX', 'ASPMX3.GOOGLEMAIL.COM.', 30),
('MX', 'ASPMX4.GOOGLEMAIL.COM.', 30),
('MX', 'ASPMX5.GOOGLEMAIL.COM.', 30),
('TXT', 'v=spf1 include:aspmx.googlemail.com ~all', 0),
)
z = Zone.find(id=zone_id)[0]
for d in data:
r = Record(data=d[1], record_type=d[0], aux=d[2], zone_id=z.id, name=z.origin)
print r.save()