Open jeffreymcmanus opened 12 years ago
in an irb session can you see what linode's api is printing out via
require 'rubygems'
require 'linode'
l = Linode.new(:api_key => "YOUR KEY HERE")
l.domain.list # This will print the open structs
l.domain.list.each { |domain| puts domain.domain } # to get list of just domains at Linode
Also see what Slicehost's API is pushing out via
#!/usr/bin/env ruby
require 'rubygems'
require 'active_resource'
require 'linode'
SLICEHOST_API_KEY = "SLICEHOST API KEY"
class Zone < ActiveResource::Base
self.site = "https://#{SLICEHOST_API_KEY}@api.slicehost.com"
def records
Record.find(:all, :params => { :zone_id => self.id })
end
def self.exists?(name)
!Zone.find(:all, :params => { :origin => name}).empty?
end
def self.find_by_name(name)
Zone.find(:first, :params => { :origin => name })
end
def domain
origin.sub(/\.$/,'')
end
end
class Record < ActiveResource::Base
self.site = "https://#{SLICEHOST_API_KEY}@api.slicehost.com"
def kind
record_type.downcase
end
[:a,:mx,:cname,:srv,:ns,:txt].each do |kind|
define_method "#{kind}?" do
self.kind == "#{kind}"
end
end
# This is to cleanup slicehost data that ends with '.'
def data
attributes['data'].end_with?('.') && !self.ns? ? attributes['data'].sub(/\.$/,'') : attributes['data']
end
end
zone = Zone.find_by_name("domain.com.") # Change domain.com.
puts zone.domain
zone.records.each do |record|
puts "Name: #{record.name} Type: #{record.record_type}"
end
Because the script is only calling Slicehost's API to get the zones based on name and then what ever Linode's API is returning. Not sure of the second Slicehost script as i don't have access to Slicehost anymore for testing.
I've got about a dozen Slicehost zones I need to migrate. When I first ran the script I directed it to import the third or fourth zone in my list. Instead it imported the first zone in the list, and then when I attempted to import a different zone, I got the message ".com. already exists at linode please delete". But Linode's DNS manager does not have a record for that domain.