Merge branch 'Dunedan-select-default-key'

This commit is contained in:
jeffrey forman 2015-03-24 20:48:34 -04:00
commit 7073cbbf8d
10 changed files with 72 additions and 79 deletions

View File

@ -28,8 +28,7 @@
<div class="navbar"> <div class="navbar">
<div class="navbar-inner"> <div class="navbar-inner">
<a class="brand" href="#"> <a class="brand" href="#">
{% block pageheader %} {% block pageheader %}{% endblock pageheader %}
{% endblock pageheader %}
</a> </a>
</div> </div>
</div> </div>

View File

@ -1,8 +1,6 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block pageheader %} {% block pageheader %}Add CNAME record for {{ originating_record }}{% endblock pageheader %}
Add CNAME record for {{ originating_record }}
{% endblock pageheader %}
{% block body %} {% block body %}
<form class="form-horizontal" action="/add_cname_record/result/" method="post">{% csrf_token %} <form class="form-horizontal" action="/add_cname_record/result/" method="post">{% csrf_token %}
@ -10,8 +8,8 @@ Add CNAME record for {{ originating_record }}
<div class="control-group"> <div class="control-group">
<label class="control-label">DNS Server: </label> <label class="control-label">DNS Server: </label>
<div class="controls"> <div class="controls">
<span class="input-xlarge uneditable-input">{{dns_server}}</span> <span class="input-xlarge uneditable-input">{{dns_server.hostname}}</span>
<input type="hidden" name="dns_server" value="{{dns_server}}"/> <input type="hidden" name="dns_server" value="{{dns_server.hostname}}"/>
</div> </div>
</div> </div>
@ -27,8 +25,8 @@ Add CNAME record for {{ originating_record }}
<label class="control-label">CNAME: </label> <label class="control-label">CNAME: </label>
<div class="controls"> <div class="controls">
<div class="input-append"> <div class="input-append">
<input class="span2" size="100" name="cname" type="text"><span class="add-on">.{{zone_name}}</span> <input class="span2" size="100" name="cname" type="text"><span class="add-on">.{{zone_name}}</span>
<input type="hidden" name="zone_name" value="{{zone_name}}"/> <input type="hidden" name="zone_name" value="{{zone_name}}"/>
</div> </div>
{% if form_errors.cname %} {% if form_errors.cname %}
<div class="alert alert-error"> <div class="alert alert-error">
@ -43,7 +41,7 @@ Add CNAME record for {{ originating_record }}
<div class="controls"> <div class="controls">
<select name="ttl"> <select name="ttl">
{% for ttl, description in ttl_choices %} {% for ttl, description in ttl_choices %}
<option value="{{ttl}}"> <option value="{{ttl}}">
{{ttl}} ({{description}}) {{ttl}} ({{description}})
</option> </option>
{% endfor %} {% endfor %}
@ -55,10 +53,11 @@ Add CNAME record for {{ originating_record }}
<label class="control-label">TSIG Key: </label> <label class="control-label">TSIG Key: </label>
<div class="controls"> <div class="controls">
<select name="key_name"> <select name="key_name">
<option selected="selected" value=""></option> {% for key in tsig_keys %}
{% for key in tsig_keys %} <option value="{{key.id}}"{% if key == dns_server.default_transfer_key %} selected="selected"{% endif %}>{{key}}</option>
<option value="{{key.id}}">{{key}}</option> {% empty %}
{% endfor %} <option selected="selected" value=""></option>
{% endfor %}
</select> </select>
</div> </div>
</div> </div>
@ -66,5 +65,4 @@ Add CNAME record for {{ originating_record }}
<button type="submit" class="btn">Save Changes</button> <button type="submit" class="btn">Save Changes</button>
<a href="{% url "zone_list" dns_server=dns_server zone_name=zone_name %}">Cancel</a> <a href="{% url "zone_list" dns_server=dns_server zone_name=zone_name %}">Cancel</a>
</form> </form>
{% endblock body %} {% endblock body %}

View File

@ -1,28 +1,25 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block pageheader %} {% block pageheader %}Add record in {{ zone_name }}{% endblock pageheader %}
Add record in {{ zone_name }}
{% endblock pageheader %}
{% block body %} {% block body %}
<form class="form-horizontal" action="/add_record/result/" method="post">{% csrf_token %} <form class="form-horizontal" action="/add_record/result/" method="post">{% csrf_token %}
<legend>Create Record</legend> <legend>Create Record</legend>
<input type="hidden" name="zone_name" value="{{zone_name}}"/> <input type="hidden" name="zone_name" value="{{zone_name}}"/>
<div class="control-group"> <div class="control-group">
<label class="control-label">DNS Server: </label> <label class="control-label">DNS Server: </label>
<div class="controls"> <div class="controls">
<span class="input-xlarge uneditable-input">{{dns_server}}</span> <span class="input-xlarge uneditable-input">{{dns_server.hostname}}</span>
<input type="hidden" name="dns_server" value="{{dns_server}}"/> <input type="hidden" name="dns_server" value="{{dns_server.hostname}}"/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label">Record Name: </label> <label class="control-label">Record Name: </label>
<div class="controls"> <div class="controls">
<div class="input-append"> <div class="input-append">
<input class="span2" size="100" name="record_name" type="text"/><span class="add-on">.{{zone_name}}</span> <input class="span2" size="100" name="record_name" type="text"/><span class="add-on">.{{zone_name}}</span>
</div> </div>
{% if form_errors.record_name %} {% if form_errors.record_name %}
<div class="alert alert-error"> <div class="alert alert-error">
@ -51,7 +48,7 @@ Add record in {{ zone_name }}
<label class="control-label">Record Data: </label> <label class="control-label">Record Data: </label>
<div class="controls"> <div class="controls">
<div class="input-append"> <div class="input-append">
<input class="input-large" size="100" name="record_data" type="text"/> <input class="input-large" size="100" name="record_data" type="text"/>
</div> </div>
{% if form_errors.record_data %} {% if form_errors.record_data %}
<div class="alert alert-error"> <div class="alert alert-error">
@ -66,7 +63,7 @@ Add record in {{ zone_name }}
<div class="controls"> <div class="controls">
<select name="ttl"> <select name="ttl">
{% for ttl, description in ttl_choices %} {% for ttl, description in ttl_choices %}
<option value="{{ttl}}"> <option value="{{ttl}}">
{{ttl}} ({{description}}) {{ttl}} ({{description}})
</option> </option>
{% endfor %} {% endfor %}
@ -88,9 +85,10 @@ Add record in {{ zone_name }}
<label class="control-label">TSIG Key: </label> <label class="control-label">TSIG Key: </label>
<div class="controls"> <div class="controls">
<select name="key_name"> <select name="key_name">
<option selected="selected" value=""/>
{% for key in tsig_keys %} {% for key in tsig_keys %}
<option value="{{key.id}}">{{key}}</option> <option value="{{key.id}}"{% if key == dns_server.default_transfer_key %} selected="selected"{% endif %}>{{key}}</option>
{% empty %}
<option selected="selected" value=""/>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -99,5 +97,4 @@ Add record in {{ zone_name }}
<button type="submit" class="btn">Save Changes</button> <button type="submit" class="btn">Save Changes</button>
<button class="btn btn-warning"><a href="{% url "zone_list" dns_server=dns_server zone_name=zone_name %}">Cancel</a></buton> <button class="btn btn-warning"><a href="{% url "zone_list" dns_server=dns_server zone_name=zone_name %}">Cancel</a></buton>
</form> </form>
{% endblock body %} {% endblock body %}

View File

@ -1,15 +1,12 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block pageheader %} {% block pageheader %}Delete record(s) in {{ zone_name }}{% endblock pageheader %}
Delete record(s) in {{ zone_name }}
{% endblock pageheader %}
{% block body %} {% block body %}
<table class="table"> <table class="table">
<form action="/delete_record/result/" method="POST"> <form action="/delete_record/result/" method="POST">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="dns_server" value="{{ dns_server }}" /> <input type="hidden" name="dns_server" value="{{ dns_server.hostname }}" />
<input type="hidden" name="zone_name" value="{{ zone_name }}" /> <input type="hidden" name="zone_name" value="{{ zone_name }}" />
<input type="hidden" name="rr_list" value="{{ rr_list }}" /> <input type="hidden" name="rr_list" value="{{ rr_list }}" />
<tr> <tr>
@ -17,7 +14,7 @@ Delete record(s) in {{ zone_name }}
</tr> </tr>
<tr> <tr>
<td>Server</td> <td>Server</td>
<td>{{ dns_server }}</td> <td>{{ dns_server.hostname }}</td>
</tr> </tr>
<tr> <tr>
<td>Zone</td> <td>Zone</td>
@ -31,9 +28,10 @@ Delete record(s) in {{ zone_name }}
<td>Key</td> <td>Key</td>
<td> <td>
<select name="key_name"> <select name="key_name">
<option selected="selected" value=""/>
{% for current_key in tsig_keys %} {% for current_key in tsig_keys %}
<option value="{{current_key.id}}">{{current_key}}</option> <option value="{{current_key.id}}"{% if current_key == dns_server.default_transfer_key %} selected="selected"{% endif %}>{{current_key}}</option>
{% empty %}
<option selected="selected" value=""/>
{% endfor %} {% endfor %}
</select> </select>
</td> </td>
@ -46,5 +44,4 @@ Delete record(s) in {{ zone_name }}
</tr> </tr>
</form> </form>
</table> </table>
{% endblock body %} {% endblock body %}

View File

@ -1,9 +1,6 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block pageheader %} {% block pageheader %}Server Zone List for {{ dns_server.hostname }}{% endblock pageheader %}
Server Zone List for {{ dns_server }}
{% endblock pageheader %}
{% block body %} {% block body %}
<table class="table sortable"> <table class="table sortable">
@ -16,7 +13,7 @@ Server Zone List for {{ dns_server }}
{% for current_view, cv_data in cz_data.iteritems %} {% for current_view, cv_data in cz_data.iteritems %}
<tr> <tr>
<td> <td>
<a href="{% url "zone_list" dns_server=dns_server zone_name=current_zone %}"> {{ current_zone }}</a> <a href="{% url "zone_list" dns_server=dns_server.hostname zone_name=current_zone %}"> {{ current_zone }}</a>
</td> </td>
<td>{{ current_view }}</td> <td>{{ current_view }}</td>
<td>{{ cv_data.serial }}</td> <td>{{ cv_data.serial }}</td>
@ -24,5 +21,4 @@ Server Zone List for {{ dns_server }}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
</table> </table>
{% endblock body %} {% endblock body %}

View File

@ -1,9 +1,6 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block pageheader %}Server List{% endblock pageheader %}
{% block pageheader %}
Server List
{% endblock pageheader %}
{% block body %} {% block body %}
<table class="table"> <table class="table">
@ -21,5 +18,4 @@ Server List
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endblock body %} {% endblock body %}

View File

@ -1,11 +1,8 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block pageheader %} {% block pageheader %}Zone listing for {{ zone_name }} on {{ dns_server.hostname }}{% endblock pageheader %}
Zone listing for {{ zone_name }} on {{ dns_server }}
{% endblock pageheader %}
{% block body %} {% block body %}
{% if not errors %} {% if not errors %}
<form action="{% url "delete_record" %}" method="post">{% csrf_token %} <form action="{% url "delete_record" %}" method="post">{% csrf_token %}
<table class="table table-hover sortable"> <table class="table table-hover sortable">
@ -21,7 +18,7 @@ Zone listing for {{ zone_name }} on {{ dns_server }}
<th></th> <th></th>
</tr> </tr>
<input type="hidden" name="dns_server" value="{{ dns_server }}"> <input type="hidden" name="dns_server" value="{{ dns_server.hostname }}">
<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>
@ -34,13 +31,13 @@ Zone listing for {{ zone_name }} on {{ dns_server }}
<td> <td>
<div class="btn-toolbar" style="margin: 0;"> <div class="btn-toolbar" style="margin: 0;">
<div class="btn-group"> <div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">Record Actions <span class="caret"></span></button> <button class="btn dropdown-toggle" data-toggle="dropdown">Record Actions <span class="caret"></span></button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#">Edit Record (Coming Soon)</a></li> <li><a href="#">Edit Record (Coming Soon)</a></li>
{% if current_record.rr_type == "A" %} {% if current_record.rr_type == "A" %}
<li><a href="{% url "add_cname" dns_server=dns_server zone_name=zone_name record_name=current_record.rr_name %}">Add CNAME Pointer</a></li> <li><a href="{% url "add_cname" dns_server=dns_server.hostname zone_name=zone_name record_name=current_record.rr_name %}">Add CNAME Pointer</a></li>
{% endif %} {% endif %}
</ul> </ul>
</div> </div>
</div> </div>
</td> </td>

View File

@ -1,9 +1,6 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block pageheader %}Record Result{% endblock pageheader %}
{% block pageheader %}
Record Result
{% endblock pageheader %}
{% block body %} {% block body %}
<table class="table"> <table class="table">

View File

@ -1,8 +1,6 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block pageheader %} {% block pageheader %}Home{% endblock pageheader %}
Home
{% endblock pageheader %}
{% block body %} {% block body %}

View File

@ -11,6 +11,7 @@ def home_index(request):
""" List the main index page for Binder. """ """ List the main index page for Binder. """
return render(request, "index.htm") return render(request, "index.htm")
def view_server_list(request): def view_server_list(request):
""" List the DNS servers configured in the database. """ """ List the DNS servers configured in the database. """
server_list = models.BindServer.objects.all().order_by("hostname") server_list = models.BindServer.objects.all().order_by("hostname")
@ -21,54 +22,62 @@ def view_server_list(request):
return render(request, "bcommon/list_servers.htm", return render(request, "bcommon/list_servers.htm",
{ "server_info" : server_info}) { "server_info" : server_info})
def view_server_zones(request, dns_server): def view_server_zones(request, dns_server):
""" Display the list of DNS zones a particular DNS host provides. """ """ Display the list of DNS zones a particular DNS host provides. """
errors = "" errors = ""
zone_array = {} zone_array = {}
try: try:
this_server = models.BindServer.objects.get(hostname=dns_server) this_server = models.BindServer.objects.get(hostname=dns_server)
zone_array = this_server.list_zones()
except models.BindServer.DoesNotExist, err: except models.BindServer.DoesNotExist, err:
errors = "There is no configured server by that name: %s" % dns_server errors = "There is no configured server by that name: %s" % dns_server
except exceptions.ZoneException, err: else:
errors = "Unable to list server zones. Error: %s" % err try:
zone_array = this_server.list_zones()
except exceptions.ZoneException, err:
errors = "Unable to list server zones. Error: %s" % err
return render(request, "bcommon/list_server_zones.htm", return render(request, "bcommon/list_server_zones.htm",
{ "errors" : errors, { "errors" : errors,
"dns_server" : dns_server, "dns_server" : this_server,
"zone_array" : zone_array}) "zone_array" : zone_array})
def view_zone_records(request, dns_server, zone_name): def view_zone_records(request, dns_server, zone_name):
""" Display the list of records for a particular zone. """ """ Display the list of records for a particular zone. """
errors = "" errors = ""
zone_array = {} zone_array = {}
this_server = models.BindServer.objects.get(hostname=dns_server)
try: try:
this_server = models.BindServer.objects.get(hostname=dns_server)
zone_array = this_server.list_zone_records(zone_name) zone_array = this_server.list_zone_records(zone_name)
except exceptions.TransferException, err: except exceptions.TransferException, err:
return render(request, "bcommon/list_zone.htm", return render(request, "bcommon/list_zone.htm",
{ "errors" : err, { "errors" : err,
"zone_name" : zone_name, "zone_name" : zone_name,
"dns_server" : dns_server}) "dns_server" : this_server})
except models.BindServer.DoesNotExist: except models.BindServer.DoesNotExist:
errors = "Requesting a zone listing for a Bind server that is not configured: %s" % dns_server errors = "Requesting a zone listing for a Bind server that is not configured: %s" % dns_server
return render(request, "bcommon/list_zone.htm", return render(request, "bcommon/list_zone.htm",
{ "zone_array" : zone_array, { "zone_array" : zone_array,
"dns_server" : dns_server, "dns_server" : this_server,
"zone_name" : zone_name, "zone_name" : zone_name,
"errors" : errors}) "errors" : errors})
def view_add_record(request, dns_server, zone_name): def view_add_record(request, dns_server, zone_name):
""" View to provide form to add a DNS record. """ """ View to provide form to add a DNS record. """
this_server = models.BindServer.objects.get(hostname=dns_server)
return render(request, "bcommon/add_record_form.htm", return render(request, "bcommon/add_record_form.htm",
{ "dns_server" : dns_server, { "dns_server" : this_server,
"zone_name" : zone_name, "zone_name" : zone_name,
"tsig_keys" : models.Key.objects.all(), "tsig_keys" : models.Key.objects.all(),
"ttl_choices" : local_settings.TTL_CHOICES, "ttl_choices" : local_settings.TTL_CHOICES,
"record_type_choices" : local_settings.RECORD_TYPE_CHOICES, "record_type_choices" : local_settings.RECORD_TYPE_CHOICES,
}) })
def view_add_record_result(request): def view_add_record_result(request):
""" Process the input given to add a DNS record. """ """ Process the input given to add a DNS record. """
errors = "" errors = ""
@ -104,21 +113,28 @@ def view_add_record_result(request):
{ "errors" : errors, { "errors" : errors,
"response" : response }) "response" : response })
dns_server = models.BindServer.objects.get(hostname=request.POST["dns_server"])
return render(request, "bcommon/add_record_form.htm", return render(request, "bcommon/add_record_form.htm",
{ "dns_server" : request.POST["dns_server"], { "dns_server" : dns_server,
"zone_name" : request.POST["zone_name"], "zone_name" : request.POST["zone_name"],
"form_errors" : form.errors, "form_errors" : form.errors,
"form_data" : request.POST }) "form_data" : request.POST })
def view_add_cname_record(request, dns_server, zone_name, record_name): def view_add_cname_record(request, dns_server, zone_name, record_name):
""" Process given input to add a CNAME pointer.""" """ Process given input to add a CNAME pointer."""
this_server = models.BindServer.objects.get(hostname=dns_server)
return render(request, "bcommon/add_cname_record_form.htm", return render(request, "bcommon/add_cname_record_form.htm",
{ "dns_server" : dns_server, { "dns_server" : this_server,
"originating_record" : "%s.%s" % (record_name, zone_name), "originating_record" : "%s.%s" % (record_name, zone_name),
"zone_name" : zone_name, "zone_name" : zone_name,
"ttl_choices" : local_settings.TTL_CHOICES, "ttl_choices" : local_settings.TTL_CHOICES,
"tsig_keys" : models.Key.objects.all() }) "tsig_keys" : models.Key.objects.all() })
def view_add_cname_result(request): def view_add_cname_result(request):
""" Process input on the CNAME form and provide a response.""" """ Process input on the CNAME form and provide a response."""
if request.method == "GET": if request.method == "GET":
@ -144,8 +160,10 @@ def view_add_cname_result(request):
{"response" : add_cname_response, {"response" : add_cname_response,
"errors" : errors }) "errors" : errors })
dns_server = models.BindServer.objects.get(hostname=request.POST["dns_server"])
return render(request, "bcommon/add_cname_record_form.htm", return render(request, "bcommon/add_cname_record_form.htm",
{ "dns_server" : request.POST["dns_server"], { "dns_server" : dns_server,
"zone_name" : request.POST["zone_name"], "zone_name" : request.POST["zone_name"],
"record_name" : request.POST["cname"], "record_name" : request.POST["cname"],
"originating_record" : request.POST["originating_record"], "originating_record" : request.POST["originating_record"],
@ -160,7 +178,7 @@ def view_delete_record(request):
if request.method == "GET": if request.method == "GET":
return redirect("/") return redirect("/")
dns_server = request.POST["dns_server"] dns_server = models.BindServer.objects.get(hostname=request.POST["dns_server"])
zone_name = request.POST["zone_name"] zone_name = request.POST["zone_name"]
rr_list = request.POST.getlist("rr_list") rr_list = request.POST.getlist("rr_list")