summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Hostbase/hostbase
diff options
context:
space:
mode:
authorKen Raffenetti <raffenet@mcs.anl.gov>2006-09-27 22:23:58 +0000
committerKen Raffenetti <raffenet@mcs.anl.gov>2006-09-27 22:23:58 +0000
commita9abc440cc0c411f9975e1827d71776364bdb659 (patch)
tree0349ee555b0d16a24ca5f911b3e329fa530a02e5 /src/lib/Server/Hostbase/hostbase
parent82c3087ee2cf83c423127c348b6b5a12461242dd (diff)
downloadbcfg2-a9abc440cc0c411f9975e1827d71776364bdb659.tar.gz
bcfg2-a9abc440cc0c411f9975e1827d71776364bdb659.tar.bz2
bcfg2-a9abc440cc0c411f9975e1827d71776364bdb659.zip
changes in database models for zone information
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2335 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Hostbase/hostbase')
-rw-r--r--src/lib/Server/Hostbase/hostbase/models.py11
-rw-r--r--src/lib/Server/Hostbase/hostbase/views.py63
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/confirm.html3
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/dns.html3
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/dnsedit.html3
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/edit.html8
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/errors.html3
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/host.html3
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/navbar2
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/results.html3
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/zoneedit.html146
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/zones.html37
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html66
13 files changed, 314 insertions, 37 deletions
diff --git a/src/lib/Server/Hostbase/hostbase/models.py b/src/lib/Server/Hostbase/hostbase/models.py
index 7c47b65bd..3216944ea 100644
--- a/src/lib/Server/Hostbase/hostbase/models.py
+++ b/src/lib/Server/Hostbase/hostbase/models.py
@@ -141,6 +141,15 @@ class Nameserver(models.Model):
class Admin:
pass
+class ZoneAddress(models.Model):
+ ip_addr = models.IPAddressField()
+
+ def __str__(self):
+ return self.ip_addr
+
+ class Admin:
+ pass
+
class Zone(models.Model):
zone = models.CharField(maxlength=64)
serial = models.IntegerField()
@@ -152,7 +161,7 @@ class Zone(models.Model):
ttl = models.IntegerField()
nameservers = models.ManyToManyField(Nameserver)
mxs = models.ManyToManyField(MX)
- addresses = models.ManyToManyField(IP, blank=True)
+ addresses = models.ManyToManyField(ZoneAddress, blank=True)
aux = models.TextField(blank=True)
def __str__(self):
diff --git a/src/lib/Server/Hostbase/hostbase/views.py b/src/lib/Server/Hostbase/hostbase/views.py
index 757b43da0..e9673e0a1 100644
--- a/src/lib/Server/Hostbase/hostbase/views.py
+++ b/src/lib/Server/Hostbase/hostbase/views.py
@@ -16,6 +16,9 @@ attribs = ['hostname', 'whatami', 'netgroup', 'security_class', 'support',
'csi', 'printq', 'primary_user', 'administrator', 'location',
'comments', 'status']
+zoneattribs = ['zone', 'admin', 'primary_master', 'expire', 'retry',
+ 'refresh', 'ttl', 'aux']
+
dispatch = {'mac_addr':'i.mac_addr LIKE \'%%%%%s%%%%\'',
'ip_addr':'p.ip_addr LIKE \'%%%%%s%%%%\'',
'name':'n.name LIKE \'%%%%%s%%%%\'',
@@ -712,28 +715,48 @@ def validate(request, new=False, host_id=None):
return 0
return failures
-def push(request):
- if request.GET.has_key('sub'):
- # do xmlrpc function here
- return HttpResponse("TBD")
- else:
- temp = Template(open('%s/push.html' % templatedir).read())
- temp.dirtyhosts = Host.objects.filter(dirty=True)
- return HttpResponse(str(temp))
-
def zones(request):
zones = Zone.objects.all()
- temp = Template(open('%s/zones.html' % templatedir).read())
- temp.zones = zones
- return HttpResponse(str(temp))
+ return render_to_response('zones.html',
+ {'zones': zones})
def zoneview(request, zone_id):
zone = Zone.objects.get(id=zone_id)
- temp = Template(open('%s/zoneview.html' % templatedir).read())
- temp.zone = zone
- aux = zone.aux.split('\n')
- temp.aux = aux
- temp.nameservers = zone.nameservers.all()
- temp.mxs = zone.mxs.all()
- temp.addresses = zone.addresses.all()
- return HttpResponse(str(temp))
+ return render_to_response('zoneview.html',
+ {'zone': zone,
+ 'nameservers': zone.nameservers.all(),
+ 'mxs': zone.mxs.all(),
+ 'addresses': zone.addresses.all()
+ })
+
+def zoneedit(request, zone_id):
+ if request.has_key('sub'):
+ zone = Zone.objects.get(id=zone_id)
+ for attrib in zoneattribs:
+ if request.POST.has_key(attrib):
+ zone.__dict__[attrib] = request.POST[attrib]
+ count = 0
+## for nameserver in zone.nameservers.all():
+## nameserver.name = request.POST['nameserver%i' % count]
+## nameserver.save()
+## count += 1
+## count = 0
+## for mx in zone.mxs.all():
+## mx.priority = request.POST['priority%i' % count]
+## mx.mx = request.POST['mx%i' % count]
+## mx.save()
+## count += 1
+## count = 0
+## for address in zone.addresses.all():
+## address.ip_addr = request.POST['address%i' % count]
+## count += 1
+ zone.save()
+ return HttpResponseRedirect('/hostbase/zones/%s/' % zone.id)
+ else:
+ zone = Zone.objects.get(id=zone_id)
+ return render_to_response('zoneedit.html',
+ {'zone': zone,
+ 'nameservers': zone.nameservers.all(),
+ 'mxs': zone.mxs.all(),
+ 'addresses': zone.addresses.all()
+ })
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/confirm.html b/src/lib/Server/Hostbase/hostbase/webtemplates/confirm.html
index e89c21247..c7761c3ea 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/confirm.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/confirm.html
@@ -8,8 +8,7 @@
{% endblock %}
{% block sidebar %}
-<a href="/hostbase/" class="sidebar">new search</a><br>
-<a href="/hostbase/" class="sidebar">add a new host</a>
+{% include "navbar" %}
{% endblock %}
{% block content %}
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html b/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html
index 1ffb0297a..1db012852 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html
@@ -8,8 +8,7 @@
{% endblock %}
{% block sidebar %}
-<a href="/hostbase/" class="sidebar">new search</a><br>
-<a href="/hostbase/" class="sidebar">add a new host</a>
+{% include "navbar" %}
<ul class="sidebar">
<li><a href="/hostbase/{{ host.id }}/" class="sidebar">host info</a></li>
<li><a href="/hostbase/{{ host.id }}/edit/" class="sidebar">edit host info</a></li>
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/dnsedit.html b/src/lib/Server/Hostbase/hostbase/webtemplates/dnsedit.html
index a5a4088eb..1d6245e81 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/dnsedit.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/dnsedit.html
@@ -8,8 +8,7 @@
{% endblock %}
{% block sidebar %}
-<a href="/hostbase/" class="sidebar">new search</a><br>
-<a href="/hostbase/" class="sidebar">add a new host</a>
+{% include "navbar" %}
<ul class="sidebar">
<li><a href="/hostbase/{{ host.id }}/" class="sidebar">host info</a></li>
<li><a href="/hostbase/{{ host.id }}/edit/" class="sidebar">edit host info</a></li>
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html b/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html
index 19094e112..efc308def 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html
@@ -8,9 +8,8 @@
{% endblock %}
{% block sidebar %}
-<a href="/hostbase/" class="sidebar">new search</a><br>
-<a href="/hostbase/new/" class="sidebar">add a new host</a>
-<ul>
+{% include "navbar" %}
+<ul class="sidebar">
<li><a href="/hostbase/{{ host.id }}/" class="sidebar">host info</a></li>
<li><a href="/hostbase/{{ host.id }}/dns/" class="sidebar">detailed dns info</a></li>
<li><a href="/hostbase/{{ host.id }}/dns/edit/" class="sidebar">edit dns info</a></li>
@@ -47,12 +46,13 @@ div#interface{
<form name="hostdata" action="?sub=true" method="post">
<input type="hidden" name="host" value="{{ host.id }}">
+<input type="hidden" name="hostname" value="{{ host.hostname }}">
<table border="0" width="100%">
<colgroup>
<col width="150">
<col width="*">
<tr> <td> <b>hostname</b></td>
- <td> <input name="hostname" type="text" value="{{ host.hostname }}"></td></tr>
+ <td> {{ host.hostname }}</td></tr>
<tr> <td> <b>whatami</b></td>
<td>
<select name="whatami">
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html b/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html
index c240651fe..d321c529f 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html
@@ -8,8 +8,7 @@
{% endblock %}
{% block sidebar %}
-<a href="/hostbase/" class="sidebar">new search</a><br>
-<a href="/hostbase/" class="sidebar">add a new host</a>
+{% include "navbar" %}
{% endblock %}
{% block content %}
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html
index 3b09cbc6b..088befe88 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html
@@ -8,8 +8,7 @@
{% endblock %}
{% block sidebar %}
-<a href="/hostbase/" class="sidebar">new search</a><br>
-<a href="/hostbase/new/" class="sidebar">add a new host</a>
+{% include "navbar" %}
<ul class="sidebar">
<li><a href="dns/" class="sidebar">detailed dns info</a></li>
<li><a href="edit/" class="sidebar">edit host info</a></li>
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/navbar b/src/lib/Server/Hostbase/hostbase/webtemplates/navbar
new file mode 100644
index 000000000..767601aca
--- /dev/null
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/navbar
@@ -0,0 +1,2 @@
+<a href="/hostbase/" class="sidebar">new search</a><br>
+<a href="/hostbase/new" class="sidebar">add a new host</a>
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/results.html b/src/lib/Server/Hostbase/hostbase/webtemplates/results.html
index c9b634177..6fb45692e 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/results.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/results.html
@@ -8,8 +8,7 @@
{% endblock %}
{% block sidebar %}
-<a href="/hostbase/" class="sidebar">new search</a><br>
-<a href="/hostbase/" class="sidebar">add a new host</a>
+{% include "navbar" %}
{% endblock %}
{% block content %}
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zoneedit.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneedit.html
new file mode 100644
index 000000000..918f80398
--- /dev/null
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneedit.html
@@ -0,0 +1,146 @@
+{% extends "base.html" %}
+
+{% block pagebanner %}
+ <div class="header">
+ <h2>Zones</h2>
+ <p>Edit information for {{ zone.zone }}
+ </div>
+ <br/>
+{% endblock %}
+
+{% block sidebar %}
+{% include "navbar" %}
+{% endblock %}
+
+{% block content %}
+
+<script language=JavaScript type=text/Javascript>
+function toggleField(fieldname){
+ if(document.getElementById){
+ var style = document.getElementById(fieldname).style;
+ style.display = style.display? "":"block";
+ }
+}
+</script>
+
+<style type=text/css>
+div#nameserver{
+ display: none;
+}
+div#mx{
+ display: none;
+}
+div#address{
+ display: none;
+}
+</style>
+
+<form name="zonedata" action="?sub=true" method="post">
+<input type="hidden" name="zone" value="{{ zone.id }}">
+<table border="0" width="100%">
+ <colgroup>
+ <col width="200">
+ <col width="*">
+ <tr> <td> <b>zone</b></td>
+ <td> <input name="zone" type="text" size="32" value="{{ zone.zone }}"></td></tr>
+ <tr> <td> <b>admin</b></td>
+ <td> <input name="admin" type="text" size="32" value="{{ zone.admin }}"></td></tr>
+ <tr> <td> <b>primary_master</b></td>
+ <td> <input name="primary_master" type="text" size="32" value="{{ zone.primary_master }}"></td></tr>
+ <tr> <td> <b>expire</b></td>
+ <td> <input name="expire" type="text" size="32" value="{{ zone.expire }}"></td></tr>
+ <tr> <td> <b>retry</b></td>
+ <td> <input name="retry" type="text" size="32" value="{{ zone.retry }}"></td></tr>
+ <tr> <td> <b>refresh</b></td>
+ <td> <input name="refresh" type="text" size="32" value="{{ zone.refresh }}"></td></tr>
+ <tr> <td> <b>ttl</b></td>
+ <td> <input name="ttl" type="text" size="32" value="{{ zone.ttl }}"></td></tr>
+
+ <tr><td valign="top"> <b>nameservers</b><br>
+ <a style="font-size:75%" href=# onclick="toggleField('nameserver')">add a new NS record</a>
+ </td>
+ <td>
+ {% for nameserver in nameservers %}
+ <input name="nameserver{{ forloop.counter0 }}" type="text" size="32" value="{{ nameserver.name }}"><br>
+ {% endfor %}
+ </td></tr>
+ </table>
+ <div id=nameserver>
+ <table border="0" width="100%">
+ <colgroup>
+ <col width="200">
+ <col width="*">
+ <tr> <td></td>
+ <td> <input name="new_nameserver" size="32" type="text"></td></tr>
+ </table>
+ </div>
+ <table border="0" width="100%">
+ <colgroup>
+ <col width="200">
+ <col width="*">
+ <tr><td valign="top"> <b>mxs</b><br>
+ <a style="font-size:75%" href=# onclick="toggleField('mx')">add a new MX record</a>
+ </td>
+ <td>
+ {% for mx in mxs %}
+ <input name="priority{{ forloop.counter0 }}" type="text" size="6" value="{{ mx.priority }}">
+ <input name="mx{{ forloop.counter0 }}" type="text" size="32" value="{{ mx.mx }}"><br>
+ {% endfor %}
+ </td></tr>
+ </table>
+ <div id=mx>
+ <table border="0" width="100%">
+ <colgroup>
+ <col width="200">
+ <col width="*">
+ <tr> <td></td>
+ <td> <input name="new_priority" type="text" size="6" >
+ <input name="new_mx" type="text" size="32" >
+ </td></tr>
+ </table>
+ </div>
+ <table border="0" width="100%">
+ <colgroup>
+ <col width="200">
+ <col width="*">
+ <tr><td valign="top"> <b>A records</b><br>
+ {% if addresses %}
+ <a style="font-size:75%" href=# onclick="toggleField('address')">add a new MX record</a>
+ {% endif %}
+ </td>
+ <td>
+ {% if addresses %}
+ {% for address in addresses %}
+ <input name="address{{ forloop.counter0 }}" type="text" value="{{ address.ip_addr }}"><br>
+ {% endfor %}
+ </td></tr>
+ </table>
+ <div id=address>
+ <table border="0" width="100%">
+ <colgroup>
+ <col width="200">
+ <col width="*">
+ <tr> <td></td>
+ <td> <input name="new_address" type="text" >
+ </td></tr>
+ </table>
+ </div>
+ <table border="0" width="100%">
+ <colgroup>
+ <col width="200">
+ <col width="*">
+ {% else %}
+ <input name="new_address" type="text" value="none" >
+ {% endif %}
+ </td></tr>
+
+ <tr> <td valign="top"> <b>aux</b> (for information not generated by the database)</td>
+ <td> <textarea rows="20" cols="80" name="aux">{{ zone.aux }}</textarea></td></tr>
+ </td></tr>
+
+</table>
+<p><input type="submit" value="Submit">
+</form>
+
+{% endblock %}
+
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html
new file mode 100644
index 000000000..dcf9a3431
--- /dev/null
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html
@@ -0,0 +1,37 @@
+{% extends "base.html" %}
+
+{% block pagebanner %}
+ <div class="header">
+ <h2>Zones</h2>
+ <p>Hostbase generates DNS zone files for the following zones.
+ </div>
+ <br/>
+{% endblock %}
+
+{% block sidebar %}
+{% include "navbar" %}
+{% endblock %}
+
+{% block content %}
+
+{% if zones %}
+<table border="0" width="100%">
+ <colgroup>
+ <col width="200">
+ <col width="75">
+ <col width="50">
+ <col width="*">
+ <tr> <td><b>zone</b></td>
+ </tr>
+ {% for zone in zones %}
+ <tr> <td> {{ zone.zone }}</td>
+ <td> <a href="{{ zone.id }}">view</a> </td>
+ <td> <a href="{{ zone.id }}/edit">edit</a> </td>
+ </tr>
+ {% endfor %}
+</table>
+{% else %}
+There is no zone data currently in the database<br>
+{% endif %}
+{% endblock %}
+
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html
new file mode 100644
index 000000000..c7ac36402
--- /dev/null
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html
@@ -0,0 +1,66 @@
+{% extends "base.html" %}
+
+{% block pagebanner %}
+ <div class="header">
+ <h2>Zones</h2>
+ <p>Hostbase generates DNS zone files for the following zones.
+ </div>
+ <br/>
+{% endblock %}
+
+{% block sidebar %}
+{% include "navbar" %}
+{% endblock %}
+
+{% block content %}
+<table border="0" width="100%">
+ <colgroup>
+ <col width="200">
+ <col width="*">
+ <tr> <td> <b>zone</b></td>
+ <td> {{ zone.zone }}</td></tr>
+ <tr> <td> <b>serial</b></td>
+ <td> {{ zone.serial }}</td></tr>
+ <tr> <td> <b>admin</b></td>
+ <td> {{ zone.admin }}</td></tr>
+ <tr> <td> <b>primary_master</b></td>
+ <td> {{ zone.primary_master }}</td></tr>
+ <tr> <td> <b>expire</b></td>
+ <td> {{ zone.expire }}</td></tr>
+ <tr> <td> <b>retry</b></td>
+ <td> {{ zone.retry }}</td></tr>
+ <tr> <td> <b>refresh</b></td>
+ <td> {{ zone.refresh }}</td></tr>
+ <tr> <td> <b>ttl</b></td>
+ <td> {{ zone.ttl }}</td></tr>
+
+ <tr><td valign="top"> <b>nameservers</b></td>
+ <td>
+ {% for nameserver in nameservers %}
+ {{ nameserver.name }}<br>
+ {% endfor %}
+ </td></tr>
+ <tr><td valign="top"> <b>mxs</b></td>
+ <td>
+ {% for mx in mxs %}
+ {{ mx.priority }} {{ mx.mx }}<br>
+ {% endfor %}
+ </td></tr>
+ {% if addresses %}
+ <tr><td valign="top"> <b>A records</b></td>
+ <td>
+ {% for address in addresses %}
+ {{ address.ip_addr }}<br>
+ {% endfor %}
+ </td></tr>
+ {% endif %}
+
+ <tr> <td valign="top"> <b>aux</b></td>
+ <td>
+ {{ zone.aux|linebreaksbr }}
+ </td></tr>
+
+</table>
+<br><br>
+{% endblock %}
+