From ec7999775cc74f3eee97b84eb4e4ef9341da594b Mon Sep 17 00:00:00 2001 From: Ken Raffenetti Date: Thu, 21 Sep 2006 21:57:44 +0000 Subject: tweaks to dhcp generation git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2297 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/Hostbase.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/lib/Server/Plugins/Hostbase.py') diff --git a/src/lib/Server/Plugins/Hostbase.py b/src/lib/Server/Plugins/Hostbase.py index bc5468926..36d2a348d 100644 --- a/src/lib/Server/Plugins/Hostbase.py +++ b/src/lib/Server/Plugins/Hostbase.py @@ -9,7 +9,7 @@ from Bcfg2.Server.Plugin import Plugin, PluginExecutionError, PluginInitError, D from time import strftime from sets import Set import re - +from django.template import loader, Context ## class DataNexus(DirectoryBacked): ## '''DataNexus is an object that watches multiple files and @@ -61,7 +61,7 @@ class Hostbase(Plugin): 'reversesoa':Template(open(self.data + '/templates/' + 'reversesoa.tmpl').read()), 'named':Template(open(self.data + '/templates/' + 'named.tmpl').read()), 'reverseapp':Template(open(self.data + '/templates/' + 'reverseappend.tmpl').read()), - 'dhcp':Template(open(self.data + '/templates/' + 'dhcpd.tmpl').read()), + 'dhcp':loader.get_template('dhcpd.tmpl'), 'hosts':Template(open(self.data + '/templates/' + 'hosts.tmpl').read()), 'hostsapp':Template(open(self.data + '/templates/' + 'hostsappend.tmpl').read()), } @@ -300,11 +300,13 @@ class Hostbase(Plugin): if hostdata not in hosts: hosts.append(hostdata) - self.templates['dhcp'].hosts = hosts - self.templates['dhcp'].numips = len(hosts) - self.templates['dhcp'].timecreated = strftime("%a %b %d %H:%M:%S %Z %Y") + context = Context({ + 'hosts': hosts, + 'numips': len(hosts), + 'timecreated': strftime("%a %b %d %H:%M:%S %Z %Y"), + }) - self.filedata['dhcpd.conf'] = str(self.templates['dhcp']) + self.filedata['dhcpd.conf'] = self.templates['dhcp'].render(context) self.Entries['ConfigFile']['/etc/dhcpd.conf'] = self.FetchFile -- cgit v1.2.3-1-g7c22