summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Hostbase/hostbase/views.py
diff options
context:
space:
mode:
authorKen Raffenetti <raffenet@mcs.anl.gov>2006-11-06 21:23:07 +0000
committerKen Raffenetti <raffenet@mcs.anl.gov>2006-11-06 21:23:07 +0000
commit75e2d050496db86c6ed1e4c8ec8c9c9da6341f77 (patch)
tree52d05dda8965c0dbdc94f122c8da1330967ea177 /src/lib/Server/Hostbase/hostbase/views.py
parent23c1f2cc6be9926fdfe85e37869ef88f84b9200e (diff)
downloadbcfg2-75e2d050496db86c6ed1e4c8ec8c9c9da6341f77.tar.gz
bcfg2-75e2d050496db86c6ed1e4c8ec8c9c9da6341f77.tar.bz2
bcfg2-75e2d050496db86c6ed1e4c8ec8c9c9da6341f77.zip
dhcp option is now per interface
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2474 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Hostbase/hostbase/views.py')
-rw-r--r--src/lib/Server/Hostbase/hostbase/views.py52
1 files changed, 17 insertions, 35 deletions
diff --git a/src/lib/Server/Hostbase/hostbase/views.py b/src/lib/Server/Hostbase/hostbase/views.py
index 748a84471..c60e2c2ff 100644
--- a/src/lib/Server/Hostbase/hostbase/views.py
+++ b/src/lib/Server/Hostbase/hostbase/views.py
@@ -29,30 +29,8 @@ dispatch = {'mac_addr':'i.mac_addr LIKE \'%%%%%s%%%%\'',
'cname':'c.cname LIKE \'%%%%%s%%%%\'',
'mx':'m.mx LIKE \'%%%%%s%%%%\'',
'dns_view':'n.dns_view = \'%s\'',
- 'hdwr_type':'i.hdwr_type = \'%s\''}
-
-
-## def netreg(request):
-## if request.GET.has_key('sub'):
-## failures = []
-## validated = True
-## # do validation right in here
-## macaddr_regex = re.compile('^[0-9abcdef]{2}(:[0-9abcdef]{2}){5}$')
-## if not (request.POST['mac_addr'] and macaddr_regex.match(request.POST['mac_addr'])):
-## validated = False
-## userregex = re.compile('^[a-z0-9-_\.@]+$')
-## if not (request.POST['email_address'] and userregex.match(request.POST['email_address'])):
-## validated = False
-## if not validated:
-## t = Template(open('./hostbase/webtemplates/errors.html').read())
-## t.failures = validate(request, True)
-## return HttpResponse(str(t))
-## return HttpResponseRedirect('/hostbase/%s/' % host.id)
-## else:
-## t = Template(open('./hostbase/webtemplates/netreg.html').read())
-## t.TYPE_CHOICES = Interface.TYPE_CHOICES
-## t.failures = False
-## return HttpResponse(str(t))
+ 'hdwr_type':'i.hdwr_type = \'%s\'',
+ 'dhcp':'i.dhcp = \'%s\''}
def index(request):
"""rediredct to /hostbase/"""
@@ -192,9 +170,6 @@ def edit(request, host_id):
not request.POST.has_key('outbound_smtp')
and host.outbound_smtp):
host.outbound_smtp = not host.outbound_smtp
- if (request.POST.has_key('dhcp') and not host.dhcp or
- not request.POST.has_key('dhcp') and host.dhcp):
- host.dhcp = not host.dhcp
# add validation for attribs here
# likely use a helper fucntion
for attrib in attribs:
@@ -214,6 +189,9 @@ def edit(request, host_id):
oldtype = inter.hdwr_type
inter.hdwr_type = request.POST['hdwr_type%d' % inter.id]
changetype = True
+ if (request.POST.has_key('dhcp%d' % inter.id) and not inter.dhcp or
+ not request.POST.has_key('dhcp%d' % inter.id) and inter.dhcp):
+ inter.dhcp = not inter.dhcp
for ip in ips:
names = ip.name_set.all()
if not ip.ip_addr == request.POST['ip_addr%d' % ip.id]:
@@ -264,7 +242,8 @@ def edit(request, host_id):
if request.POST['mac_addr_new']:
new_inter = Interface(host=host,
mac_addr=request.POST['mac_addr_new'],
- hdwr_type=request.POST['hdwr_type_new'])
+ hdwr_type=request.POST['hdwr_type_new'],
+ dhcp=request.POST['dhcp_new'])
new_inter.save()
if request.POST['mac_addr_new'] and request.POST['ip_addr_new']:
mx, created = MX.objects.get_or_create(priority=settings.PRIORITY, mx=settings.DEFAULT_MX)
@@ -296,7 +275,8 @@ def edit(request, host_id):
if created:
mx.save()
new_inter = Interface(host=host, mac_addr="",
- hdwr_type=request.POST['hdwr_type_new'])
+ hdwr_type=request.POST['hdwr_type_new'],
+ dhcp=False)
new_inter.save()
new_ip = IP(interface=new_inter, num=0,
ip_addr=request.POST['ip_addr_new'])
@@ -517,7 +497,6 @@ def new(request):
# this is the stuff that validate() should take care of
# examine the check boxes for any changes
host.outbound_smtp = request.POST.has_key('outbound_smtp')
- host.dhcp = request.POST.has_key('dhcp')
for attrib in attribs:
if request.POST.has_key(attrib):
host.__dict__[attrib] = request.POST[attrib].lower()
@@ -535,7 +514,8 @@ def new(request):
if request.POST['mac_addr_new']:
new_inter = Interface(host=host,
mac_addr=request.POST['mac_addr_new'],
- hdwr_type=request.POST['hdwr_type_new'])
+ hdwr_type=request.POST['hdwr_type_new'],
+ dhcp=request.POST.has_key('dhcp_new'))
new_inter.save()
if request.POST['mac_addr_new'] and request.POST['ip_addr_new']:
new_ip = IP(interface=new_inter,
@@ -564,7 +544,8 @@ def new(request):
if request.POST['ip_addr_new'] and not request.POST['mac_addr_new']:
new_inter = Interface(host=host,
mac_addr="",
- hdwr_type=request.POST['hdwr_type_new1'])
+ hdwr_type=request.POST['hdwr_type_new1'],
+ dhcp=False)
new_inter.save()
new_ip = IP(interface=new_inter, num=0,
ip_addr=request.POST['ip_addr_new1'])
@@ -593,7 +574,8 @@ def new(request):
if request.POST['mac_addr_new2']:
new_inter = Interface(host=host,
mac_addr=request.POST['mac_addr_new2'],
- hdwr_type=request.POST['mac_addr_new2'])
+ hdwr_type=request.POST['mac_addr_new2'],
+ dhcp=request.POST.has_key('dhcp_new2'))
new_inter.save()
if request.POST['mac_addr_new2'] and request.POST['ip_addr_new2']:
new_ip = IP(interface=new_inter, num=0,
@@ -623,7 +605,8 @@ def new(request):
if request.POST['ip_addr_new2'] and not request.POST['mac_addr_new2']:
new_inter = Interface(host=host,
mac_addr="",
- hdwr_type=request.POST['hdwr_type_new2'])
+ hdwr_type=request.POST['hdwr_type_new2'],
+ dhcp=False)
new_inter.save()
new_ip = IP(interface=new_inter, num=0,
ip_addr=request.POST['ip_addr_new2'])
@@ -915,4 +898,3 @@ else:
remove = login_required(remove)
zoneedit = login_required(zoneedit)
zonenew = login_required(zonenew)
-