1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[zerigo|dns] move compute to dns namespace

This commit is contained in:
geemus 2010-12-21 13:45:53 -08:00
parent bf9a56c57c
commit 8c5b57cf0e
29 changed files with 85 additions and 85 deletions

View file

@ -73,7 +73,7 @@ An alternate file may be used by placing its path in the FOG_RC environment vari
:terremark_username:
:terremark_password:
:zerigo_email:
:zerigo_password:
:zerigo_token:
#
# End of Fog Credentials File
#######################################################

View file

@ -9,7 +9,7 @@ module Fog
extend Fog::Provider
service_path 'fog/zerigo'
service :compute
service :dns
end
end

View file

@ -3,8 +3,8 @@ class Zerigo < Fog::Bin
def class_for(key)
case key
when :compute
Fog::Zerigo::Compute
when :dns
Fog::Zerigo::DNS
else
raise ArgumentError, "Unrecognized service: #{key}"
end
@ -18,7 +18,7 @@ class Zerigo < Fog::Bin
end
def services
[:compute]
[:dns]
end
end

View file

@ -1,15 +1,15 @@
module Fog
module Zerigo
class Compute < Fog::Service
class DNS < Fog::Service
requires :zerigo_email, :zerigo_password
requires :zerigo_email, :zerigo_token
recognizes :timeout, :persistent
# model_path 'fog/zerigo/models/compute'
# model_path 'fog/zerigo/models/dns'
# model :server
# collection :servers
request_path 'fog/zerigo/requests/compute'
request_path 'fog/zerigo/requests/dns'
request :list_zones
request :count_zones
request :get_zone
@ -41,7 +41,7 @@ module Fog
def initialize(options={})
@zerigo_email = options[:zerigo_email]
@zerigo_password = options[:zerigo_password]
@zerigo_token = options[:zerigo_token]
@data = self.class.data[@zerigo_email]
@data = self.class.data[@zerigo_password]
end
@ -52,7 +52,7 @@ module Fog
def initialize(options={})
@zerigo_email = options[:zerigo_email]
@zerigo_password = options[:zerigo_password]
@zerigo_token = options[:zerigo_token]
@host = options[:host] || "ns.zerigo.com"
@port = options[:port] || 80
@scheme = options[:scheme] || 'http'
@ -65,7 +65,7 @@ module Fog
def request(params)
params[:headers] ||= {}
key= "#{@zerigo_email}:#{@zerigo_password}"
key= "#{@zerigo_email}:#{@zerigo_token}"
params[:headers].merge!({
'Authorization' => "Basic #{Base64.encode64(key).delete("\r\n")}"
})
@ -81,7 +81,7 @@ module Fog
rescue Excon::Errors::HTTPStatusError => error
raise case error
when Excon::Errors::NotFound
Fog::Zerigo::Compute::NotFound.slurp(error)
Fog::Zerigo::DNS::NotFound.slurp(error)
else
error
end

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class CountHosts < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class CountZones < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class CreateHost < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class CreateZone < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class FindHosts < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class GetHost < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class GetZone < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class GetZoneStats < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class ListHosts < Fog::Parsers::Base

View file

@ -1,7 +1,7 @@
module Fog
module Parsers
module Zerigo
module Compute
module DNS
class ListZones < Fog::Parsers::Base

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/count_hosts'
require 'fog/zerigo/parsers/dns/count_hosts'
# total number of hosts available for the specified zone. It is the same value as provided
# in the X-Query-Count header in the list_hosts API method
@ -17,7 +17,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::CountHosts.new,
:parser => Fog::Parsers::Zerigo::DNS::CountHosts.new,
:path => "/api/1.1/zones/#{zone_id}/hosts/count.xml"
)
end

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/count_zones'
require 'fog/zerigo/parsers/dns/count_zones'
# Total number of zones hosted Zerigo for this account. It is the same value as provided
# in the X-Query-Count header in the list_zones API method
@ -17,7 +17,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::CountZones.new,
:parser => Fog::Parsers::Zerigo::DNS::CountZones.new,
:path => "/api/1.1/zones/count.xml"
)
end

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/create_host'
require 'fog/zerigo/parsers/dns/create_host'
# Create a new host in the specified zone
#
@ -51,7 +51,7 @@ module Fog
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><host><host-type>#{host_type}</host-type><data>#{data}</data>#{optional_tags}</host>},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::Zerigo::Compute::CreateHost.new,
:parser => Fog::Parsers::Zerigo::DNS::CreateHost.new,
:path => "/api/1.1/zones/#{zone_id}/hosts.xml"
)
end

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/create_zone'
require 'fog/zerigo/parsers/dns/create_zone'
# Create a new zone for Zerigo's DNS servers to serve/host
# ==== Parameters
@ -78,7 +78,7 @@ module Fog
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><domain>#{domain}</domain><default-ttl type="integer">#{default_ttl}</default-ttl><ns-type>#{ns_type}</ns-type>#{optional_tags}</zone>},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::Zerigo::Compute::CreateZone.new,
:parser => Fog::Parsers::Zerigo::DNS::CreateZone.new,
:path => '/api/1.1/zones.xml'
)
end

View file

@ -1,6 +1,6 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
# Delete a host record

View file

@ -1,6 +1,6 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
# Delete a zone from Zerigo

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/find_hosts'
require 'fog/zerigo/parsers/dns/find_hosts'
# Get list of all the host records that match the FQDN. If desired, can limit
# search to a specific zone
@ -35,7 +35,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::FindHosts.new,
:parser => Fog::Parsers::Zerigo::DNS::FindHosts.new,
:path => "/api/1.1/hosts.xml?fqdn=#{fqdn}"
)
else
@ -43,7 +43,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::FindHosts.new,
:parser => Fog::Parsers::Zerigo::DNS::FindHosts.new,
:path => "/api/1.1/zones/#{zone_id}/hosts.xml?fqdn=#{fqdn}"
)
end

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/get_host'
require 'fog/zerigo/parsers/dns/get_host'
# get details about a given host record
#
@ -28,7 +28,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::GetHost.new,
:parser => Fog::Parsers::Zerigo::DNS::GetHost.new,
:path => "/api/1.1/hosts/#{host_id}.xml"
)
end

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/get_zone'
require 'fog/zerigo/parsers/dns/get_zone'
# Get details of a DNS zone. The response is similar to list_zones, with the
# addition of hosts-count and possibly hosts.
@ -38,7 +38,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::GetZone.new,
:parser => Fog::Parsers::Zerigo::DNS::GetZone.new,
:path => "/api/1.1/zones/#{zone}.xml"
)
end

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/get_zone_stats'
require 'fog/zerigo/parsers/dns/get_zone_stats'
# returns current traffic statistics about this zone. Queries is measured from the
# beginning of the current period through the time of the API call.
@ -25,7 +25,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::GetZoneStats.new,
:parser => Fog::Parsers::Zerigo::DNS::GetZoneStats.new,
:path => "/api/1.1/zones/#{zone_id}/stats.xml"
)
end

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/list_hosts'
require 'fog/zerigo/parsers/dns/list_hosts'
# Get list of all DNS zones hosted on Slicehost (for this account)
#
@ -29,7 +29,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::ListHosts.new,
:parser => Fog::Parsers::Zerigo::DNS::ListHosts.new,
:path => "/api/1.1/zones/#{zone_id}/hosts.xml"
)
end

View file

@ -1,9 +1,9 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
require 'fog/zerigo/parsers/compute/list_zones'
require 'fog/zerigo/parsers/dns/list_zones'
# Get list of all DNS zones hosted on Slicehost (for this account)
#
@ -34,7 +34,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::ListZones.new,
:parser => Fog::Parsers::Zerigo::DNS::ListZones.new,
:path => '/api/1.1/zones.xml'
)
end

View file

@ -1,6 +1,6 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
# Update a host record

View file

@ -1,6 +1,6 @@
module Fog
module Zerigo
class Compute
class DNS
class Real
# Update the parameters of a zone

View file

@ -1,4 +1,4 @@
Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
Shindo.tests('Zerigo::dns | DNS requests', ['zerigo', 'dns']) do
# tests assume have a free acccount - ie need to limit # of zones to max of 3
@ -26,7 +26,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
pending if Fog.mocking?
@org_zone_count= 0
response = Zerigo[:compute].count_zones()
response = Zerigo[:dns].count_zones()
if response.status == 200
@org_zone_count = response.body['count']
end
@ -39,11 +39,11 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
options = { :nx_ttl => 1800 }
domain = generate_unique_domain
response = Zerigo[:compute].create_zone( domain, 3600, 'pri_sec', options)
response = Zerigo[:dns].create_zone( domain, 3600, 'pri_sec', options)
if response.status == 201
zone_id = response.body['id']
#worked so can now delete
response = Zerigo[:compute].delete_zone( zone_id)
response = Zerigo[:dns].delete_zone( zone_id)
end
response.status == 200
@ -54,11 +54,11 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
options = { :active => 'N', :ns1=> '2.3.4.5' }
domain= generate_unique_domain
response = Zerigo[:compute].create_zone( domain, 14400, 'sec', options )
response = Zerigo[:dns].create_zone( domain, 14400, 'sec', options )
if response.status == 201
zone_id = response.body['id']
#worked so can now delete
response = Zerigo[:compute].delete_zone( zone_id)
response = Zerigo[:dns].delete_zone( zone_id)
end
response.status == 200
@ -69,11 +69,11 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
domain= generate_unique_domain
options = { :active => 'N', :slave_nameservers=> "ns1.#{domain},ns2.#{domain}" }
response = Zerigo[:compute].create_zone( domain, 14400, 'pri', options )
response = Zerigo[:dns].create_zone( domain, 14400, 'pri', options )
if response.status == 201
zone_id = response.body['id']
#worked so can now delete
response = Zerigo[:compute].delete_zone( zone_id)
response = Zerigo[:dns].delete_zone( zone_id)
end
response.status == 200
@ -85,7 +85,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
@domain = generate_unique_domain
options = { :nx_ttl => 1800, :active => 'N', :hostmaster => "netops@#{@domain}",
:notes => 'for client ABC', :tag_list=> 'sample-tag' }
response = Zerigo[:compute].create_zone( @domain, 14400, 'pri', options )
response = Zerigo[:dns].create_zone( @domain, 14400, 'pri', options )
if response.status == 201
@zone_id = response.body['id']
@new_zones << @zone_id
@ -99,7 +99,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result= false
response = Zerigo[:compute].get_zone( @zone_id)
response = Zerigo[:dns].get_zone( @zone_id)
if response.status == 200
zone = response.body
if (zone['ns-type'] == 'pri') and (zone['tag-list'] == 'sample-tag') and
@ -118,7 +118,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
pending if Fog.mocking?
options = { :notes => 'for client XYZ', :tag_list=> 'testing-tag' }
response = Zerigo[:compute].update_zone( @zone_id, options )
response = Zerigo[:dns].update_zone( @zone_id, options )
response.status == 200
end
@ -128,7 +128,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result= false
response = Zerigo[:compute].get_zone( @zone_id)
response = Zerigo[:dns].get_zone( @zone_id)
if response.status == 200
zone = response.body
if (zone['tag-list'] == 'testing-tag') and (zone['notes'] == 'for client XYZ')
@ -144,7 +144,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result= false
response = Zerigo[:compute].get_zone_stats( @zone_id)
response = Zerigo[:dns].get_zone_stats( @zone_id)
if response.status == 200
zone = response.body
if (zone['domain'] == @domain) and (zone['id'] == @zone_id) and
@ -162,7 +162,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result= false
response = Zerigo[:compute].list_zones()
response = Zerigo[:dns].list_zones()
if response.status == 200
zones = response.body['zones']
if (@org_zone_count+1) == zones.count
@ -178,7 +178,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
host= 'www'
options = { :hostname => host }
response = Zerigo[:compute].create_host( @zone_id, 'A', '1.2.3.4', options)
response = Zerigo[:dns].create_host( @zone_id, 'A', '1.2.3.4', options)
if response.status == 201
record_id = response.body['id']
@new_records << record_id
@ -192,7 +192,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
host = 'mail'
options = { :hostname => host }
response = Zerigo[:compute].create_host( @zone_id, 'CNAME', @domain, options)
response = Zerigo[:dns].create_host( @zone_id, 'CNAME', @domain, options)
if response.status == 201
record_id = response.body['id']
@new_records << record_id
@ -210,7 +210,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
sub_domain = 'subdomain' # that we want to delete DNS for
ns_host = 'ns.' + @domain
options = { :hostname => sub_domain}
response = Zerigo[:compute].create_host( @zone_id, 'NS', ns_host, options)
response = Zerigo[:dns].create_host( @zone_id, 'NS', ns_host, options)
if response.status == 201
record_id = response.body['id']
@new_records << record_id
@ -224,7 +224,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
mail_domain = 'mail.' + @domain
options = { :hostname => @domain, :ttl => 3600, :priority => '3'}
response = Zerigo[:compute].create_host( @zone_id, 'MX', mail_domain, options)
response = Zerigo[:dns].create_host( @zone_id, 'MX', mail_domain, options)
if response.status == 201
@record_id = response.body['id']
@new_records << @record_id
@ -238,7 +238,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result = false
response = Zerigo[:compute].get_host( @record_id)
response = Zerigo[:dns].get_host( @record_id)
if response.status == 200
host = response.body
if (host['id'] == @record_id) and (host['host-type'] == 'MX') and
@ -256,9 +256,9 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result = false
options = { :priority => 7 }
response = Zerigo[:compute].update_host( @record_id, options)
response = Zerigo[:dns].update_host( @record_id, options)
if response.status == 200
response = Zerigo[:compute].get_host( @record_id)
response = Zerigo[:dns].get_host( @record_id)
if response.status == 200
host= response.body
if (host['priority'] == 7)
@ -274,7 +274,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
pending if Fog.mocking?
host_count = 0
response = Zerigo[:compute].count_hosts( @zone_id)
response = Zerigo[:dns].count_hosts( @zone_id)
if response.status == 200
host_count = response.body['count']
end
@ -287,7 +287,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result = false
response = Zerigo[:compute].list_hosts( @zone_id)
response = Zerigo[:dns].list_hosts( @zone_id)
if response.status == 200
hosts = response.body['hosts']
if (hosts.count == 4)
@ -309,7 +309,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result = false
host = 'mail.' + @domain
response = Zerigo[:compute].find_hosts( host)
response = Zerigo[:dns].find_hosts( host)
if response.status == 200
hosts = response.body['hosts']
host_count = hosts.count
@ -327,7 +327,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result = false
host = 'mail.' + @domain
response = Zerigo[:compute].find_hosts( host, @zone_id)
response = Zerigo[:dns].find_hosts( host, @zone_id)
if response.status == 200
hosts = response.body['hosts']
host_count = hosts.count
@ -344,7 +344,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result= true
@new_records.each { |record_id|
response = Zerigo[:compute].delete_host( record_id)
response = Zerigo[:dns].delete_host( record_id)
if response.status != 200
result= false;
end
@ -358,7 +358,7 @@ Shindo.tests('Zerigo::Compute | DNS requests', ['zerigo', 'dns']) do
result= true
@new_zones.each { |zone_id|
response = Zerigo[:compute].delete_zone( zone_id)
response = Zerigo[:dns].delete_zone( zone_id)
if response.status != 200
result= false;
end