|
|
|
@ -205,19 +205,23 @@ class DNSManager::Storage
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# TODO: verify that this rr.rrid isn't ReadOnly.
|
|
|
|
|
stored_rr = zone.resources.select { |x| x.rrid == rr.rrid }
|
|
|
|
|
unless stored_rr.size > 0
|
|
|
|
|
stored_rrs = zone.resources.select { |x| x.rrid == rr.rrid }
|
|
|
|
|
unless stored_rrs.size > 0
|
|
|
|
|
Baguette::Log.warning "modifying a RR that doesn't exist (#{rr.rrid}) in domain #{domain}"
|
|
|
|
|
return Response::RRNotFound.new
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Verify that this resource isn't ReadOnly.
|
|
|
|
|
stored_rrs.each do |stored_rr|
|
|
|
|
|
return Response::RRReadOnly.new domain, rr if stored_rr.readonly
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
zone.resources = zone.resources.map { |x| x.rrid == rr.rrid ? rr : x }
|
|
|
|
|
|
|
|
|
|
# Update the zone.
|
|
|
|
|
zones_by_domain.update_or_create zone.domain, zone
|
|
|
|
|
|
|
|
|
|
Response::Success.new
|
|
|
|
|
Response::RRUpdated.new domain, rr
|
|
|
|
|
rescue e
|
|
|
|
|
Baguette::Log.error "trying to replace a resource record in domain #{domain}: #{e}"
|
|
|
|
|
Response::Error.new "error while replacing a resource record in domain #{domain}"
|
|
|
|
|