summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Hostbase/hostbase
diff options
context:
space:
mode:
authorKen Raffenetti <raffenet@mcs.anl.gov>2006-09-07 19:46:18 +0000
committerKen Raffenetti <raffenet@mcs.anl.gov>2006-09-07 19:46:18 +0000
commitd2407fc1c39c270dc2c2aa8d216706260ee2fe4d (patch)
tree2167fcb121b00de59081f2aac9caa6fda5821ca0 /src/lib/Server/Hostbase/hostbase
parentfbde04178a68b3e785785c7b793c2362f45cd457 (diff)
downloadbcfg2-d2407fc1c39c270dc2c2aa8d216706260ee2fe4d.tar.gz
bcfg2-d2407fc1c39c270dc2c2aa8d216706260ee2fe4d.tar.bz2
bcfg2-d2407fc1c39c270dc2c2aa8d216706260ee2fe4d.zip
updated for use with apache
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2222 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Hostbase/hostbase')
-rw-r--r--src/lib/Server/Hostbase/hostbase/models.py19
-rw-r--r--src/lib/Server/Hostbase/hostbase/views.py50
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/edit.html18
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/host.html8
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/results.html2
5 files changed, 75 insertions, 22 deletions
diff --git a/src/lib/Server/Hostbase/hostbase/models.py b/src/lib/Server/Hostbase/hostbase/models.py
index 6253a7b50..92bbb4b00 100644
--- a/src/lib/Server/Hostbase/hostbase/models.py
+++ b/src/lib/Server/Hostbase/hostbase/models.py
@@ -19,6 +19,25 @@ class Host(models.Model):
('operations','operations'),('guest','guest'),
('confidential','confidential'),('public','public')
)
+ WHATAMI_CHOICES = (
+ ('aix-3', 'aix-3'), ('aix-4', 'aix-4'),
+ ('aix-5', 'aix-5'), ('baytech', 'baytech'),
+ ('decserver', 'decserver'), ('dialup', 'dialup'),
+ ('dos', 'dos'), ('freebsd', 'freebsd'),
+ ('hpux', 'hpux'), ('irix-5', 'irix-5'),
+ ('irix-6', 'irix-6'), ('linux', 'linux'),
+ ('linux-2', 'linux-2'), ('linux-rh73', 'linux-rh73'),
+ ('linux-rh80', 'linux-rh80'), ('linux-sles80', 'linux-sles80'),
+ ('linux-sles80-64', 'linux-sles80-64'), ('linux-sles80-ia32', 'linux-sles80-ia32'),
+ ('linux-sles80-ia64', 'linux-sles80-ia64'), ('mac', 'mac'),
+ ('network', 'network'), ('next', 'next'),
+ ('none', 'none'), ('osf', 'osf'), ('printer', 'printer'),
+ ('robot', 'robot'), ('solaris-2', 'solaris-2'),
+ ('sun4', 'sun4'), ('unknown', 'unknown'), ('virtual', 'virtual'),
+ ('win31', 'win31'), ('win95', 'win95'),
+ ('winNTs', 'winNTs'), ('winNTw', 'winNTw'),
+ ('win2k', 'win2k'), ('winXP', 'winXP'), ('xterm', 'xterm')
+ )
hostname = models.CharField(maxlength=64)
whatami = models.CharField(maxlength=16)
netgroup = models.CharField(maxlength=32, choices=NETGROUP_CHOICES)
diff --git a/src/lib/Server/Hostbase/hostbase/views.py b/src/lib/Server/Hostbase/hostbase/views.py
index 1077cbede..299cc5829 100644
--- a/src/lib/Server/Hostbase/hostbase/views.py
+++ b/src/lib/Server/Hostbase/hostbase/views.py
@@ -6,12 +6,14 @@ Also has does form validation
__revision__ = 0.1
from django.http import HttpResponse, HttpResponseRedirect
-from models import *
+from hostbase.models import *
from Cheetah.Template import Template
from datetime import date
from django.db import connection
import re
+templatedir = '/usr/lib/python2.3/site-packages/Hostbase/hostbase/webtemplates'
+
attribs = ['hostname', 'whatami', 'netgroup', 'security_class', 'support',
'csi', 'printq', 'primary_user', 'administrator', 'location',
'comments', 'status']
@@ -88,11 +90,11 @@ def search(request):
cursor.execute(querystring)
results = cursor.fetchall()
- temp = Template(open('./hostbase/webtemplates/results.html').read())
+ temp = Template(open('%s/results.html' % templatedir).read())
temp.hosts = results
return HttpResponse(str(temp))
else:
- temp = Template(open('./hostbase/webtemplates/search.html').read())
+ temp = Template(open('%s/search.html' % templatedir).read())
temp.TYPE_CHOICES = Interface.TYPE_CHOICES
temp.DNS_CHOICES = Name.DNS_CHOICES
temp.yesno = [(1, 'yes'), (0, 'no')]
@@ -100,13 +102,13 @@ def search(request):
def look(request, host_id):
"""Displays general host information"""
- temp = Template(open('./hostbase/webtemplates/host.html').read())
+ temp = Template(open('%s/host.html' % templatedir).read())
hostdata = gethostdata(host_id)
temp = fill(temp, hostdata)
return HttpResponse(str(temp))
def dns(request, host_id):
- temp = Template(open('./hostbase/webtemplates/dns.html').read())
+ temp = Template(open('%s/dns.html' % templatedir).read())
hostdata = gethostdata(host_id, True)
temp = fill(temp, hostdata, True)
return HttpResponse(str(temp))
@@ -247,12 +249,12 @@ def edit(request, host_id):
host.save()
return HttpResponseRedirect('/hostbase/%s/' % host.id)
else:
- t = Template(open('./hostbase/webtemplates/errors.html').read())
+ t = Template(open('%s/errors.html' % templatedir).read())
t.failures = validate(request, False, host_id)
return HttpResponse(str(t))
# examine the check boxes for any changes
else:
- t = Template(open('./hostbase/webtemplates/edit.html').read())
+ t = Template(open('%s/edit.html' % templatedir).read())
hostdata = gethostdata(host_id)
t = fill(t, hostdata)
t.type_choices = Interface.TYPE_CHOICES
@@ -287,7 +289,7 @@ def confirm(request, item, item_id, host_id, name_id=None):
else:
return HttpResponseRedirect('/hostbase/%s/edit' % host_id)
else:
- temp = Template(open('./hostbase/webtemplates/confirm.html').read())
+ temp = Template(open('%s/confirm.html' % templatedir).read())
interface = None
ips = []
names = {}
@@ -375,7 +377,7 @@ def dnsedit(request, host_id):
name.mxs.add(mx)
return HttpResponseRedirect('/hostbase/%s/dns' % host_id)
else:
- temp = Template(open('./hostbase/webtemplates/dnsedit.html').read())
+ temp = Template(open('%s/dnsedit.html' % templatedir).read())
hostdata = gethostdata(host_id, True)
temp = fill(temp, hostdata, True)
temp.request = request
@@ -430,7 +432,7 @@ def new(request):
host.status = 'active'
host.save()
else:
- temp = Template(open('./hostbase/webtemplates/errors.html').read())
+ temp = Template(open('%s/errors.html' % templatedir).read())
temp.failures = validate(request, True)
return HttpResponse(str(temp))
if request.POST['mac_addr_new']:
@@ -553,7 +555,7 @@ def new(request):
host.save()
return HttpResponseRedirect('/hostbase/%s/' % host.id)
else:
- temp = Template(open('./hostbase/webtemplates/new.html').read())
+ temp = Template(open('%s/new.html' % templatedir).read())
temp.TYPE_CHOICES = Interface.TYPE_CHOICES
temp.NETGROUP_CHOICES = Host.NETGROUP_CHOICES
temp.CLASS_CHOICES = Host.CLASS_CHOICES
@@ -652,3 +654,29 @@ def validate(request, new=False, host_id=None):
if not failures:
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))
+
+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))
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html b/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html
index 71ca621a1..571fa3f5d 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html
@@ -101,13 +101,6 @@ function toggleInter(){
div#ipaddr${interface.id}{
display: none;
}
-<!--
-#for $ip in $ips[$interface.id]
-div#dns${ip.id}{
- display: none;
-}
-#end for
--->
#end for
div#interface{
display: none;
@@ -130,7 +123,16 @@ ok, submitted
<tr> <td> <b>hostname</b></td>
<td> <input name="hostname" type="text" value="$host.hostname"></td></tr>
<tr> <td> <b>whatami</b></td>
- <td> <input name="whatami" type="text" value="$host.whatami"></td></tr>
+ <td>
+ <select name="whatami">
+ #for $choice in $host.WHATAMI_CHOICES
+ #if $host.whatami == $choice[0]
+ <option value="$choice[0]" selected="selected">$choice[1]
+ #else
+ <option value="$choice[0]">$choice[1]
+ #end if
+ #end for
+ </select></td></tr>
<tr> <td> <b>netgroup</b></td>
<td>
<select name="netgroup">
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html
index a9ec9014b..43baa14c6 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html
@@ -131,8 +131,12 @@
<td> $ip.ip_addr</td></tr>
#end for
#end for
- <tr> <td> <b>comments</b></td>
- <td> $host.comments</td></tr>
+ <tr> <td valign="top"> <b>comments</b></td>
+ <td>
+ #for $line in $host.comments.split("\n")
+ $line<br>
+ #end for
+ </td></tr>
</table>
<a style="font-size:75%" href="/hostbase/$host.id/dns/">see detailed DNS information for this host</a>
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/results.html b/src/lib/Server/Hostbase/hostbase/webtemplates/results.html
index efae1143f..470883e61 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/results.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/results.html
@@ -99,7 +99,7 @@
<td> inactive </td>
#end if
<td> <a href="$host[1]">view</a> </td>
- <td> <a href="$host[1]/edit.html">edit</a> </td>
+ <td> <a href="$host[1]/edit">edit</a> </td>
</tr>
#end for
</table>