Revision 4761cd13
Added by Marc Dequènes almost 14 years ago
- ID 4761cd134c36a40c0240698f7440ba4b693c1b32
bin/mapmaker | ||
---|---|---|
def setup
|
||
super
|
||
|
||
define_interface "0.1~" do
|
||
node "DNS" do
|
||
dns = Services::DNS::System.new
|
||
on_request do |request|
|
||
request.reply.results = {
|
||
:type => dns.type
|
||
}
|
||
end
|
||
node "check_config" do
|
||
on_request do |request|
|
||
request.reply.results = dns.check_config
|
||
end
|
||
end
|
||
node "Zones" do
|
||
zone_list = Proc.new{dns.zones}
|
||
node zone_list do
|
||
zone = Services::DNS::Zone.new(node_name)
|
||
on_request do |request|
|
||
request.reply.results = {
|
||
:master => zone.master?,
|
||
:signed => zone.signed?,
|
||
:serial => zone.serial_in_dns
|
||
}
|
||
if zone.master?
|
||
request.reply.results.merge!({
|
||
:serial_in_zone_file => zone.serial_in_zone_file,
|
||
:serial_in_signed_zone_file => zone.serial_in_signed_zone_file
|
||
})
|
||
end
|
||
end
|
||
node "content" do
|
||
on_request do |request|
|
||
request.reply.results = {:content => zone.content}
|
||
end
|
||
end
|
||
node "content=" do
|
||
on_request do |request|
|
||
content = request.args.shift
|
||
if content.empty?
|
||
request.errors << "Zone content missing"
|
||
return
|
||
end
|
||
|
||
zone.content = content
|
||
if zone.changed?
|
||
check_result = zone.check
|
||
if check_result[:ok]
|
||
request.reply.warnings = check_result[:warnings]
|
||
# zone signer automatically handles serial bump
|
||
if check_result[:serial] > zone.serial or zone.signed?
|
||
zone.save
|
||
zone.activate
|
||
else
|
||
request.reply.errors << _("Zone serial is not superior to current serial.")
|
||
end
|
||
else
|
||
request.reply.errors = check_result[:errors]
|
||
zone.cancel_changes
|
||
end
|
||
else
|
||
request.reply.warnings << _("Zone is unmodified (same content)")
|
||
zone.cancel_changes
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end # interface
|
||
define_interface "0.1~"
|
||
end
|
||
end # class MapMaker
|
||
end
|
Also available in: Unified diff
[evol] allow splitting the API interface declaration over multiple files/directories, split MapMaker interface, and added cross-nodes storage during the interface life (as we can't use closures across files)