mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
finished testing Linode DNS support.
updated example code to show all major functions fixes a few small bugs
This commit is contained in:
parent
8b7eac7d62
commit
f09fa8b442
4 changed files with 36 additions and 11 deletions
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
# require 'fog'
|
require 'fog'
|
||||||
require '/Users/anuaimi/code/fog/lib/fog'
|
|
||||||
|
|
||||||
LINODE_API_KEY = '--put-your-key-here--'
|
LINODE_API_KEY = '--put-your-key-here--'
|
||||||
SLICEHOST_PASSWORD = '--put-your-key-here--'
|
SLICEHOST_PASSWORD = '--put-your-key-here--'
|
||||||
|
@ -16,6 +15,7 @@ def show_linode_dns_usage( api_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
#connect to Linode
|
#connect to Linode
|
||||||
options = { :linode_api_key => api_key }
|
options = { :linode_api_key => api_key }
|
||||||
cloud= Fog::Linode::Compute.new( options)
|
cloud= Fog::Linode::Compute.new( options)
|
||||||
|
@ -26,7 +26,7 @@ def show_linode_dns_usage( api_key)
|
||||||
options = { :SOA_email => 'netops@sample-domain.com', :description => "Sample-Domain Inc", :status => 0}
|
options = { :SOA_email => 'netops@sample-domain.com', :description => "Sample-Domain Inc", :status => 0}
|
||||||
response = cloud.domain_create( domain, type, options)
|
response = cloud.domain_create( domain, type, options)
|
||||||
if response.status == 200
|
if response.status == 200
|
||||||
master_zone_id = response.body['DATA']['DOMAINID']
|
master_zone_id = response.body['DATA']['DomainID']
|
||||||
end
|
end
|
||||||
|
|
||||||
#create a slave zone
|
#create a slave zone
|
||||||
|
@ -35,11 +35,9 @@ def show_linode_dns_usage( api_key)
|
||||||
options = { :master_ips => '1.2.3.4; 1.2.3.5'}
|
options = { :master_ips => '1.2.3.4; 1.2.3.5'}
|
||||||
response = cloud.domain_create( domain, type, options)
|
response = cloud.domain_create( domain, type, options)
|
||||||
if response.status == 200
|
if response.status == 200
|
||||||
slave_zone_id = response.body['DATA']['DOMAINID']
|
slave_zone_id = response.body['DATA']['DomainID']
|
||||||
end
|
end
|
||||||
|
|
||||||
#add an A record for website
|
|
||||||
|
|
||||||
#get a list of zones Linode hosted for account
|
#get a list of zones Linode hosted for account
|
||||||
response = cloud.domain_list()
|
response = cloud.domain_list()
|
||||||
if response.status == 200
|
if response.status == 200
|
||||||
|
@ -47,6 +45,33 @@ def show_linode_dns_usage( api_key)
|
||||||
puts "Linode is hosting #{num_zones} DNS zones for this account"
|
puts "Linode is hosting #{num_zones} DNS zones for this account"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#add an A and a MX record
|
||||||
|
options = { :name => 'www.sample-domain.com', :target => '4.5.6.7', :ttl_sec => 7200 }
|
||||||
|
response = cloud.domain_resource_create( master_zone_id, 'A', options)
|
||||||
|
if response.status == 200
|
||||||
|
resource_id = response.body['DATA']['ResourceID']
|
||||||
|
end
|
||||||
|
|
||||||
|
options = { :target => 'mail.sample-domain.com', :priority => 1 }
|
||||||
|
response = cloud.domain_resource_create( master_zone_id, 'MX', options)
|
||||||
|
if response.status == 200
|
||||||
|
resource_id = response.body['DATA']['ResourceID']
|
||||||
|
end
|
||||||
|
|
||||||
|
#change MX to have a lower priority
|
||||||
|
options = { :priority => 5 }
|
||||||
|
response = cloud.domain_resource_update( master_zone_id, resource_id, options)
|
||||||
|
if response.status == 200
|
||||||
|
resource_id = response.body['DATA']['ResourceID']
|
||||||
|
end
|
||||||
|
|
||||||
|
#get the list of resource records for the domain
|
||||||
|
response = cloud.domain_resource_list( master_zone_id)
|
||||||
|
if response.status == 200
|
||||||
|
num_records = response.body['DATA'].count
|
||||||
|
puts "Domain has #{num_records} records for this domain"
|
||||||
|
end
|
||||||
|
|
||||||
#finally cleanup by deleting the zone we created
|
#finally cleanup by deleting the zone we created
|
||||||
response = cloud.domain_delete( master_zone_id)
|
response = cloud.domain_delete( master_zone_id)
|
||||||
if response.status == 200
|
if response.status == 200
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Fog
|
||||||
request :domain_resource_create
|
request :domain_resource_create
|
||||||
request :domain_resource_delete
|
request :domain_resource_delete
|
||||||
request :domain_resource_list
|
request :domain_resource_list
|
||||||
# request :domain_resource_update
|
request :domain_resource_update
|
||||||
# request :linode_boot
|
# request :linode_boot
|
||||||
request :linode_create
|
request :linode_create
|
||||||
request :linode_delete
|
request :linode_delete
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Fog
|
||||||
# * port<~Integer>: default: 80
|
# * port<~Integer>: default: 80
|
||||||
# * protocol<~String>: The protocol to append to an SRV record. Ignored on other record
|
# * protocol<~String>: The protocol to append to an SRV record. Ignored on other record
|
||||||
# types. default: udp
|
# types. default: udp
|
||||||
# * ttl_sec<~Integer>: default: 0
|
# * ttl_sec<~Integer>: note, Linode will round the input to set values (300, 3600, 7200, etc)
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# * response<~Excon::Response>:
|
# * response<~Excon::Response>:
|
||||||
# * body<~Hash>:
|
# * body<~Hash>:
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Fog
|
||||||
# * port<~Integer>: default: 80
|
# * port<~Integer>: default: 80
|
||||||
# * protocol<~String>: The protocol to append to an SRV record. Ignored on other record
|
# * protocol<~String>: The protocol to append to an SRV record. Ignored on other record
|
||||||
# types. default: udp
|
# types. default: udp
|
||||||
# * ttl_sec<~Integer>: default: 0
|
# * ttl_sec<~Integer>: note, Linode will round the input to set values (300, 3600, 7200, etc)
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# * response<~Excon::Response>:
|
# * response<~Excon::Response>:
|
||||||
# * body<~Hash>:
|
# * body<~Hash>:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue