Hi list,<br /><br />Having issues with SNIPPETS and variables.<br /><br />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.<br /><br />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:<br />mgmt_classes : [ 'xen-dom0', 'vlans=575,573,596']<br /><br />I want to get the 575,573,596 and stick it into a var that I can split on the ','.<br /><br />The problem I'm getting is that if I use the following I get a<br />"expected string or buffer<br /># File "/usr/lib/python2.6/site-packages/cobbler/templar.py", line 121, in render<br /># data_out = t.respond()<br />"<br />(adding line numbers for clarity)<br />1 #if $getVar('$mgmt_classes')<br />2 #set $mclass = $getVar('$mgmt_classes')<br />3 #import re<br />4 test class: $mclass<br />5 #set $vlanpattern = $re.compile("[vlans=](((\d{3,4})+[,]?)+)")<br />6 #if $vlanpattern.search($mgmt_classes)<br />7 match<br />8 test class: $mclass<br />9 #else<br />10 print no match $mclass<br />11 #end if<br />12 #end if<br /><br />This is following the example in the cobbler snippets directory for 'network_config' where<br />#set $vlanpattern = $re.compile("[a-zA-Z0-9]+[\.:][0-9]+")<br />..<br />#if $vlanpattern.match($iname)<br />is used.<br /><br />If I change<br />6 #if $vlanpattern.search($mgmt_classes)<br />to<br />6 #if $vlanpattern.search('$mgmt_classes')<br /><br />The kickstart file compiles but the match does not occur.<br /><br />from the kickstart with "if $vlanpattern.search('$mgmt_classes')" :<br /> <snip><br /> test class: ['xen-dom0', 'vlans=575,573,596']<br /> print no match ['xen-dom0', 'vlans=575,573,596']<br /> <snip><br /><br />Anyone care to shed any light on it? The regex itself should work fine.<br /><br />Cheers,<br />denmat