Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: DNS Batch Update
PostPosted: Thu Jun 16, 2011 10:49 pm 
Offline
Senior Newbie

Joined: Thu Jun 16, 2011 10:40 pm
Posts: 5
Website: http://snowulf.com
Location: San Francisco, CA
It would be really quite nice if there was some way to mass update some/all of the DNS records in DNS manager. For example I recently switch from using an HE IPv6 tunnel to Linode provided native IPv6 which necessitated updating every single domain by hand. It would have been very nice to have a "add X record to all domains" or "replace all instances of X for Y".

_________________
Have you tried rebooting?


Top
   
 Post subject: Re: DNS Batch Update
PostPosted: Sat Jun 18, 2011 6:36 pm 
Offline
Senior Member

Joined: Fri Dec 10, 2010 6:21 am
Posts: 144
ShakataGaNai wrote:
It would be really quite nice if there was some way to mass update some/all of the DNS records in DNS manager. For example I recently switch from using an HE IPv6 tunnel to Linode provided native IPv6 which necessitated updating every single domain by hand. It would have been very nice to have a "add X record to all domains" or "replace all instances of X for Y".


This may not be what you had in mind, but there are APIs to do these things if you want to automate things: http://www.linode.com/api/dns


Top
   
 Post subject:
PostPosted: Sun Jun 19, 2011 2:13 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
As an example of how the API can be used to solve this for the programatically-inclined, here is a quick, one-off script I wrote shortly after the API was released. I used it to move "everything else" from an old Linode in Dallas to a new one in Newark:

Code:
#!/usr/bin/python
import api

instance = api.Api(key='urmom')

for domain in instance.domain_list():
    if domain['TYPE'] == 'master':
        print "Updating %s (%i)..." % (domain['DOMAIN'], domain['DOMAINID'])
        for resource in instance.domain_resource_list(
                                            domainid=domain['DOMAINID']):
            if resource['TYPE'] == 'AAAA' and \
               resource['TARGET'] == '2001:470:1f06:f41::2':
                print 'Old AAAA Record Found: %s.%s (%i)' % \
                    (resource['NAME'], domain['DOMAIN'],
                     resource['RESOURCEID'])
                newresid = instance.domain_resource_create(
                    domainid=domain['DOMAINID'],
                    type='AAAA',
                    name=resource['NAME'],
                    target='2001:470:1f07:f41::dead:beef')
                print '  Created resource %i' % newresid['ResourceID']
                oldresid = instance.domain_resource_delete(
                    domainid=domain['DOMAINID'],
                    resourceid=resource['RESOURCEID'])
                print '  Deleted resource %i' % oldresid['ResourceID']
            elif resource['TYPE'] == 'A' and \
                 resource['TARGET'] == '67.18.176.246':
                print 'Old A Record Found: %s.%s (%i)' % \
                    (resource['NAME'], domain['DOMAIN'],
                     resource['RESOURCEID'])
                newresid = instance.domain_resource_create(
                    domainid=domain['DOMAINID'],
                    type='A',
                    name=resource['NAME'],
                    target='97.107.134.213')
                print '  Created resource %i' % newresid['ResourceID']
                oldresid = instance.domain_resource_delete(
                    domainid=domain['DOMAINID'],
                    resourceid=resource['RESOURCEID'])
                print '  Deleted resource %i' % oldresid['ResourceID']


The key part is iterating over the domain_list, then over each record (domain_resource_list).

Obviously not an easy pointy-clicky way, but indeed, it is "some way." :-) And more flexible, especially for my most-recent change, which moved from one IPv6 address for all sites to one IPv6 address for each site.

(I'd share the script for that, but there was no script. My work-anticipator -- the part of the brain that optimizes for maximum laziness -- told me it'd be more work to write a script to do everything than it would be to just do it. My work-anticipator was a lying sack of shit.)

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
 Post subject:
PostPosted: Mon Jun 20, 2011 3:15 am 
Offline
Junior Member

Joined: Mon Jun 06, 2011 1:33 am
Posts: 40
hoopycat wrote:
As an example of how the API can be used to solve this for the programatically-inclined, here is a quick, one-off script I wrote shortly after the API was released. I used it to move "everything else" from an old Linode in Dallas to a new one in Newark:


Wow, cool! I don't have a need for this kind of thing right now, but I may have to move off Fremont, so this is awesome to know I can do something like this.

Thanks!
bruce


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group