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:
parent
df44afd837
commit
65e6c49757
9 changed files with 14 additions and 40 deletions
|
@ -64,7 +64,6 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def request(params)
|
def request(params)
|
||||||
key= "#{@zerigo_user}:#{@zerigo_password}"
|
|
||||||
params[:headers] ||= {}
|
params[:headers] ||= {}
|
||||||
key= "#{@zerigo_user}:#{@zerigo_password}"
|
key= "#{@zerigo_user}:#{@zerigo_password}"
|
||||||
params[:headers].merge!({
|
params[:headers].merge!({
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Fog
|
||||||
|
|
||||||
def reset
|
def reset
|
||||||
@host = {}
|
@host = {}
|
||||||
@hosts = {}
|
@hosts = []
|
||||||
@response = {}
|
@response = {}
|
||||||
@in_hosts = false
|
@in_hosts = false
|
||||||
end
|
end
|
||||||
|
@ -33,7 +33,7 @@ module Fog
|
||||||
@hosts << @host
|
@hosts << @host
|
||||||
@host = {}
|
@host = {}
|
||||||
when 'hosts'
|
when 'hosts'
|
||||||
@response[name] << @hosts
|
@response[name] = @hosts
|
||||||
@in_hosts = false
|
@in_hosts = false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -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
|
|
|
@ -10,6 +10,7 @@ module Fog
|
||||||
#
|
#
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# * response<~Excon::Response>:
|
# * response<~Excon::Response>:
|
||||||
|
# * body<~Hash>
|
||||||
# * 'count'<~Integer>
|
# * 'count'<~Integer>
|
||||||
def count_zones()
|
def count_zones()
|
||||||
request(
|
request(
|
||||||
|
|
|
@ -43,6 +43,7 @@ module Fog
|
||||||
when :ttl
|
when :ttl
|
||||||
optional_tags+= "<ttl>#{value}</ttl>"
|
optional_tags+= "<ttl>#{value}</ttl>"
|
||||||
end
|
end
|
||||||
|
}
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><host><host-type>#{host_type}</host-type><data>#{data}</data>#{optional_tags}</host>},
|
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><host><host-type>#{host_type}</host-type><data>#{data}</data>#{optional_tags}</host>},
|
||||||
|
|
|
@ -26,8 +26,8 @@ module Fog
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# * response<~Excon::Response>:
|
# * response<~Excon::Response>:
|
||||||
# * body<~Hash>:
|
# * body<~Hash>:
|
||||||
|
# * 'id'<~Integer> - zone ID to use for future calls
|
||||||
# * 'default-ttl'<~Integer>
|
# * 'default-ttl'<~Integer>
|
||||||
# * 'id'<~Integer>
|
|
||||||
# * 'nx-ttl'<~Integer>
|
# * 'nx-ttl'<~Integer>
|
||||||
# * 'hosts-count'<~Integer>
|
# * 'hosts-count'<~Integer>
|
||||||
# * 'created-at'<~String>
|
# * '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>},
|
: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,
|
:expects => 201,
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:parser => Fog::Parsers::Slicehost::Compute::CreateZone.new,
|
:parser => Fog::Parsers::Zerigo::Compute::CreateZone.new,
|
||||||
:path => '/api/1.1/zones.xml'
|
:path => '/api/1.1/zones.xml'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:parser => Fog::Parsers::Zerigo::Compute::GetZoneStats.new,
|
: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
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ module Fog
|
||||||
when :ttl
|
when :ttl
|
||||||
optional_tags+= "<ttl>#{value}</ttl>"
|
optional_tags+= "<ttl>#{value}</ttl>"
|
||||||
end
|
end
|
||||||
|
}
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><host>#{optional_tags}</host>},
|
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><host>#{optional_tags}</host>},
|
||||||
|
|
|
@ -3,8 +3,6 @@ module Fog
|
||||||
class Compute
|
class Compute
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
require 'fog/zerigo/parsers/compute/update_zone'
|
|
||||||
|
|
||||||
# Update the parameters of a zone
|
# Update the parameters of a zone
|
||||||
# ==== Parameters
|
# ==== Parameters
|
||||||
#
|
#
|
||||||
|
@ -25,7 +23,8 @@ module Fog
|
||||||
#
|
#
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# * response<~Excon::Response>:
|
# * response<~Excon::Response>:
|
||||||
# * body<~Hash>:
|
# * header<~Hash>
|
||||||
|
# * 'status'<~Integer> - 200 for success
|
||||||
#
|
#
|
||||||
def update_zone( zone_id, options = {})
|
def update_zone( zone_id, options = {})
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ module Fog
|
||||||
when :axfr_ips
|
when :axfr_ips
|
||||||
optional_tags+= "<axfr-ips>#{value}</axfr-ips>"
|
optional_tags+= "<axfr-ips>#{value}</axfr-ips>"
|
||||||
when :custom_nameservers
|
when :custom_nameservers
|
||||||
optional_tags+= "<custom_nameservers>#{value}</custom-nameservers>"
|
optional_tags+= "<custom-nameservers>#{value}</custom-nameservers>"
|
||||||
when :custom_ns
|
when :custom_ns
|
||||||
optional_tags+= "<custom-ns>#{value}</custom-ns>"
|
optional_tags+= "<custom-ns>#{value}</custom-ns>"
|
||||||
when :hostmaster
|
when :hostmaster
|
||||||
|
@ -60,10 +59,9 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
request(
|
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,
|
:expects => 200,
|
||||||
:method => 'PUT',
|
:method => 'PUT',
|
||||||
:parser => Fog::Parsers::Slicehost::Compute::UpdateZone.new,
|
|
||||||
:path => "/api/1.1/zones/#{zone_id}.xml"
|
:path => "/api/1.1/zones/#{zone_id}.xml"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue