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

Support freeze and thaw.

This commit is contained in:
Dylan Egan 2011-08-30 09:58:26 -07:00
parent 18c672f194
commit 3900846820
2 changed files with 45 additions and 22 deletions

View file

@ -31,36 +31,43 @@ module Fog
response = Excon::Response.new
response.status = 200
if options[:freeze]
zone[:frozen] = true
elsif options[:publish]
data = {}
if options['freeze']
zone['frozen'] = true
info = "freeze: Your zone is now frozen"
elsif options['publish']
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] = []
response.body = {
"status" => "success",
"data" => {
"zone_type" => zone[:zone_type],
"serial_style" => zone[:serial_style],
"serial" => zone[:serial] += 1,
"zone" => zone[:zone]
},
"job_id" => Fog::Dynect::Mock.job_id,
"msgs" => [{
"INFO" => "publish: #{zone[:zone]} published",
"SOURCE"=>"BLL",
"ERR_CD"=>nil,
"LVL"=>"INFO"
}]
data = {
"zone_type" => zone[:zone_type],
"serial_style" => zone[:serial_style],
"serial" => zone[:serial] += 1,
"zone" => zone[:zone]
}
elsif options[:thaw]
info = "publish: #{zone[:zone]} published"
elsif options['thaw']
zone[:frozen] = false
info = "thaw: Your zone is now thawed, you may edit normally"
else
raise ArgumentError
end
response.body = {
"status" => "success",
"data" => data,
"job_id" => Fog::Dynect::Mock.job_id,
"msgs" => [{
"INFO" => info,
"SOURCE"=>"BLL",
"ERR_CD"=>nil,
"LVL"=>"INFO"
}]
}
response
end
end

View file

@ -79,7 +79,7 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
@dns.post_record('A', @domain, @fqdn, {'address' => '1.2.3.4'}, {}).body
end
put_zone_format = shared_format.merge({
publish_zone_format = shared_format.merge({
'data' => {
'serial' => Integer,
'serial_style' => String,
@ -88,8 +88,24 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
}
})
tests("put_zone('#{@domain}', :publish => true)").formats(put_zone_format) do
@dns.put_zone(@domain, :publish => true).body
tests("put_zone('#{@domain}', 'publish' => true)").formats(publish_zone_format) do
@dns.put_zone(@domain, 'publish' => true).body
end
freeze_zone_format = shared_format.merge({
'data' => {}
})
tests("put_zone('#{@domain}', 'freeze' => true)").formats(freeze_zone_format) do
@dns.put_zone(@domain, 'freeze' => true).body
end
thaw_zone_format = shared_format.merge({
'data' => {}
})
tests("put_zone('#{@domain}', 'thaw' => true)").formats(thaw_zone_format) do
@dns.put_zone(@domain, 'thaw' => true).body
end
get_node_list_format = shared_format.merge({