2011-07-14 20:22:43 -04:00
|
|
|
module Fog
|
|
|
|
module DNS
|
|
|
|
class Dynect
|
|
|
|
class Real
|
|
|
|
|
|
|
|
# Update a zone
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * zone<~String> - name or id of zone
|
|
|
|
# * options<~Hash>:
|
|
|
|
# * freeze<~Boolean> - causes zone to become frozen
|
|
|
|
# * publish<~Boolean> - causes all pending changes to be pushed to nameservers
|
|
|
|
# * thaw<~Boolean> - causes zone to cease being frozen
|
|
|
|
|
|
|
|
def put_zone(zone, options = {})
|
|
|
|
request(
|
2012-04-25 10:31:28 -04:00
|
|
|
:body => Fog::JSON.encode(options),
|
2011-07-14 20:22:43 -04:00
|
|
|
:expects => 200,
|
|
|
|
:method => :put,
|
|
|
|
:path => 'Zone/' << zone
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2011-08-29 19:04:13 -04:00
|
|
|
|
|
|
|
class Mock
|
|
|
|
def put_zone(zone, options = {})
|
2011-09-01 18:03:36 -04:00
|
|
|
raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]
|
2011-08-29 19:04:13 -04:00
|
|
|
|
|
|
|
raise ArgumentError unless options.size == 1
|
|
|
|
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 200
|
|
|
|
|
2011-08-30 12:58:26 -04:00
|
|
|
data = {}
|
|
|
|
|
|
|
|
if options['freeze']
|
|
|
|
zone['frozen'] = true
|
|
|
|
info = "freeze: Your zone is now frozen"
|
|
|
|
elsif options['publish']
|
2011-08-29 19:04:13 -04:00
|
|
|
zone[:changes] = {}
|
|
|
|
zone[:records_to_delete].each do |record|
|
|
|
|
zone[:records][record[:type]].delete_if { |r| r[:fqdn] == record[:fqdn] && r[:record_id] == record[:record_id] }
|
|
|
|
end
|
|
|
|
zone[:records_to_delete] = []
|
2011-08-30 12:58:26 -04:00
|
|
|
data = {
|
|
|
|
"zone_type" => zone[:zone_type],
|
|
|
|
"serial_style" => zone[:serial_style],
|
|
|
|
"serial" => zone[:serial] += 1,
|
|
|
|
"zone" => zone[:zone]
|
2011-08-29 19:04:13 -04:00
|
|
|
}
|
2011-08-30 12:58:26 -04:00
|
|
|
info = "publish: #{zone[:zone]} published"
|
|
|
|
elsif options['thaw']
|
2011-08-29 19:04:13 -04:00
|
|
|
zone[:frozen] = false
|
2011-08-30 12:58:26 -04:00
|
|
|
info = "thaw: Your zone is now thawed, you may edit normally"
|
2011-08-29 19:04:13 -04:00
|
|
|
else
|
|
|
|
raise ArgumentError
|
|
|
|
end
|
|
|
|
|
2011-08-30 12:58:26 -04:00
|
|
|
response.body = {
|
|
|
|
"status" => "success",
|
|
|
|
"data" => data,
|
|
|
|
"job_id" => Fog::Dynect::Mock.job_id,
|
|
|
|
"msgs" => [{
|
|
|
|
"INFO" => info,
|
|
|
|
"SOURCE"=>"BLL",
|
|
|
|
"ERR_CD"=>nil,
|
|
|
|
"LVL"=>"INFO"
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
2011-08-29 19:04:13 -04:00
|
|
|
response
|
|
|
|
end
|
|
|
|
end
|
2011-07-14 20:22:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|