beginner questions

Jonathan Sabo <[email protected]> Thu, 18 Mar 2010 08:30:43 -0400
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
I'm using cheetah templates in Cobbler and I'm just getting started
with cheetah itself so please forgive my lame and hopefully not to
annoying questions.  Cobbler comes with a dhcpd.conf template and I've
customized it a bit but I'm not sure there isn't a cleaner way to
write this code.  I want to allow non programmer types to add
netblocks to this file so it can configure the dhcpd.conf file.  I'm
curious if there are cleaner ways to write this or if this just looks
retarded?

#set $netblocks = {
'NYC' : {
'NYC_MANAGEMENT'               : { 'NETWORK' : '10.37.40.0',
'NETMASK' : '255.255.248.0', 'GATEWAY' : '10.37.40.1' },
'NYC_DMZ_MANAGEMENT'      : { 'NETWORK' : '10.37.54.0',  'NETMASK' :
'255.255.255.0', 'GATEWAY' : '10.37.54.1' },
'NYC_EXT_MANAGEMENT'       : { 'NETWORK' : '10.37.72.0',  'NETMASK' :
'255.255.248.0', 'GATEWAY' : '10.37.72.1' },
'TRUSTED_MANAGEMENT'       : { 'NETWORK' : '10.37.86.0',  'NETMASK' :
'255.255.255.0', 'GATEWAY' : '10.37.86.1' },
'UNTRUSTED_MANAGEMENT'  : { 'NETWORK' : '10.37.200.0', 'NETMASK' :
'255.255.248.0', 'GATEWAY' : '10.37.200.1' },
'DMZ_MANAGEMENT'  : { 'NETWORK' : '10.37.214.0', 'NETMASK' :
'255.255.255.0', 'GATEWAY' : '10.37.214.1' },
}
}

#for $skey in $netblocks.keys()
    #for $nkey in $netblocks[skey].keys()
# $skey $nkey
subnet $netblocks[skey][nkey]['NETWORK'] netmask
$netblocks[skey][nkey]['NETMASK'] {
     option routers             $netblocks[skey][nkey]['GATEWAY'];
     option subnet-mask         $netblocks[skey][nkey]['NETMASK'];
     filename                   "/pxelinux.0";
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $nextserver;
}

    #end for
#end for

Thanks,

Jonathan

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev