Improved record deletion performance

Up to now when selecting multiple resource records for deletion for each of
them a single message has been sent to the DNS server. This commit changes the
behavior to put all requested deletions into a single message, which improves
performance.
This commit is contained in:
Daniel Roschka 2015-03-25 22:48:47 +01:00
parent 7073cbbf8d
commit 24e6b7e399
4 changed files with 13 additions and 13 deletions

View File

@ -80,7 +80,7 @@ def add_cname_record(dns_server, zone_name, cname, originating_record, ttl, key_
return [{ "description" : "CNAME %s.%s points to %s" % (cname, zone_name, originating_record),
"output" : output}]
def delete_record(dns_server, rr_list, key_name):
def delete_record(dns_server, zone_name, rr_list, key_name):
"""Delete a list of DNS records passed as strings in rr_items."""
try:
@ -92,17 +92,16 @@ def delete_record(dns_server, rr_list, key_name):
keyring = transfer_key.create_keyring()
algorithm = transfer_key.algorithm
delete_response = []
for current_rr in rr_list:
record_list = current_rr.split(".")
record = record_list[0]
domain = ".".join(record_list[1:])
dns_update = dns.update.Update(domain, keyring=keyring, keyalgorithm=algorithm)
dns_update.delete(record)
output = send_dns_update(dns_update, dns_server, key_name)
dns_update = dns.update.Update(zone_name, keyring=keyring, keyalgorithm=algorithm)
records = []
for resource_record in rr_list:
dns_update.delete(resource_record)
records.append("%s.%s" % (zone_name, resource_record))
delete_response.append({ "description" : "Delete Record: %s" % current_rr,
"output" : output })
output = send_dns_update(dns_update, dns_server, key_name)
delete_response = [{"description": "Deleted Records:<br/>%s" %
'<br />'.join(records),
"output": output}]
return delete_response

View File

@ -22,7 +22,7 @@
<input type="hidden" name="zone_name" value="{{ zone_name }}">
{% for current_record in zone_array %}
<tr>
<td><input type="checkbox" name="rr_list" value="{{ current_record.rr_name }}.{{ zone_name }}"></td>
<td><input type="checkbox" name="rr_list" value="{{ current_record.rr_name }}"></td>
<td>{{ current_record.rr_name }}</td>
<td>{{ current_record.rr_ttl }}</td>
<td>{{ current_record.rr_class }}</td>

View File

@ -10,7 +10,7 @@
<th>Output</th>
</tr>
<tr>
<td>{{ current_response.description }}</td>
<td>{{ current_response.description|safe }}</td>
<td><pre>{{ current_response.output }}</pre></td>
</tr>
{% endfor %}

View File

@ -204,6 +204,7 @@ def view_delete_result(request):
print "in view_delete_result, form errors: %r" % form.errors
delete_result = helpers.delete_record(clean_form["dns_server"],
clean_form["zone_name"],
clean_form["rr_list"],
clean_form["key_name"])