2010-12-12 18:02:02 -05:00
|
|
|
module Fog
|
2011-06-15 20:25:01 -04:00
|
|
|
module DNS
|
|
|
|
class Zerigo
|
2010-12-12 18:02:02 -05:00
|
|
|
class Real
|
|
|
|
|
2010-12-12 21:18:21 -05:00
|
|
|
# Update a host record
|
2010-12-12 18:02:02 -05:00
|
|
|
#
|
2010-12-12 21:18:21 -05:00
|
|
|
# ==== Parameters
|
|
|
|
# * host_id<~Integer> - host ID of the record to update
|
|
|
|
# * options<~Hash> - optional paramaters
|
|
|
|
# * host_type<~String>
|
|
|
|
# * data<~String>
|
|
|
|
# * hostname<~String> - Note: normally this is set/required!!
|
|
|
|
# * notes<~String>
|
|
|
|
# * priority<~Integer> - Note: required for MX or SRV records
|
|
|
|
# * ttl<~Integer>
|
2010-12-12 18:02:02 -05:00
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
2010-12-13 08:51:04 -05:00
|
|
|
# * 'status'<~Integer> - 200 for success
|
2010-12-12 21:18:21 -05:00
|
|
|
#
|
2011-10-08 20:19:32 -04:00
|
|
|
def update_host(host_id, options = {})
|
2010-12-12 21:18:21 -05:00
|
|
|
|
|
|
|
optional_tags= ''
|
|
|
|
options.each { |option, value|
|
|
|
|
case option
|
|
|
|
when :host_type
|
2011-12-22 15:38:08 -05:00
|
|
|
optional_tags+= "<host-type>#{value}</host-type>"
|
2010-12-12 21:18:21 -05:00
|
|
|
when :data
|
2011-12-22 15:38:08 -05:00
|
|
|
optional_tags+= "<data>#{value}</data>"
|
2010-12-12 21:18:21 -05:00
|
|
|
when :hostname
|
|
|
|
optional_tags+= "<hostname>#{value}</hostname>"
|
|
|
|
when :notes
|
|
|
|
optional_tags+= "<notes>#{value}</notes>"
|
|
|
|
when :priority
|
|
|
|
optional_tags+= "<priority>#{value}</priority>"
|
|
|
|
when :ttl
|
|
|
|
optional_tags+= "<ttl>#{value}</ttl>"
|
|
|
|
end
|
2010-12-13 07:38:06 -05:00
|
|
|
}
|
2010-12-12 21:18:21 -05:00
|
|
|
|
2010-12-12 18:02:02 -05:00
|
|
|
request(
|
2010-12-12 21:18:21 -05:00
|
|
|
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><host>#{optional_tags}</host>},
|
2010-12-12 18:02:02 -05:00
|
|
|
:expects => 200,
|
|
|
|
:method => 'PUT',
|
|
|
|
:path => "/api/1.1/hosts/#{host_id}.xml"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2011-10-08 20:19:32 -04:00
|
|
|
|
|
|
|
class Mock # :nodoc:all
|
|
|
|
def update_host(host_id, options = {})
|
|
|
|
host = find_host(host_id)
|
|
|
|
|
|
|
|
response = Excon::Response.new
|
|
|
|
|
|
|
|
if host
|
|
|
|
options.each { |k, v| host[k.to_s] = v } # Deal with symbols in requests but strings in responses.
|
|
|
|
host['updated-at'] = Time.now
|
|
|
|
|
|
|
|
response.status = 200
|
|
|
|
else
|
|
|
|
response.status = 404
|
|
|
|
end
|
|
|
|
|
|
|
|
response
|
|
|
|
end
|
|
|
|
end
|
2010-12-12 18:02:02 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|