kickstart cobbler snippet and cheetah regex
tu2Bgone at gmail.com
tu2Bgone at gmail.com
Mon Jul 19 11:03:32 UTC 2010
Hi list,
Having issues with SNIPPETS and variables.
I'm trying to use the mgmt_classes var to get the vlans my host belongs to
and then I want to configure some bond aliases and bridges.
The trouble I'm having is that I can't seem to use some variables like the
examples show - and not being a python nor cheetah expert was wondering if
someone could help me. I want to use a regex to get the vlans associated
with this host. The mgmt_classes declaration looks like this:
mgmt_classes : [ 'xen-dom0', 'vlans=575,573,596']
I want to get the 575,573,596 and stick it into a var that I can split on
the ','.
The problem I'm getting is that if I use the following I get a
"expected string or buffer
# File "/usr/lib/python2.6/site-packages/cobbler/templar.py", line 121, in
render
# data_out = t.respond()
"
(adding line numbers for clarity)
1 #if $getVar('$mgmt_classes')
2 #set $mclass = $getVar('$mgmt_classes')
3 #import re
4 test class: $mclass
5 #set $vlanpattern = $re.compile("[vlans=](((\d{3,4})+[,]?)+)")
6 #if $vlanpattern.search($mgmt_classes)
7 match
8 test class: $mclass
9 #else
10 print no match $mclass
11 #end if
12 #end if
This is following the example in the cobbler snippets directory
for 'network_config' where
#set $vlanpattern = $re.compile("[a-zA-Z0-9]+[\.:][0-9]+")
..
#if $vlanpattern.match($iname)
is used.
If I change
6 #if $vlanpattern.search($mgmt_classes)
to
6 #if $vlanpattern.search('$mgmt_classes')
The kickstart file compiles but the match does not occur.
from the kickstart with "if $vlanpattern.search('$mgmt_classes')" :
<snip>
test class: ['xen-dom0', 'vlans=575,573,596']
print no match ['xen-dom0', 'vlans=575,573,596']
<snip>
Anyone care to shed any light on it? The regex itself should work fine.
Cheers,
denmat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/kickstart-list/attachments/20100719/393c97e3/attachment.htm>
More information about the Kickstart-list
mailing list