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

Zerigo DNS methods to manage zones fully debugged and commented

This commit is contained in:
Athir Nuaimi 2010-12-13 07:38:06 -05:00
parent df44afd837
commit 65e6c49757
9 changed files with 14 additions and 40 deletions

View file

@ -64,7 +64,6 @@ module Fog
end
def request(params)
key= "#{@zerigo_user}:#{@zerigo_password}"
params[:headers] ||= {}
key= "#{@zerigo_user}:#{@zerigo_password}"
params[:headers].merge!({

View file

@ -7,7 +7,7 @@ module Fog
def reset
@host = {}
@hosts = {}
@hosts = []
@response = {}
@in_hosts = false
end
@ -33,7 +33,7 @@ module Fog
@hosts << @host
@host = {}
when 'hosts'
@response[name] << @hosts
@response[name] = @hosts
@in_hosts = false
end
else

View file

@ -1,26 +0,0 @@
module Fog
module Parsers
module Zerigo
module Compute
class UpdateZone < Fog::Parsers::Base
def reset
@response = {}
end
def end_element(name)
case name
when 'default-ttl', 'id', 'nx-ttl', 'hosts-count'
@response[name] = @value.to_i
when 'created-at', 'custom-nameservers', 'custom-ns', 'domain', 'hostmaster', 'notes', 'ns1', 'ns-type', 'slave-nameservers', 'tag-list', 'updated-at', 'hosts', 'axfr-ips', 'restrict-axfr'
@response[name] = @value
end
end
end
end
end
end
end

View file

@ -10,7 +10,8 @@ module Fog
#
# ==== Returns
# * response<~Excon::Response>:
# * 'count'<~Integer>
# * body<~Hash>
# * 'count'<~Integer>
def count_zones()
request(
:expects => 200,

View file

@ -29,7 +29,7 @@ module Fog
# * 'ttl'<~Integer>
# * 'updated-at'<~String>
# * 'zone-id'<~String>
def create_host( zone_id, host_type, data, options = {})
def create_host( zone_id, host_type, data, options = {} )
optional_tags= ''
options.each { |option, value|
@ -43,6 +43,7 @@ module Fog
when :ttl
optional_tags+= "<ttl>#{value}</ttl>"
end
}
request(
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><host><host-type>#{host_type}</host-type><data>#{data}</data>#{optional_tags}</host>},

View file

@ -26,8 +26,8 @@ module Fog
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'id'<~Integer> - zone ID to use for future calls
# * 'default-ttl'<~Integer>
# * 'id'<~Integer>
# * 'nx-ttl'<~Integer>
# * 'hosts-count'<~Integer>
# * 'created-at'<~String>
@ -76,7 +76,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::Slicehost::Compute::CreateZone.new,
:parser => Fog::Parsers::Zerigo::Compute::CreateZone.new,
:path => '/api/1.1/zones.xml'
)
end

View file

@ -24,7 +24,7 @@ module Fog
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::Compute::GetZoneStats.new,
:path => "/api/1.1/zones/#{zone}/stats.xml"
:path => "/api/1.1/zones/#{zone_id}/stats.xml"
)
end

View file

@ -37,6 +37,7 @@ module Fog
when :ttl
optional_tags+= "<ttl>#{value}</ttl>"
end
}
request(
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><host>#{optional_tags}</host>},

View file

@ -3,8 +3,6 @@ module Fog
class Compute
class Real
require 'fog/zerigo/parsers/compute/update_zone'
# Update the parameters of a zone
# ==== Parameters
#
@ -25,7 +23,8 @@ module Fog
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * header<~Hash>
# * 'status'<~Integer> - 200 for success
#
def update_zone( zone_id, options = {})
@ -45,7 +44,7 @@ module Fog
when :axfr_ips
optional_tags+= "<axfr-ips>#{value}</axfr-ips>"
when :custom_nameservers
optional_tags+= "<custom_nameservers>#{value}</custom-nameservers>"
optional_tags+= "<custom-nameservers>#{value}</custom-nameservers>"
when :custom_ns
optional_tags+= "<custom-ns>#{value}</custom-ns>"
when :hostmaster
@ -60,10 +59,9 @@ module Fog
}
request(
: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>},
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone>#{optional_tags}</zone>},
:expects => 200,
:method => 'PUT',
:parser => Fog::Parsers::Slicehost::Compute::UpdateZone.new,
:path => "/api/1.1/zones/#{zone_id}.xml"
)
end