CommonThread

Displaying articles with tag

Slicehost API Saves The Day

Posted by ben, Tue May 20 22:25:00 UTC 2008

Thanks to slicehost for giving me an API for managing my DNS zones and records via ActiveResource becauase it saved me lots of time and tedious work. I needed to update my TTL settings in all my domains and rather than having to edit all 61 entries I simply made a ruby script to do it for me:

require 'rubygems'
require 'activeresource'

API_PASSWORD = "MY_SECRET_PASSWORD" 
DEFAULT_TTL = 86400

class Record < ActiveResource::Base
  self.site = "https://#{API_PASSWORD}@api.slicehost.com/" 
end

records = Record.find(:all)

for record in records
  record.ttl = DEFAULT_TTL
  record.save
end

and while we are at it lets output all of our info:

require 'rubygems'
require 'activeresource'

API_PASSWORD = "MY_SECRET_PASSWORD" 

class Zone < ActiveResource::Base
  self.site = "https://#{API_PASSWORD}@api.slicehost.com/" 
end

class Record < ActiveResource::Base
  self.site = "https://#{API_PASSWORD}@api.slicehost.com/" 
end

zones = Zone.find(:all)
records = Record.find(:all)

for zone in zones
  puts "zone: #{zone.origin}" 

  for record in records.find_all{|record| record.zone_id == zone.id}
    puts "  #{record.record_type}: #{record.name} - #{record.data}" 
  end
end

There, that was easy.

1 comment | Filed Under: | Tags:

Slice It Up

Posted by ben, Fri Jun 01 00:33:00 UTC 2007

Well the time on shared hosting is over. My dreamhost account officially expires June 3rd and I am frantically trying to get all of my stuff off of the server before I get sucked into paying for anymore because I didn’t get it off in time. We are officially moving all of our applications to slicehost. They have provided us with great service so far … lets hope they keep that up ;)

0 comments | Filed Under: | Tags:

Categories