summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Hostbase/hostbase
diff options
context:
space:
mode:
authorKen Raffenetti <raffenet@mcs.anl.gov>2006-10-10 15:23:17 +0000
committerKen Raffenetti <raffenet@mcs.anl.gov>2006-10-10 15:23:17 +0000
commit60030f92fbdee28cc06f59c65654cf7a9c6e70f4 (patch)
treee921901db4b747aeb512e7f21db735aa659d0f91 /src/lib/Server/Hostbase/hostbase
parent11636a6e5ad02928b150676be21f090795374153 (diff)
downloadbcfg2-60030f92fbdee28cc06f59c65654cf7a9c6e70f4.tar.gz
bcfg2-60030f92fbdee28cc06f59c65654cf7a9c6e70f4.tar.bz2
bcfg2-60030f92fbdee28cc06f59c65654cf7a9c6e70f4.zip
minor updates to plugin and templates
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2427 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Hostbase/hostbase')
-rw-r--r--src/lib/Server/Hostbase/hostbase/views.py33
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/edit.html3
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/new.html4
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/remove.html88
4 files changed, 110 insertions, 18 deletions
diff --git a/src/lib/Server/Hostbase/hostbase/views.py b/src/lib/Server/Hostbase/hostbase/views.py
index 8da790d5f..b49af90c7 100644
--- a/src/lib/Server/Hostbase/hostbase/views.py
+++ b/src/lib/Server/Hostbase/hostbase/views.py
@@ -10,11 +10,12 @@ from Hostbase.hostbase.models import *
from datetime import date
from django.db import connection
from django.shortcuts import render_to_response
+from Hostbase import settings
import re
attribs = ['hostname', 'whatami', 'netgroup', 'security_class', 'support',
'csi', 'printq', 'primary_user', 'administrator', 'location',
- 'comments', 'status']
+ 'status']
zoneattribs = ['zone', 'admin', 'primary_master', 'expire', 'retry',
'refresh', 'ttl', 'aux']
@@ -180,7 +181,9 @@ def edit(request, host_id):
# likely use a helper fucntion
for attrib in attribs:
if request.POST.has_key(attrib):
- host.__dict__[attrib] = request.POST[attrib]
+ host.__dict__[attrib] = request.POST[attrib].lower()
+ if request.POST.has_key('comments'):
+ host.comments = request.POST['comments']
if len(request.POST['expiration_date'].split("-")) == 3:
(year, month, day) = request.POST['expiration_date'].split("-")
host.expiration_date = date(int(year), int(month), int(day))
@@ -212,7 +215,7 @@ def edit(request, host_id):
name.name = newname
name.save()
if request.POST['%dip_addr' % inter.id]:
- mx, created = MX.objects.get_or_create(priority=30, mx='mailgw.mcs.anl.gov')
+ mx, created = MX.objects.get_or_create(priority=settings.PRIORITY, mx=settings.DEFAULT_MX)
if created:
mx.save()
new_ip = IP(interface=inter, num=len(ips),
@@ -243,7 +246,7 @@ def edit(request, host_id):
hdwr_type=request.POST['hdwr_type_new'])
new_inter.save()
if request.POST['mac_addr_new'] and request.POST['ip_addr_new']:
- mx, created = MX.objects.get_or_create(priority=30, mx='mailgw.mcs.anl.gov')
+ mx, created = MX.objects.get_or_create(priority=settings.PRIORITY, mx=settings.DEFAULT_MX)
if created:
mx.save()
new_ip = IP(interface=new_inter, num=0,
@@ -268,7 +271,7 @@ def edit(request, host_id):
name.save()
name.mxs.add(mx)
if request.POST['ip_addr_new'] and not request.POST['mac_addr_new']:
- mx, created = MX.objects.get_or_create(priority=30, mx='mailgw.mcs.anl.gov')
+ mx, created = MX.objects.get_or_create(priority=settings.PRIORITY, mx=settings.DEFAULT_MX)
if created:
mx.save()
new_inter = Interface(host=host, mac_addr="",
@@ -478,7 +481,7 @@ def new(request):
Data is validated before committed to the database"""
if request.GET.has_key('sub'):
try:
- Host.objects.get(hostname=request.POST['hostname'])
+ Host.objects.get(hostname=request.POST['hostname'].lower())
return render_to_response('errors.html',
{'failures': ['%s already exists in hostbase' % request.POST['hostname']]})
except:
@@ -491,7 +494,9 @@ def new(request):
host.dhcp = request.POST.has_key('dhcp')
for attrib in attribs:
if request.POST.has_key(attrib):
- host.__dict__[attrib] = request.POST[attrib]
+ host.__dict__[attrib] = request.POST[attrib].lower()
+ if request.POST.has_key('comments'):
+ host.comments = request.POST['comments']
if request.POST.has_key('expiration_date'):
host.__dict__['expiration_date'] = date(2000, 1, 1)
host.status = 'active'
@@ -508,7 +513,7 @@ def new(request):
new_ip = IP(interface=new_inter,
num=0, ip_addr=request.POST['ip_addr_new'])
new_ip.save()
- mx, created = MX.objects.get_or_create(priority=30, mx='mailgw.mcs.anl.gov')
+ mx, created = MX.objects.get_or_create(priority=settings.PRIORITY, mx=settings.DEFAULT_MX)
if created:
mx.save()
new_name = "-".join([host.hostname.split(".")[0],
@@ -536,7 +541,7 @@ def new(request):
new_ip = IP(interface=new_inter, num=0,
ip_addr=request.POST['ip_addr_new1'])
new_ip.save()
- mx, created = MX.objects.get_or_create(priority=30, mx='mailgw.mcs.anl.gov')
+ mx, created = MX.objects.get_or_create(priority=settings.PRIORITY, mx=settings.DEFAULT_MX)
if created:
mx.save()
new_name = "-".join([host.hostname.split(".")[0],
@@ -566,7 +571,7 @@ def new(request):
new_ip = IP(interface=new_inter, num=0,
ip_addr=request.POST['ip_addr_new2'])
new_ip.save()
- mx, created = MX.objects.get_or_create(priority=30, mx='mailgw.mcs.anl.gov')
+ mx, created = MX.objects.get_or_create(priority=settings.PRIORITY, mx=settings.DEFAULT_MX)
if created:
mx.save()
new_name = "-".join([host.hostname.split(".")[0],
@@ -595,7 +600,7 @@ def new(request):
new_ip = IP(interface=new_inter, num=0,
ip_addr=request.POST['ip_addr_new2'])
new_ip.save()
- mx, created = MX.objects.get_or_create(priority=30, mx='mailgw.mcs.anl.gov')
+ mx, created = MX.objects.get_or_create(priority=settings.PRIORITY, mx=settings.DEFAULT_MX)
if created:
mx.save()
new_name = "-".join([host.hostname.split(".")[0],
@@ -627,7 +632,7 @@ def new(request):
'WHATAMI_CHOICES': Host.WHATAMI_CHOICES})
def remove(request, host_id):
- host = Host.GET.objects.get(id=host_id)
+ host = Host.objects.get(id=host_id)
if request.has_key('sub'):
for interface in host.interface_set.all():
for ip in interface.ip_set.all():
@@ -637,7 +642,7 @@ def remove(request, host_id):
interface.ip_set.all().delete()
interface.delete()
host.delete()
- return HttpResponseRedirect('/hostbase/%s/' % host_id)
+ return HttpResponseRedirect('/hostbase/')
else:
"""Displays general host information"""
interfaces = []
@@ -678,7 +683,7 @@ def validate(request, new=False, host_id=None):
and request.POST['administrator']):
failures.append('administrator')
- locationregex = re.compile('^[0-9]{3}-[a-z][0-9]{3}$|none|bmr|cave|dsl|evl|mobile|offsite|mural|activespaces')
+ locationregex = re.compile('^[0-9]{3}-[a-zA-Z][0-9]{3}$|none|bmr|cave|dsl|evl|mobile|offsite|mural|activespaces')
if not (request.POST['location']
and locationregex.match(request.POST['location'])):
failures.append('location')
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html b/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html
index efc308def..0785b64e8 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html
@@ -46,13 +46,12 @@ 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> {{ host.hostname }}</td></tr>
+ <td> <input name="hostname" value="{{ host.hostname }}"></td></tr>
<tr> <td> <b>whatami</b></td>
<td>
<select name="whatami">
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/new.html b/src/lib/Server/Hostbase/hostbase/webtemplates/new.html
index 949afc611..bcec42404 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/new.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/new.html
@@ -62,9 +62,9 @@
<td>
<input type="checkbox" name="outbound_smtp"></td></tr>
<tr> <td> <b>primary_user</b></td>
- <td> <input name="primary_user" type="text" size="32" ></td></tr>
+ <td> <input name="primary_user" type="text" size="32" > (email address)</td></tr>
<tr> <td> <b>administrator</b></td>
- <td> <input name="administrator" type="text" size="32" ></td></tr>
+ <td> <input name="administrator" type="text" size="32" > (email address)</td></tr>
<tr> <td> <b>location</b></td>
<td> <input name="location" type="text" ></td></tr>
<tr> <td> <b>expiration_date</b></td>
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/remove.html b/src/lib/Server/Hostbase/hostbase/webtemplates/remove.html
new file mode 100644
index 000000000..19c73b4f9
--- /dev/null
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/remove.html
@@ -0,0 +1,88 @@
+{% extends "base.html" %}
+
+{% block pagebanner %}
+ <div class="header">
+ <h2>Are you sure you want to remove {{ host.hostname }}?</h2>
+ </div>
+ <br/>
+{% endblock %}
+
+{% block sidebar %}
+{% 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>
+ <li><a href="dns/edit/" class="sidebar">edit dns info</a></li>
+</ul>
+{% endblock %}
+
+{% block content %}
+
+<table border="0" width="100%">
+ <colgroup>
+ <col width="150">
+ <col width="*">
+ <tr> <td> <b>hostname</b></td>
+ <td> {{ host.hostname }}</td></tr>
+ <tr> <td> <b>whatami</b></td>
+ <td> {{ host.whatami }}</td></tr>
+ <tr> <td> <b>netgroup</b></td>
+ <td> {{ host.netgroup }}</td></tr>
+ <tr> <td> <b>class</b></td>
+ <td> {{ host.security_class }}</td></tr>
+ <tr> <td> <b>support</b></td>
+ <td> {{ host.support }}</td></tr>
+ <tr> <td> <b>csi</b></td>
+ <td> {{ host.csi }}</td></tr>
+ <tr> <td> <b>printq</b></td>
+ <td> {{ host.printq }}</td></tr>
+ <tr> <td> <b>dhcp</b></td>
+ {% if host.dhcp %}
+ <td> y </td></tr>
+ {% else %}
+ <td> n </td></tr>
+ {% endif %}
+ <tr> <td> <b>outbound_smtp</b></td>
+ {% if host.outbound_smtp %}
+ <td> y </td></tr>
+ {% else %}
+ <td> n </td></tr>
+ {% endif %}
+ <tr> <td> <b>primary_user</b></td>
+ <td> {{ host.primary_user }}</td></tr>
+ <tr> <td> <b>administrator</b></td>
+ <td> {{ host.administrator }}</td></tr>
+ <tr> <td> <b>location</b></td>
+ <td> {{ host.location }}</td></tr>
+ <tr> <td> <b>expiration_date</b></td>
+ <td> {{ host.expiration_date }}</td></tr>
+ {% for interface in interfaces %}
+ <tr> <td><br><b>Interface</b></td>
+ {% ifnotequal interface.0.hdwr_type 'no' %}
+ <td><br>{{ interface.0.hdwr_type }}</td></tr>
+ {% endifnotequal %}
+ <tr> <td> <b>mac_addr</b></td>
+ <td> {{ interface.0.mac_addr }}</b></td></tr>
+ {% for ip in interface.1 %}
+ <tr> <td> <b>ip_addr</b></td>
+ <td> {{ ip.ip_addr }}</td></tr>
+ {% endfor %}
+ {% endfor %}
+ <tr> <td valign="top"> <b>comments</b></td>
+ <td>
+ {{ host.comments|linebreaksbr }}<br>
+ </td></tr>
+
+</table>
+<a style="font-size:75%" href="/hostbase/{{ host.id }}/dns/">see detailed DNS information for this host</a>
+<br><br>
+this host is {{ host.status }}<br>
+last update on {{ host.last }}<br>
+
+<form name="input" action="remove.html?sub=true" method="post">
+<input type="submit" value="remove">
+<input type="reset" value="cancel" onclick="history.back()">
+</form>
+
+{% endblock %}
+