make exceptions a bit more module-path happy. fix some iterator references
This commit is contained in:
parent
2247f7262e
commit
17da7b33a3
|
@ -9,8 +9,8 @@
|
||||||
<th>View</th>
|
<th>View</th>
|
||||||
<th>Serial Number</th>
|
<th>Serial Number</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for current_zone, cz_data in zone_array.stats.zone_stats.iteritems %}
|
{% for current_zone, cz_data in zone_array.stats.zone_stats.items %}
|
||||||
{% for current_view, cv_data in cz_data.iteritems %}
|
{% for current_view, cv_data in cz_data.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{% url "zone_list" dns_server=dns_server.hostname zone_name=current_zone %}"> {{ current_zone }}</a>
|
<a href="{% url "zone_list" dns_server=dns_server.hostname zone_name=current_zone %}"> {{ current_zone }}</a>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Hostname</th>
|
<th>Hostname</th>
|
||||||
<th>IP Address</th>
|
<th>IP Address</th>
|
||||||
|
<th>Server Type</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for current_server in server_info %}
|
{% for current_server in server_info %}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
{{type}}: {{data}}<br>
|
{{type}}: {{data}}<br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
|
<td> {{ current_server.server_type}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
<td>{{ current_record.rr_data }}</td>
|
<td>{{ current_record.rr_data }}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-toolbar" style="margin: 0;">
|
<div class="btn-toolbar" style="margin: 0;">
|
||||||
|
{% if dynamic_dns_available %}
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||||
Record Actions <span class="caret"></span>
|
Record Actions <span class="caret"></span>
|
||||||
|
@ -38,6 +39,9 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
Actions not available.
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
# Binder VIews
|
# Binder Views
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
# 3rd Party
|
# 3rd Party
|
||||||
|
import dns.query
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
|
|
||||||
# App Imports
|
# App Imports
|
||||||
from binder import forms, helpers, models
|
from binder import forms, helpers, models
|
||||||
from binder.exceptions import KeyringException, RecordException, TransferException, ZoneException
|
from binder import exceptions
|
||||||
|
|
||||||
def home_index(request):
|
def home_index(request):
|
||||||
"""List the main index page for Binder."""
|
"""List the main index page for Binder."""
|
||||||
|
@ -19,7 +22,8 @@ def view_server_list(request):
|
||||||
server_info = []
|
server_info = []
|
||||||
for current in server_list:
|
for current in server_list:
|
||||||
server_info.append({"host_name": current,
|
server_info.append({"host_name": current,
|
||||||
"ip_address": helpers.ip_info(current.hostname)})
|
"ip_address": helpers.ip_info(current.hostname),
|
||||||
|
"server_type": current.server_type})
|
||||||
|
|
||||||
return render(request, "bcommon/list_servers.html",
|
return render(request, "bcommon/list_servers.html",
|
||||||
{"server_info": server_info})
|
{"server_info": server_info})
|
||||||
|
@ -33,8 +37,10 @@ def view_server_zones(request, dns_server):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
zone_array = this_server.list_zones()
|
zone_array = this_server.list_zones()
|
||||||
except ZoneException as exc:
|
except exceptions.ZoneException as exc:
|
||||||
messages.error(request, "Unable to list server zones. Error: %s" % exc)
|
messages.error(request, "Unable to list server zones. Error: %s" % exc)
|
||||||
|
except subprocess.CalledProcessError as err:
|
||||||
|
messages.error(request, "Error in retrieving zones: %s." % str(err.output))
|
||||||
|
|
||||||
return render(request, "bcommon/list_server_zones.html",
|
return render(request, "bcommon/list_server_zones.html",
|
||||||
{"dns_server": this_server,
|
{"dns_server": this_server,
|
||||||
|
@ -49,22 +55,31 @@ def view_zone_records(request, dns_server, zone_name):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
zone_array = this_server.list_zone_records(zone_name)
|
zone_array = this_server.list_zone_records(zone_name)
|
||||||
except TransferException as exc:
|
except exceptions.TransferException as exc:
|
||||||
|
messages.error(request, "TransferException: %s." % exc)
|
||||||
return render(request, "bcommon/list_zone.html",
|
return render(request, "bcommon/list_zone.html",
|
||||||
{"zone_name": zone_name,
|
{"zone_name": zone_name,
|
||||||
"dns_server": this_server})
|
"dns_server": this_server})
|
||||||
except KeyringException:
|
except exceptions.KeyringException:
|
||||||
messages.error(request, "Unable to get zone list. A problem was encountered "
|
messages.error(request, "Unable to get zone list. A problem was encountered "
|
||||||
"decrypting your TSIG key. Ensure the key is correctly "
|
"decrypting your TSIG key. Ensure the key is correctly "
|
||||||
"specified in the Binder Database.")
|
"specified in the Binder Database.")
|
||||||
return render(request, "bcommon/list_zone.html",
|
return render(request, "bcommon/list_zone.html",
|
||||||
{ "dns_server": this_server,
|
{ "dns_server": this_server,
|
||||||
"zone_name" :zone_name })
|
"zone_name" :zone_name })
|
||||||
|
except dns.query.TransferError as err:
|
||||||
|
messages.error(request, "TransferError: %s." % err)
|
||||||
|
return render(request, "bcommon/list_zone.html",
|
||||||
|
{"zone_name": zone_name,
|
||||||
|
"dns_server": this_server})
|
||||||
|
|
||||||
return render(request, "bcommon/list_zone.html",
|
return render(request, "bcommon/list_zone.html",
|
||||||
{"zone_array": zone_array,
|
{"zone_array": zone_array,
|
||||||
"dns_server": this_server,
|
"dns_server": this_server,
|
||||||
"zone_name": zone_name})
|
"zone_name": zone_name,
|
||||||
|
# NOTE: A hack because NSD doesn't support dynamic updates
|
||||||
|
# so merely display the zone.
|
||||||
|
"dynamic_dns_available": this_server.server_type in ['BIND']})
|
||||||
|
|
||||||
|
|
||||||
def view_add_record(request, dns_server, zone_name):
|
def view_add_record(request, dns_server, zone_name):
|
||||||
|
@ -86,7 +101,8 @@ def view_add_record(request, dns_server, zone_name):
|
||||||
form_cleaned["ttl"],
|
form_cleaned["ttl"],
|
||||||
form_cleaned["key_name"],
|
form_cleaned["key_name"],
|
||||||
form_cleaned["create_reverse"])
|
form_cleaned["create_reverse"])
|
||||||
except (KeyringException, RecordException) as exc:
|
except (exceptions.KeyringException,
|
||||||
|
exceptions.RecordException) as exc:
|
||||||
messages.error(request, "Adding %s.%s failed: %s" %
|
messages.error(request, "Adding %s.%s failed: %s" %
|
||||||
(form_cleaned["record_name"], zone_name, exc))
|
(form_cleaned["record_name"], zone_name, exc))
|
||||||
else:
|
else:
|
||||||
|
@ -130,7 +146,8 @@ def view_edit_record(request, dns_server, zone_name, record_name=None,
|
||||||
form_cleaned["ttl"],
|
form_cleaned["ttl"],
|
||||||
form_cleaned["key_name"],
|
form_cleaned["key_name"],
|
||||||
form_cleaned["create_reverse"])
|
form_cleaned["create_reverse"])
|
||||||
except (KeyringException, RecordException) as exc:
|
except (exceptions.KeyringException,
|
||||||
|
exceptions.RecordException) as exc:
|
||||||
messages.error(request, "Modifying %s.%s failed: %s" %
|
messages.error(request, "Modifying %s.%s failed: %s" %
|
||||||
(form_cleaned["record_name"], zone_name, exc))
|
(form_cleaned["record_name"], zone_name, exc))
|
||||||
else:
|
else:
|
||||||
|
@ -173,7 +190,8 @@ def view_add_cname_record(request, dns_server, zone_name, record_name):
|
||||||
str(form_cleaned["zone_name"])),
|
str(form_cleaned["zone_name"])),
|
||||||
form_cleaned["ttl"],
|
form_cleaned["ttl"],
|
||||||
form_cleaned["key_name"])
|
form_cleaned["key_name"])
|
||||||
except (KeyringException, RecordException) as exc:
|
except (exceptions.KeyringException,
|
||||||
|
exceptions.RecordException) as exc:
|
||||||
messages.error(request, "Adding %s.%s failed: %s" %
|
messages.error(request, "Adding %s.%s failed: %s" %
|
||||||
(form_cleaned["cname"], zone_name, exc))
|
(form_cleaned["cname"], zone_name, exc))
|
||||||
else:
|
else:
|
||||||
|
@ -215,7 +233,7 @@ def view_delete_record(request, dns_server, zone_name):
|
||||||
response = helpers.delete_record(form_cleaned["dns_server"],
|
response = helpers.delete_record(form_cleaned["dns_server"],
|
||||||
rr_list,
|
rr_list,
|
||||||
form_cleaned["key_name"])
|
form_cleaned["key_name"])
|
||||||
except KeyringException as exc:
|
except exceptions.KeyringException as exc:
|
||||||
for record in rr_list:
|
for record in rr_list:
|
||||||
messages.error(request, "Deleting %s.%s failed: %s" %
|
messages.error(request, "Deleting %s.%s failed: %s" %
|
||||||
(record, zone_name, exc))
|
(record, zone_name, exc))
|
||||||
|
|
Loading…
Reference in New Issue