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:
parent
7073cbbf8d
commit
24e6b7e399
|
@ -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),
|
return [{ "description" : "CNAME %s.%s points to %s" % (cname, zone_name, originating_record),
|
||||||
"output" : output}]
|
"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."""
|
"""Delete a list of DNS records passed as strings in rr_items."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -92,17 +92,16 @@ def delete_record(dns_server, rr_list, key_name):
|
||||||
keyring = transfer_key.create_keyring()
|
keyring = transfer_key.create_keyring()
|
||||||
algorithm = transfer_key.algorithm
|
algorithm = transfer_key.algorithm
|
||||||
|
|
||||||
delete_response = []
|
dns_update = dns.update.Update(zone_name, keyring=keyring, keyalgorithm=algorithm)
|
||||||
for current_rr in rr_list:
|
records = []
|
||||||
record_list = current_rr.split(".")
|
for resource_record in rr_list:
|
||||||
record = record_list[0]
|
dns_update.delete(resource_record)
|
||||||
domain = ".".join(record_list[1:])
|
records.append("%s.%s" % (zone_name, resource_record))
|
||||||
dns_update = dns.update.Update(domain, keyring=keyring, keyalgorithm=algorithm)
|
|
||||||
dns_update.delete(record)
|
|
||||||
output = send_dns_update(dns_update, dns_server, key_name)
|
|
||||||
|
|
||||||
delete_response.append({ "description" : "Delete Record: %s" % current_rr,
|
output = send_dns_update(dns_update, dns_server, key_name)
|
||||||
"output" : output })
|
delete_response = [{"description": "Deleted Records:<br/>%s" %
|
||||||
|
'<br />'.join(records),
|
||||||
|
"output": output}]
|
||||||
|
|
||||||
return delete_response
|
return delete_response
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<input type="hidden" name="zone_name" value="{{ zone_name }}">
|
<input type="hidden" name="zone_name" value="{{ zone_name }}">
|
||||||
{% for current_record in zone_array %}
|
{% for current_record in zone_array %}
|
||||||
<tr>
|
<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_name }}</td>
|
||||||
<td>{{ current_record.rr_ttl }}</td>
|
<td>{{ current_record.rr_ttl }}</td>
|
||||||
<td>{{ current_record.rr_class }}</td>
|
<td>{{ current_record.rr_class }}</td>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<th>Output</th>
|
<th>Output</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ current_response.description }}</td>
|
<td>{{ current_response.description|safe }}</td>
|
||||||
<td><pre>{{ current_response.output }}</pre></td>
|
<td><pre>{{ current_response.output }}</pre></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -204,6 +204,7 @@ def view_delete_result(request):
|
||||||
print "in view_delete_result, form errors: %r" % form.errors
|
print "in view_delete_result, form errors: %r" % form.errors
|
||||||
|
|
||||||
delete_result = helpers.delete_record(clean_form["dns_server"],
|
delete_result = helpers.delete_record(clean_form["dns_server"],
|
||||||
|
clean_form["zone_name"],
|
||||||
clean_form["rr_list"],
|
clean_form["rr_list"],
|
||||||
clean_form["key_name"])
|
clean_form["key_name"])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue