petermity <6t12-n6js(a)dea.spamcon.org> wrote:
Scott Henson <shenson(a)redhat.com> wrote:
>On Wed, 02 Mar 2011 00:15:01 -0800, petermity <6t12-n6js(a)dea.spamcon.org>
wrote:
>> How can I force a failure on a bad condition, so that "cobbler
>> profile getks" fails with a traceback (and the actual kickstart
>> fails, and validateks fails too)?
>>
>> For instance, I don't want to proceed if some variable is not set:
>>
>> #if $getVar('myvar','') != ''
>> # ... do something with $myvar
>> #else
>> # Somehow throw an error to abort, e.g.:
>> #error "The profile must define 'myvar'"
>> #end if
>
>I believe the directives you need are #assert and #raise. Though they
>are probably disabled by safe templating. I'll include one of them in
>the next release of cobbler (along with the ability to modify the
>whitelist in the settings file).
To help track this, I submitted an enhacement issue:
https://fedorahosted.org/cobbler/ticket/656
With Cobbler V2.0.11, I was able to (indirectly) do what I wanted
here.
I couldn't find a way to use the Cheetah exception-handling
directives directly to cause a nice clear error message.
Instead, I used #echo to put out an error message of my own. I
have a wrapper script that does validation (basically runs
getks), and it looks for and shows this error message.
It would still be nice to do this directly in Cobbler - halt and
put out a user-defined message - without having to wrap the
process independently.