2010-12-12 18:02:02 -05:00
|
|
|
module Fog
|
|
|
|
module Zerigo
|
2010-12-21 16:45:53 -05:00
|
|
|
class DNS
|
2010-12-12 18:02:02 -05:00
|
|
|
class Real
|
|
|
|
|
2011-01-07 19:12:04 -05:00
|
|
|
require 'fog/dns/parsers/zerigo/create_host'
|
2010-12-12 18:02:02 -05:00
|
|
|
|
2010-12-12 21:18:21 -05:00
|
|
|
# Create a new host in the specified zone
|
2010-12-12 18:02:02 -05:00
|
|
|
#
|
2010-12-12 21:18:21 -05:00
|
|
|
# ==== Parameters
|
|
|
|
# * zone_id<~Integer>
|
|
|
|
# * host_type<~String>
|
|
|
|
# * data<~String>
|
|
|
|
# * options<~Hash> - optional paramaters
|
|
|
|
# * 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
|
|
|
# * body<~Hash>
|
|
|
|
# * 'created-at'<~String>
|
|
|
|
# * 'data'<~String>
|
|
|
|
# * 'fqdn'<~String>
|
|
|
|
# * 'host-type'<~String>
|
|
|
|
# * 'hostname'<~String>
|
|
|
|
# * 'id'<~Integer>
|
|
|
|
# * 'notes'<~String>
|
|
|
|
# * 'priority'<~Integer>
|
|
|
|
# * 'ttl'<~Integer>
|
|
|
|
# * 'updated-at'<~String>
|
|
|
|
# * 'zone-id'<~String>
|
|
|
|
# * 'status'<~Integer> - 201 if successful
|
2010-12-22 23:36:53 -05:00
|
|
|
def create_host(zone_id, host_type, data, options = {})
|
2010-12-12 21:18:21 -05:00
|
|
|
|
|
|
|
optional_tags= ''
|
|
|
|
options.each { |option, value|
|
|
|
|
case option
|
|
|
|
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><host-type>#{host_type}</host-type><data>#{data}</data>#{optional_tags}</host>},
|
2010-12-13 08:51:04 -05:00
|
|
|
:expects => 201,
|
2010-12-12 18:02:02 -05:00
|
|
|
:method => 'POST',
|
2010-12-21 16:45:53 -05:00
|
|
|
:parser => Fog::Parsers::Zerigo::DNS::CreateHost.new,
|
2010-12-12 18:02:02 -05:00
|
|
|
:path => "/api/1.1/zones/#{zone_id}/hosts.xml"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|