Hi all,
It works with a little trick:
*VARIABLE*
snippets_list=machinetypesnippet,machineenvsnippet
*CHEETAH*
#for $i in $snippets_list.split(",")
#set snippet = "spacewalk/1/" + $i
$SNIPPET($snippet)
#end for
Good news. Nothing complicate at least.
Thanks fo all!
A-
2015-11-27 17:19 GMT-03:00 <[email protected]>:
> Hi
>
> Forgot to mention: then you can have a snippet called puppet or vas or
> whatever and you put all the enable or disable checks in the snippet, hiding
> all that complexity from the ks. For example for our hadoop builds we don't
> want puppet so you can either make it part of build=hadoop or it can be
> disabled via the disable ksmeta variable.
>
> So the ks would look like:
>
> $SNIPPET(vas)
> $SNIPPET(puppet)
> SNIPPET(stornext)
>
> Nice and clean; all complexity hidden.
>
> --
> Alastair Munro
>
> -----Original Message-----
> From: [email protected]
> To: Nishanth Aravamudan <[email protected]>, "Antonio Sebastian Salles
> M." <[email protected]>, cobbler mailing list
> <[email protected]>
> Cc: [email protected]
> Sent: Fri, 27 Nov 2015 20:08
> Subject: [cobbler] Re: Calling snippets from ksmeta
>
> Hi
>
> Have you tried backslashes or additional $s?
>
> Maybe you are trying to use it in a way not intended? My understanding of
> snippets is to try and keep the ks templates easy to read, and in effect
> they are just include code. We just use a limited number of ksmeta
> variables. Mainly 'build' 'enable' 'disable' 'addvol'. Then these are
> interpreted all over the ks and in snippets. So build=vm will give you a VM
> build. 'enable' is a comma delimited list of things to enable. Example's:
> vas, nimsoft, stornext. disable is similar; you can disable things that are
> normally switched on. disable=puppet. Then you can say #if not 'puppet' in
> disable. Addvol is a comma list of lvm volumes to add in vg_root
> addvol=/data:10240:lv_data. Point I am trying to make is you can switch
> functionality on and off via ksmeta variables; that is the way we use
> cheetah.
>
> --
> Alastair Munro
>
> -----Original Message-----
> From: "Antonio Sallés" <[email protected]>
> To: Nishanth Aravamudan <[email protected]>, "Antonio Sebastian Salles
> M." <[email protected]>
> Cc: [email protected]
> Sent: Fri, 27 Nov 2015 2:25
> Subject: [cobbler] Re: Calling snippets from ksmeta
>
> On 11/25/2015 04:29 PM, Nishanth Aravamudan wrote:
>> On 25.11.2015 [15:33:12 -0300], Antonio Sebastian Salles M. wrote:
>>> Hi there,
>>>
>>> I'm looking the way for call a list of SNIPPETs using an array of
>>> ksmeta variables, but finally cheeta doesn't like it. Something like
>>> this:
>>
>> What does cheeta say?
>>
>>> cobbler ... --ksmeta="machinetype=kvm machineenv=db"
>>> ...
>>>
>>> #set $machinetype = $getVar('$machinetype')
>>> #set $machineenv = $getVar('$machineenv')
>>> $SNIPPET('spacewalk/1/$machinetype')
>>> $SNIPPET('spacewalk/1/$machineenv')
>>
>> You *might* need to evaluate this outside of the $SNIPPET call. THat is,
>> try:
>>
>> #set $machinetypesnippet = 'spacewalk/1/$getVar('$machinetype')'
>> #set $machineenvsnippet = 'spacewalk/1/$getVar('$machineenv')'
>>
>> $SNIPPET($machinetypesnippet)
>> $SNIPPET($machineenvsnippet)
>>
>> Does that make any difference?
>>
>> -Nish
>>
>>
>
> Hi,
>
> Nop, it doesn't work neither.
> This is the output:
>
> 8<-------------------
>
> <class 'Cheetah.Parser.ParseError'>:
>
> Error in the Python code which Cheetah generated for this template:
> ================================================================================
>
> invalid syntax
> (cheetah_DynamicallyCompiledCheetahTemplate_1448583729_4_36017.py, line 554)
>
> Line|Python Code
> ----|-------------------------------------------------------------
> 552 |
> 553 |''')
> 554 | machinetypesnippet =
> 'spacewalk/1/$getVar('VFSL([locals()]+SL+[globals(),
> __builtin__],"machinetype",True)')'
> ^
> 555 | write(u'''
> 556 |''')
> 557 | _v = self.__errorCatcher19(localsDict=locals()) #
> u'$SNIPPET($machinetypesnippet)' on line 217, col 1
>
> ================================================================================
>
> Here is the corresponding Cheetah code.
> ** I had to guess the line & column numbers, so they are probably incorrect:
>
> Line 217, column 1
>
> Line|Cheetah Code
> ----|-------------------------------------------------------------
> 214 |#set $machinetypesnippet = 'spacewalk/1/$getVar('$machinetype')'
> 215 |#set $machineenvsnippet = 'spacewalk/1/$getVar('$machineenv')'
> 216 |
> 217 |$SNIPPET($machinetypesnippet)
> ^
> 218 |$SNIPPET($machineenvsnippet)
> 219 |
> 8<-------------------
>
> Any idea?
> Thanks so much.
>
> Antonio.
> _______________________________________________
> cobbler mailing list
> [email protected]
> https://lists.fedorahosted.org/admin/lists/[email protected]
--
Saludos!
Antonio Sebastián Sallés M.
UCENTUX
[cel] +56-9-8-281 71 61
[lab] +56-2-582 9101
_______________________________________________
cobbler mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]