summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRene Martin <rene@minicroso.(none)>2010-04-04 19:02:25 +0100
committerSol Jerome <solj@ices.utexas.edu>2010-04-08 09:03:39 -0500
commit0153af6e2ed6671ea2ee013a7f551ba7c61a5c88 (patch)
treec118c3603ace9e78739f79601a7fa2016240a8a3 /src
parent66f08b0a6dd519009c6d2094421498e4d446114e (diff)
downloadbcfg2-0153af6e2ed6671ea2ee013a7f551ba7c61a5c88.tar.gz
bcfg2-0153af6e2ed6671ea2ee013a7f551ba7c61a5c88.tar.bz2
bcfg2-0153af6e2ed6671ea2ee013a7f551ba7c61a5c88.zip
Trying to commit all my work
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Hostbase/hostbase/models.py75
-rw-r--r--src/lib/Server/Hostbase/hostbase/views.py201
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/base.html4
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/host.html4
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/zonenew.html8
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/zones.html5
-rw-r--r--src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html6
-rw-r--r--src/lib/Server/Hostbase/ldapauth.py2
-rw-r--r--src/lib/Server/Hostbase/settings.py39
-rw-r--r--src/lib/Server/Hostbase/urls.py54
10 files changed, 157 insertions, 241 deletions
diff --git a/src/lib/Server/Hostbase/hostbase/models.py b/src/lib/Server/Hostbase/hostbase/models.py
index eaeecd48d..529f420d2 100644
--- a/src/lib/Server/Hostbase/hostbase/models.py
+++ b/src/lib/Server/Hostbase/hostbase/models.py
@@ -38,21 +38,21 @@ class Host(models.Model):
('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)
- security_class = models.CharField('class', maxlength=16)
- support = models.CharField(maxlength=8, choices=SUPPORT_CHOICES)
- csi = models.CharField(maxlength=32, blank=True)
- printq = models.CharField(maxlength=32, blank=True)
+ hostname = models.CharField(max_length=64)
+ whatami = models.CharField(max_length=16)
+ netgroup = models.CharField(max_length=32, choices=NETGROUP_CHOICES)
+ security_class = models.CharField('class', max_length=16)
+ support = models.CharField(max_length=8, choices=SUPPORT_CHOICES)
+ csi = models.CharField(max_length=32, blank=True)
+ printq = models.CharField(max_length=32, blank=True)
outbound_smtp = models.BooleanField()
primary_user = models.EmailField()
administrator = models.EmailField(blank=True)
- location = models.CharField(maxlength=16)
+ location = models.CharField(max_length=16)
comments = models.TextField(blank=True)
expiration_date = models.DateField(null=True, blank=True)
last = models.DateField(auto_now=True, auto_now_add=True)
- status = models.CharField(maxlength=7, choices=STATUS_CHOICES)
+ status = models.CharField(max_length=7, choices=STATUS_CHOICES)
dirty = models.BooleanField()
class Admin:
@@ -65,12 +65,17 @@ class Host(models.Model):
class Interface(models.Model):
TYPE_CHOICES = (
('eth', 'ethernet'), ('wl', 'wireless'), ('virtual', 'virtual'), ('myr', 'myr'),
- ('mgmt', 'mgmt'), ('tape', 'tape'), ('fe', 'fe'), ('ge', 'ge'), ('virtual', 'virtual')
+ ('mgmt', 'mgmt'), ('tape', 'tape'), ('fe', 'fe'), ('ge', 'ge'),
)
- host = models.ForeignKey(Host, edit_inline=models.TABULAR, num_in_admin=2)
- mac_addr = models.CharField(maxlength=32, core=True)
- hdwr_type = models.CharField('type', maxlength=16, choices=TYPE_CHOICES,
- radio_admin=True, blank=True)
+ # FIXME: The new admin interface has change a lot.
+ #host = models.ForeignKey(Host, edit_inline=models.TABULAR, num_in_admin=2)
+ host = models.ForeignKey(Host)
+ # FIXME: The new admin interface has change a lot.
+ #mac_addr = models.CharField(max_length=32, core=True)
+ mac_addr = models.CharField(max_length=32)
+ hdwr_type = models.CharField('type', max_length=16, choices=TYPE_CHOICES, blank=True)
+ # FIXME: The new admin interface has change a lot.
+ # radio_admin=True, blank=True)
dhcp = models.BooleanField()
def __str__(self):
@@ -81,9 +86,11 @@ class Interface(models.Model):
search_fields = ['mac_addr']
class IP(models.Model):
- interface = models.ForeignKey(Interface,
- edit_inline=models.TABULAR, num_in_admin=1)
- ip_addr = models.IPAddressField(core=True)
+ interface = models.ForeignKey(Interface)
+ # FIXME: The new admin interface has change a lot.
+ # edit_inline=models.TABULAR, num_in_admin=1)
+ #ip_addr = models.IPAddressField(core=True)
+ ip_addr = models.IPAddressField()
def __str__(self):
return self.ip_addr
@@ -96,7 +103,9 @@ class IP(models.Model):
class MX(models.Model):
priority = models.IntegerField(blank=True)
- mx = models.CharField(maxlength=64, core=True, blank=True)
+ # FIXME: The new admin interface has change a lot.
+ #mx = models.CharField(max_length=64, blank=True, core=True)
+ mx = models.CharField(max_length=64, blank=True)
def __str__(self):
return (" ".join([str(self.priority), self.mx]))
@@ -109,9 +118,13 @@ class Name(models.Model):
('global','global'),('internal','ANL internal'),
('private','private')
)
- ip = models.ForeignKey(IP, edit_inline=models.TABULAR, num_in_admin=1)
- name = models.CharField(maxlength=64, core=True)
- dns_view = models.CharField(maxlength=16, choices=DNS_CHOICES)
+ # FIXME: The new admin interface has change a lot.
+ #ip = models.ForeignKey(IP, edit_inline=models.TABULAR, num_in_admin=1)
+ ip = models.ForeignKey(IP)
+ # FIXME: The new admin interface has change a lot.
+ #name = models.CharField(max_length=64, core=True)
+ name = models.CharField(max_length=64)
+ dns_view = models.CharField(max_length=16, choices=DNS_CHOICES)
only = models.BooleanField(blank=True)
mxs = models.ManyToManyField(MX)
@@ -122,8 +135,12 @@ class Name(models.Model):
pass
class CName(models.Model):
- name = models.ForeignKey(Name, edit_inline=models.TABULAR, num_in_admin=1)
- cname = models.CharField(maxlength=64, core=True)
+ # FIXME: The new admin interface has change a lot.
+ #name = models.ForeignKey(Name, edit_inline=models.TABULAR, num_in_admin=1)
+ name = models.ForeignKey(Name)
+ # FIXME: The new admin interface has change a lot.
+ #cname = models.CharField(max_length=64, core=True)
+ cname = models.CharField(max_length=64)
def __str__(self):
return self.cname
@@ -132,7 +149,7 @@ class CName(models.Model):
pass
class Nameserver(models.Model):
- name = models.CharField(maxlength=64, blank=True)
+ name = models.CharField(max_length=64, blank=True)
def __str__(self):
return self.name
@@ -150,10 +167,10 @@ class ZoneAddress(models.Model):
pass
class Zone(models.Model):
- zone = models.CharField(maxlength=64)
+ zone = models.CharField(max_length=64)
serial = models.IntegerField()
- admin = models.CharField(maxlength=64)
- primary_master = models.CharField(maxlength=64)
+ admin = models.CharField(max_length=64)
+ primary_master = models.CharField(max_length=64)
expire = models.IntegerField()
retry = models.IntegerField()
refresh = models.IntegerField()
@@ -170,7 +187,7 @@ class Zone(models.Model):
pass
class Log(models.Model):
- hostname = models.CharField(maxlength=64)
+ hostname = models.CharField(max_length=64)
date = models.DateTimeField(auto_now=True, auto_now_add=True)
log = models.TextField()
@@ -178,7 +195,7 @@ class Log(models.Model):
return self.hostname
class ZoneLog(models.Model):
- zone = models.CharField(maxlength=64)
+ zone = models.CharField(max_length=64)
date = models.DateTimeField(auto_now=True, auto_now_add=True)
log = models.TextField()
diff --git a/src/lib/Server/Hostbase/hostbase/views.py b/src/lib/Server/Hostbase/hostbase/views.py
index a4bddb857..075497174 100644
--- a/src/lib/Server/Hostbase/hostbase/views.py
+++ b/src/lib/Server/Hostbase/hostbase/views.py
@@ -8,7 +8,7 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout
-
+from django.template import RequestContext
from Bcfg2.Server.Hostbase.hostbase.models import *
from datetime import date
from django.db import connection
@@ -34,11 +34,6 @@ dispatch = {'mac_addr':'i.mac_addr LIKE \'%%%%%s%%%%\'',
'hdwr_type':'i.hdwr_type = \'%s\'',
'dhcp':'i.dhcp = \'%s\''}
-def index(request):
- """rediredct to /hostbase/"""
- return render_to_response('index.html',
- {})
-
def search(request):
"""Search for hosts in the database
If more than one field is entered, logical AND is used
@@ -85,25 +80,15 @@ def search(request):
return render_to_response('results.html',
{'hosts': results,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
else:
return render_to_response('search.html',
{'TYPE_CHOICES': Interface.TYPE_CHOICES,
'DNS_CHOICES': Name.DNS_CHOICES,
'yesno': [(1, 'yes'), (0, 'no')],
- 'logged_in': request.session.get('_auth_user_id', False)})
-
-
-def look(request, host_id):
- """Displays general host information"""
- host = Host.objects.get(id=host_id)
- interfaces = []
- for interface in host.interface_set.all():
- interfaces.append([interface, interface.ip_set.all()])
- return render_to_response('host.html',
- {'host': host,
- 'interfaces': interfaces,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def logs(request, host_id):
"""Displays general host information"""
@@ -112,14 +97,16 @@ def logs(request, host_id):
return render_to_response('logviewer.html',
{'hostname': host.hostname,
'logs': logs,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def printlog(request, host_id, log_id):
"""Displays general host information"""
log = Log.objects.get(id=log_id)
return render_to_response('log.html',
{'text': log.log,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def dns(request, host_id):
host = Host.objects.get(id=host_id)
@@ -139,7 +126,8 @@ def dns(request, host_id):
'info': info,
'cnames': cnames,
'mxs': mxs,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def gethostdata(host_id, dnsdata=False):
@@ -343,7 +331,8 @@ def edit(request, host_id):
else:
return render_to_response('errors.html',
{'failures': errors,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
else:
host = Host.objects.get(id=host_id)
interfaces = []
@@ -353,7 +342,8 @@ def edit(request, host_id):
{'host': host,
'interfaces': interfaces,
'TYPE_CHOICES': Interface.TYPE_CHOICES,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def confirm(request, item, item_id, host_id=None, name_id=None, zone_id=None):
"""Asks if the user is sure he/she wants to remove an item"""
@@ -449,7 +439,8 @@ def confirm(request, item, item_id, host_id=None, name_id=None, zone_id=None):
'nameserver': nameserver,
'address': address,
'zone_id': zone_id,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def dnsedit(request, host_id):
"""Edits specific DNS information
@@ -545,7 +536,8 @@ def dnsedit(request, host_id):
'request': request,
'interfaces': interfaces,
'DNS_CHOICES': Name.DNS_CHOICES,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def new(request):
"""Function for creating a new host in hostbase
@@ -555,14 +547,16 @@ def new(request):
Host.objects.get(hostname=request.POST['hostname'].lower())
return render_to_response('errors.html',
{'failures': ['%s already exists in hostbase' % request.POST['hostname']],
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
except:
pass
if not validate(request, True):
if not request.POST['ip_addr_new'] and not request.POST['ip_addr_new2']:
return render_to_response('errors.html',
{'failures': ['ip_addr: You must enter an ip address'],
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
host = Host()
# this is the stuff that validate() should take care of
# examine the check boxes for any changes
@@ -581,7 +575,8 @@ def new(request):
else:
return render_to_response('errors.html',
{'failures': validate(request, True),
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
if request.POST['mac_addr_new']:
new_inter = Interface(host=host,
@@ -709,7 +704,8 @@ def new(request):
'CLASS_CHOICES': Host.CLASS_CHOICES,
'SUPPORT_CHOICES': Host.SUPPORT_CHOICES,
'WHATAMI_CHOICES': Host.WHATAMI_CHOICES,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def copy(request, host_id):
"""Function for creating a new host in hostbase
@@ -719,14 +715,16 @@ def copy(request, host_id):
Host.objects.get(hostname=request.POST['hostname'].lower())
return render_to_response('errors.html',
{'failures': ['%s already exists in hostbase' % request.POST['hostname']],
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
except:
pass
if not validate(request, True):
if not request.POST['ip_addr_new'] and not request.POST['ip_addr_new2']:
return render_to_response('errors.html',
{'failures': ['ip_addr: You must enter an ip address'],
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
host = Host()
# this is the stuff that validate() should take care of
# examine the check boxes for any changes
@@ -745,7 +743,8 @@ def copy(request, host_id):
else:
return render_to_response('errors.html',
{'failures': validate(request, True),
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
if request.POST['mac_addr_new']:
new_inter = Interface(host=host,
@@ -875,7 +874,8 @@ def copy(request, host_id):
'CLASS_CHOICES': Host.CLASS_CHOICES,
'SUPPORT_CHOICES': Host.SUPPORT_CHOICES,
'WHATAMI_CHOICES': Host.WHATAMI_CHOICES,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def remove(request, host_id):
host = Host.objects.get(id=host_id)
@@ -897,7 +897,8 @@ def remove(request, host_id):
return render_to_response('remove.html',
{'host': host,
'interfaces': interfaces,
- 'logged_in': request.session.get('_auth_user_id', False)})
+ 'logged_in': request.session.get('_auth_user_id', False)},
+ context_instance = RequestContext(request))
def validate(request, new=False, host_id=None):
"""Function for checking form data"""
@@ -988,130 +989,6 @@ def validate(request, new=False, host_id=None):
return 0
return failures
-def zones(request):
- zones = Zone.objects.all()
- return render_to_response('zones.html',
- {'zones': zones,
- 'logged_in': request.session.get('_auth_user_id', False)})
-
-def zoneview(request, zone_id):
- zone = Zone.objects.get(id=zone_id)
- return render_to_response('zoneview.html',
- {'zone': zone,
- 'nameservers': zone.nameservers.all(),
- 'mxs': zone.mxs.all(),
- 'addresses': zone.addresses.all(),
- 'logged_in': request.session.get('_auth_user_id', False)
- })
-
-def zonenew(request):
- manipulator = Zone.AddManipulator()
- nsmanipulator = Nameserver.AddManipulator()
- mxmanipulator = MX.AddManipulator()
- addressmanipulator = ZoneAddress.AddManipulator()
-
- if request.method == 'POST':
- new_data = request.POST.copy()
- new_data['serial'] = '1'
- errors = manipulator.get_validation_errors(new_data)
- errors.update(check_zone_errors(request.POST.copy()))
- if errors:
- return render_to_response('errors.html', {'failures': errors})
- else:
- do_zone_add(manipulator, new_data)
- return HttpResponseRedirect('/hostbase/zones/')
- else:
- errors = new_data = {}
-
- form = forms.FormWrapper(manipulator, {}, {})
- nsform = forms.FormWrapper(nsmanipulator, {}, {})
- mxform = forms.FormWrapper(mxmanipulator, {}, {})
- aform = forms.FormWrapper(addressmanipulator, {}, {})
- context = {'form': form,
- 'nsform': nsform,
- 'mxform': mxform,
- 'aform': aform,
- }
- return render_to_response('zonenew.html', context)
-
-def zoneedit(request, zone_id):
- manipulator = Zone.ChangeManipulator(zone_id)
- nsaddmanipulator = Nameserver.AddManipulator()
- mxaddmanipulator = MX.AddManipulator()
- addressaddmanipulator = ZoneAddress.AddManipulator()
- zone = manipulator.original_object
- nsmanipulators = [Nameserver.ChangeManipulator(ns.id)
- for ns in zone.nameservers.all()]
- mxmanipulators = [MX.ChangeManipulator(mx.id) for mx in zone.mxs.all()]
- addressmanipulators = [ZoneAddress.ChangeManipulator(address.id)
- for address in zone.addresses.all()]
- if request.method == 'POST':
- new_data = request.POST.copy()
- new_data['serial'] = str(zone.serial)
- errors = manipulator.get_validation_errors(new_data)
- errors.update(check_zone_errors(request.POST.copy()))
- if not errors:
- do_zone_add(manipulator, new_data)
- return HttpResponseRedirect('/hostbase/zones/%s' % zone.id)
- else:
- return render_to_response('errors.html', {'failures': errors})
- else:
- errors = {}
- new_data = manipulator.flatten_data()
-
- form = forms.FormWrapper(manipulator, new_data, errors)
- nsforms = [forms.FormWrapper(nsm, nsm.flatten_data(), {}) for nsm in nsmanipulators]
- mxforms = [forms.FormWrapper(mxm, mxm.flatten_data(), {}) for mxm in mxmanipulators]
- aforms = [forms.FormWrapper(am, am.flatten_data(), {}) for am in addressmanipulators]
- context = {'form': form,
- 'nsforms': nsforms,
- 'mxforms': mxforms,
- 'aforms': aforms,
- 'nsadd': forms.FormWrapper(nsaddmanipulator, {}, {}),
- 'mxadd': forms.FormWrapper(mxaddmanipulator, {}, {}),
- 'addadd': forms.FormWrapper(addressaddmanipulator, {}, {}),
- 'zone_id': zone_id,
- 'zone': zone.zone
- }
- return render_to_response('zoneedit.html', context)
-
-def do_zone_add(manipulator, new_data):
- manipulator.do_html2python(new_data)
- zone = manipulator.save(new_data)
-## text = ''
-## for field in new_data:
-## if not (field == 'nameservers' or field == 'mxs' or
-## field == 'priority' or field == 'ip_addr' or field == 'mx'):
-## text += "%-20s -> %s" % (field, new_data[field])
-## log = ZoneLog(zone=new_data['zone'], text)
-## log.save()
- for name in new_data.getlist('name'):
- if name:
- ns, created = Nameserver.objects.get_or_create(name=name)
- zone.nameservers.add(ns)
- priorities = new_data.getlist('priority')
- for mx in new_data.getlist('mx'):
- if priorities[0] and mx:
- mxrecord, created = MX.objects.get_or_create(priority=priorities.pop(0), mx=mx)
- zone.mxs.add(mxrecord)
- for address in new_data.getlist('ip_addr'):
- if address:
- arecord, created = ZoneAddress.objects.get_or_create(ip_addr=address)
- zone.addresses.add(arecord)
-
-def check_zone_errors(new_data):
- errors = {}
- for ns in new_data.getlist('name'):
- errors.update(Nameserver.AddManipulator().get_validation_errors({'name':ns}))
- for addr in new_data.getlist('ip_addr'):
- errors.update(ZoneAddress.AddManipulator().get_validation_errors({'ip_addr':addr}))
- priorities = new_data.getlist('priority')
- count = 0
- for mx in new_data.getlist('mx'):
- errors.update(MX.AddManipulator().get_validation_errors({'mx':mx, 'priority':priorities[count]}))
- count += 1
- return errors
-
def do_log(text, attribute, previous, new):
if previous != new:
text += "%-20s%-20s -> %s\n" % (attribute, previous, new)
@@ -1129,8 +1006,8 @@ dnsedit = login_required(dnsedit)
new = login_required(new)
copy = login_required(copy)
remove = login_required(remove)
-zoneedit = login_required(zoneedit)
-zonenew = login_required(zonenew)
+#zoneedit = login_required(zoneedit)
+#zonenew = login_required(zonenew)
## uncomment the lines below this point to restrict access to all of hostbase
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/base.html b/src/lib/Server/Hostbase/hostbase/webtemplates/base.html
index 537535663..1d7c5565b 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/base.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/base.html
@@ -3,8 +3,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>{% block title %}BCFG2 - Hostbase{% endblock %}</title>
- <link rel="stylesheet" type="text/css" href="/site_media/boxypastel.css" />
- <link rel="stylesheet" type="text/css" href="/site_media/base.css" />
+ <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}/boxypastel.css" />
+ <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}/base.css" />
<!--<script type="text/javascript" src="http://hostbase.mcs.anl.gov/site_media/main.js"> -->
{% block extra_header_info %}{% endblock %}
</head>
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html
index a8fa6a2cd..73792e0e0 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html
@@ -52,7 +52,7 @@
<td> {{ host.location }}</td></tr>
<tr> <td> <b>expiration_date</b></td>
<td> {{ host.expiration_date }}</td></tr>
- {% for interface in interfaces %}
+ {% for interface in host.inserface_set.all %}
<tr> <td><br><b>Interface</b></td>
{% ifnotequal interface.0.hdwr_type 'no' %}
<td><br>{{ interface.0.hdwr_type }}</td></tr>
@@ -77,4 +77,4 @@
this host is {{ host.status }}<br>
last update on {{ host.last }}<br>
-{% endblock %} \ No newline at end of file
+{% endblock %}
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zonenew.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zonenew.html
index af6ae2422..8a31e0dde 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/zonenew.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zonenew.html
@@ -15,7 +15,9 @@
{% block content %}
<form name="zonedata" action="" method="post">
- <fieldset class="module aligned ()">
+ <fieldset class="module aligned ()">
+ {{ form.as_p}}
+<!--
<label for="id_zone">zone:</label>{{ form.zone }}<br>
<label for="id_admin">admin:</label>{{ form.admin }}<br>
<label for="id_primary_master">primary_master:</label>{{ form.primary_master }}<br>
@@ -33,7 +35,9 @@
<label for="id_mx">ip address:</label>{{ aform.ip_addr }}<br>
<label for="id_aux">aux:
(information not generated from Hostbase)</label>{{ form.aux }}<br>
-<p><input type="submit" value="Submit">
+--!>
+ <p><input type="submit" value="Submit">
+ </fieldset>
</form>
{% endblock %}
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html
index b8bbc9d90..405b748f9 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html
@@ -14,8 +14,7 @@
{% endblock %}
{% block content %}
-
-{% if zones %}
+{% if zone_list %}
<table border="0" width="100%">
<colgroup>
<col width="200">
@@ -24,7 +23,7 @@
<col width="*">
<tr> <td><b>zone</b></td>
</tr>
- {% for zone in zones|dictsort:"zone" %}
+ {% for zone in zone_list|dictsort:"zone" %}
<tr> <td> {{ zone.zone }}</td>
<td> <a href="{{ zone.id }}">view</a> </td>
<td> <a href="{{ zone.id }}/edit">edit</a> </td>
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html
index e4a3a3fde..59443c00d 100644
--- a/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html
+++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html
@@ -41,20 +41,20 @@
<tr><td valign="top"> <b>nameservers</b></td>
<td>
- {% for nameserver in nameservers %}
+ {% for nameserver in zone.nameservers.all %}
{{ nameserver.name }}<br>
{% endfor %}
</td></tr>
<tr><td valign="top"> <b>mxs</b></td>
<td>
- {% for mx in mxs %}
+ {% for mx in zone.mxs.all %}
{{ mx.priority }} {{ mx.mx }}<br>
{% endfor %}
</td></tr>
{% if addresses %}
<tr><td valign="top"> <b>A records</b></td>
<td>
- {% for address in addresses %}
+ {% for address in sof.addresses.all %}
{{ address.ip_addr }}<br>
{% endfor %}
</td></tr>
diff --git a/src/lib/Server/Hostbase/ldapauth.py b/src/lib/Server/Hostbase/ldapauth.py
index 1dc563368..94f5192e0 100644
--- a/src/lib/Server/Hostbase/ldapauth.py
+++ b/src/lib/Server/Hostbase/ldapauth.py
@@ -2,7 +2,7 @@
and returns a subset of the user's profile that is needed by Argonne/CIS to
to set user level privleges in Django"""
-__revision__ = '$Revision$'
+__revision__ = '$Revision: 2456 $'
import os
import ldap
diff --git a/src/lib/Server/Hostbase/settings.py b/src/lib/Server/Hostbase/settings.py
index ac2dc5fab..07577664b 100644
--- a/src/lib/Server/Hostbase/settings.py
+++ b/src/lib/Server/Hostbase/settings.py
@@ -1,14 +1,21 @@
from ConfigParser import ConfigParser, NoSectionError, NoOptionError
+import os.path
+
+PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
+
c = ConfigParser()
#This needs to be configurable one day somehow
-c.read(['/etc/bcfg2.conf'])
+c.read(['./bcfg2.conf'])
-defaults = {'database_engine':'',
- 'database_name':'',
+defaults = {'database_engine':'sqlite3',
+ 'database_name':'./dev.db',
'database_user':'',
'database_password':'',
'database_host':'',
'database_port':3306,
+ 'default_mx':'localhost',
+ 'priority':10,
+ 'authorized_group':'admins',
}
if c.has_section('hostbase'):
@@ -60,16 +67,18 @@ import django.contrib.auth
django.contrib.auth.LOGIN_URL = '/login'
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = ''
+MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
+# Just for development
+SERVE_MEDIA = DEBUG
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
-LANGUAGE_CODE = 'en-us'
+LANGUAGE_CODE = 'es'
SITE_ID = 1
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
-MEDIA_URL = ''
+MEDIA_URL = '/site_media/'
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
@@ -83,9 +92,21 @@ TEMPLATE_LOADERS = (
# 'django.template.loaders.eggs.load_template_source',
)
+TEMPLATE_CONTEXT_PROCESSORS = (
+ "django.core.context_processors.auth",
+ "django.core.context_processors.debug",
+ "django.core.context_processors.i18n",
+ "django.core.context_processors.request",
+ "django.core.context_processors.media",
+# Django development version.
+# "django.core.context_processors.csrf",
+)
+
+
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)
@@ -100,16 +121,20 @@ TEMPLATE_DIRS = (
'/usr/lib/python2.3/site-packages/Bcfg2/Server/Hostbase/templates',
'/usr/lib/python2.4/site-packages/Bcfg2/Server/Hostbase/templates',
'/usr/share/bcfg2/Hostbase/templates',
+ os.path.join(PROJECT_ROOT, 'templates'),
+ os.path.join(PROJECT_ROOT, 'hostbase/webtemplates'),
)
INSTALLED_APPS = (
'django.contrib.admin',
+ 'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
+ 'django.contrib.humanize',
'Bcfg2.Server.Hostbase.hostbase',
-
)
+LOGIN_URL = '/login/'
diff --git a/src/lib/Server/Hostbase/urls.py b/src/lib/Server/Hostbase/urls.py
index 4e45e883c..01fe97d4f 100644
--- a/src/lib/Server/Hostbase/urls.py
+++ b/src/lib/Server/Hostbase/urls.py
@@ -1,33 +1,27 @@
from django.conf.urls.defaults import *
+from django.conf import settings
+from django.views.generic.simple import direct_to_template
+from django.contrib import admin
-urlpatterns = patterns('Bcfg2.Server.Hostbase.hostbase.views',
-
- (r'^admin/', include('django.contrib.admin.urls')),
- (r'^hostbase/$', 'search'),
- (r'^$','index' ),
- (r'^hostbase/(?P<host_id>\d+)/$', 'look'),
- (r'^hostbase/(?P<host_id>\d+)/edit', 'edit'),
- (r'^hostbase/(?P<host_id>\d+)/remove', 'remove'),
- (r'^hostbase/(?P<host_id>\d+)/(?P<item>\D+)/(?P<item_id>\d+)/confirm', 'confirm'),
- (r'^hostbase/(?P<host_id>\d+)/(?P<item>\D+)/(?P<item_id>\d+)/(?P<name_id>\d+)/confirm', 'confirm'),
- (r'^hostbase/(?P<host_id>\d+)/dns/edit', 'dnsedit'),
- (r'^hostbase/(?P<host_id>\d+)/dns', 'dns'),
- (r'^hostbase/(?P<host_id>\d+)/logs/(?P<log_id>\d+)', 'printlog'),
- (r'^hostbase/(?P<host_id>\d+)/logs', 'logs'),
- (r'^hostbase/new', 'new'),
- (r'^hostbase/(?P<host_id>\d+)/copy', 'copy'),
- (r'^hostbase/hostinfo', 'hostinfo'),
- (r'^hostbase/zones/$', 'zones'),
- (r'^hostbase/zones/(?P<zone_id>\d+)/$', 'zoneview'),
- (r'^hostbase/zones/(?P<zone_id>\d+)/edit', 'zoneedit'),
- (r'^hostbase/zones/new/$', 'zonenew'),
- (r'^hostbase/zones/(?P<zone_id>\d+)/(?P<item>\D+)/(?P<item_id>\d+)/confirm', 'confirm'),
- )
-urlpatterns += patterns('',
- (r'^login/$', 'django.contrib.auth.views.login',
- {'template_name': 'login.html'}),
- (r'^logout/$', 'django.contrib.auth.views.logout',
- {'template_name': 'logout.html'})
- )
-
+admin.autodiscover()
+
+
+urlpatterns = patterns('',
+ # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
+ # to INSTALLED_APPS to enable admin documentation:
+ (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+ # Uncomment the next line to enable the admin:
+ (r'^admin/', include(admin.site.urls)),
+
+ (r'^$',direct_to_template, {'template':'index.html'}, 'index'),
+ (r'^hostbase/', include('hostbase.urls')),
+ (r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
+ (r'^logout/$', 'django.contrib.auth.views.logout', {'template_name': 'logout.html'})
+)
+
+if settings.SERVE_MEDIA:
+ urlpatterns += patterns('',
+ (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
+ dict(document_root=settings.MEDIA_ROOT)),)