May I suggestion something like this

%include /tmp/part-include
%pre

#Liquidnet Distro
build=`echo $profile | awk -F- '{print $2}'`

# Determine how many drives we have
set \$(list-harddrives)
let numd=\$#/2
d1=\$1
d2=\$3

# Total System Memory
memKiB=`awk '/MemTotal:/{print $2 }' /proc/meminfo` memMiB=`expr $memKiB / 
1024` mem=`expr \( \( $memMiB / 32 \) + 1 \) \* 32`

## Are we a VM
#set $isvm = $getVar('isvm', '0')
##

# Default swap size and rootvg size
pv2size=1
pv1size=16384
swapsize=2048

if [ $mem -gt 4100  -a $mem -lt 8100 ]; then
   swapsize=4096
elif [ $mem -gt 8100 ]; then
   swapsize=8192
fi

# Automagically set the partition layout

case \$build in

  xen) #ESX Server / Xen Server
     swapsize=550
     if [ \$numd = 1 ]; then
        cat <<-EOpart > /tmp/part-include
                part /boot --fstype ext3 --size=100 --ondisk=\$d1 --asprimary
                part pv.100000 --size \$pv1size --ondisk=\$d1 --asprimary
                part pv.200000 --size \$pv2size --grow --ondisk=\$d1 --asprimary
                volgroup rootvg pv.100000
                volgroup datavg pv.200000
                logvol / --fstype ext3 --vgname=rootvg --size=4192 
--name=rootvol
                logvol /tmp --fstype ext3 --vgname=rootvg --size=548 
--name=tmpvol
                logvol /var --fstype ext3 --vgname=rootvg --size=2048 
--name=varvol
                logvol swap --fstype swap --vgname=rootvg --size=\$swapsize 
--name=swapvol
                logvol /appdata --fstype ext3 --vgname=datavg --size=1 --grow 
--name=appdatavol
        EOpart
     else
        cat <<-EOpart > /tmp/part-include
                part /boot --fstype ext3 --size=100 --ondisk=\$d1 --asprimary
                part pv.100000 --size \$pv1size --ondisk=\$d1 --asprimary
                part pv.200000 --size \$pv2size --grow --ondisk=\$d2 --asprimary
                volgroup rootvg pv.100000
                volgroup datavg pv.200000
                logvol / --fstype ext3 --vgname=rootvg --size=4192 
--name=rootvol
                logvol /tmp --fstype ext3 --vgname=rootvg --size=548 
--name=tmpvol
                logvol /var --fstype ext3 --vgname=rootvg --size=2048 
--name=varvol
                logvol swap --fstype swap --vgname=rootvg --size=\$swapsize 
--name=swapvol
                logvol /appdata --fstype ext3 --vgname=datavg --size=1 --grow 
--name=appdatavol
        EOpart
     fi ;;

  *) #All Liquidnet Servers
    if [ $isvm = 1 ]; then
      pv2size=1
      pv1size=11264
      if [ "$vendor" = vmw ]; then #VM Workstatsion / Virtualbox
        swapsize=550
        pv2size=1
        pv1size=8192
        cat <<-EOpart > /tmp/part-include
                part /boot --fstype ext3 --size=100 --ondisk=\$d1 --asprimary
                part pv.100000 --size \$pv1size --ondisk=\$d1 --asprimary
                part pv.200000 --size \$pv2size --grow --ondisk=\$d1 --asprimary
                volgroup rootvg pv.100000
                volgroup datavg pv.200000
                logvol / --fstype ext3 --vgname=rootvg --size=4192 
--name=rootvol
                logvol /tmp --fstype ext3 --vgname=rootvg --size=548 
--name=tmpvol
                logvol /var --fstype ext3 --vgname=rootvg --size=2048 
--name=varvol
                logvol swap --fstype swap --vgname=rootvg --size=\$swapsize 
--name=swapvol
                logvol /appdata --fstype ext3 --vgname=datavg --size=1 --grow  
--name=appdatavol
        EOpart
      else #ESX Server VM
        cat <<-EOpart > /tmp/part-include
                part /boot --fstype ext3 --size=100 --ondisk=\$d1 --asprimary
                part pv.100000 --size \$pv1size --ondisk=\$d1 --asprimary
                part pv.200000 --size \$pv2size --grow --ondisk=\$d1 --asprimary
                volgroup rootvg pv.100000
                volgroup datavg pv.200000
                logvol / --fstype ext3 --vgname=rootvg --size=4192 
--name=rootvol
                logvol /tmp --fstype ext3 --vgname=rootvg --size=548 
--name=tmpvol
                logvol /var --fstype ext3 --vgname=rootvg --size=2048 
--name=varvol
                logvol swap --fstype swap --vgname=rootvg --size=\$swapsize 
--name=swapvol
                logvol /appdata --fstype ext3 --vgname=datavg --size=1 --grow 
--name=appdatavol
        EOpart
      fi
     else
      if [ \$numd = 1 ]; then #Physical Hardware
        cat <<-EOpart > /tmp/part-include
                part /boot --fstype ext3 --size=100 --ondisk=\$d1 --asprimary
                part pv.100000 --size \$pv1size --ondisk=\$d1 --asprimary
                part pv.200000 --size \$pv2size --grow --ondisk=\$d1 --asprimary
                volgroup rootvg pv.100000
                volgroup datavg pv.200000
                logvol / --fstype ext3 --vgname=rootvg --size=4192 
--name=rootvol
                logvol /tmp --fstype ext3 --vgname=rootvg --size=548 
--name=tmpvol
                logvol /var --fstype ext3 --vgname=rootvg --size=2048 
--name=varvol
                logvol swap --fstype swap --vgname=rootvg --size=\$swapsize 
--name=swapvol
                logvol /appdata/cores --fstype ext3 --vgname=datavg 
--size=25600 --name=corevol
                logvol /appdata --fstype ext3 --vgname=datavg --size=1 --grow 
--name=appdatavol
        EOpart
      else
        cat <<-EOpart > /tmp/part-include
                part /boot --fstype ext3 --size=100
                part pv.100000 --size \$pv1size --ondisk=\$d1 --asprimary
                part pv.200000 --size \$pv2size --grow --ondisk=\$d2 --asprimary
                volgroup rootvg pv.100000
                volgroup datavg pv.200000
                logvol / --fstype ext3 --vgname=rootvg --size=4192 
--name=rootvol
                logvol /tmp --fstype ext3 --vgname=rootvg --size=548 
--name=tmpvol
                logvol /var --fstype ext3 --vgname=rootvg --size=2048 
--name=varvol
                logvol swap --fstype swap --vgname=rootvg --size=\$swapsize 
--name=swapvol
                logvol /appdata/cores --fstype ext3 --vgname=datavg 
--size=25600 --name=corevol
                logvol /appdata --fstype ext3 --vgname=datavg --size=1 --grow 
--name=appdatavol
        EOpart
      fi
    fi ;;
esac

Joseph Boyer Jr.
Liquidnet Holdings, Inc.
E [email protected]
T +1 646.660.8352
C +1 646.284.8394


-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Michael DeHaan
Sent: Tuesday, January 27, 2009 1:34 PM
To: cobbler mailing list
Subject: Re: problems figuring out disks - and new cheetah-snippets

Rainer Duffner wrote:
> Hi,
>
> I want to figure out (or rather: pass them to cobbler via ksmeta variables):
>
> I have:
>
> disk=cciss/c0d0,cciss/c0d1
>
> in the ksmeta-string.
>
> I've got a snippet, that is included in the template via
> $SNIPPET('disk_double_big_opt_neutral')
>
> It looks like this:
>
> #set $disks=getVar('$disk', None)
> #set $disk1=$disks.split(',')[0]
> #set $disk2=$disks.split(',')[1]
>
> clearpart --all --drives=$disks
> part /boot --fstype ext3 --size=100 --ondisk=$disk1
> part pv.2 --size=0 --grow --ondisk=$disk1
> volgroup VolGroup00 --pesize=32768 pv.2
> logvol swap --fstype swap --name=swapvol --vgname=VolGroup00 --size=512
> --grow --maxsize=$ksmaxswap
> logvol / --fstype ext3 --name=rootvol --vgname=VolGroup00
> --size=$ksmaxslash --grow
> logvol /tmp --fstype ext3 --name=tmpvol --vgname=VolGroup00 --size=$ksmaxtmp
> part pv.3 --size=0 --grow --ondisk=$disk2
> volgroup VolGroup01 --pesize=32768 pv.3
> logvol $bigpart --fstype ext3 --name=bigvol --vgname=VolGroup01
> --size=$ksmaxbig --grow
>

All the Cobbler 1.4 default templates are switched to just use
"autopart" now, for complexity reasons. We're still leaving the old disk
partitioning snippets in /var/lib/cobbler/snippets for folks that are
using it.
>
> But all I get is a big error when I want to view the rendered result:
>
> # *** ERROR ***
> #
> # There is a templating error preventing this file from rendering correctly.
> #
> # This is most likely not due to a bug in Cobbler and is something you can 
> fix.
> #
> # Look at the message below to see what things are causing problems.
> #
> # (1) Does the template file reference a $variable that is not defined?
> # (2) is there a formatting error in a Cheetah directive?
> # (3) Should dollar signs ($) be escaped that are not being escaped?
> #
> # Try fixing the problem and then investigate to see if this message goes
> # away or changes.
> #
> #
> # global name 'getVar' is not defined
> #   File "/usr/lib/python2.4/site-packages/cobbler/templar.py", line 114, in 
> render
> #     data_out = str(t)
> #
> #   File "/usr/lib/python2.4/site-packages/Cheetah/Template.py", line 994, in 
> __str__
> #     def __str__(self): return getattr(self, mainMethName)()
> #
> #   File "cheetah_DynamicallyCompiledCheetahTemplate_1233079651_86_79472.py", 
> line 290, in respond
> #
> #   File "cheetah_DynamicallyCompiledCheetahTemplate_1233079651_86_79472.py", 
> line 127, in __errorCatcher9
> #
> #   File "<string>", line 0, in ?
> #
> #   File "/usr/lib/python2.4/site-packages/cobbler/template_api.py", line 
> 156, in SNIPPET
> #     result = BuiltinTemplate.SNIPPET(self, file)
> #
> #   File "DynamicallyCompiledCheetahTemplate.py", line 89, in SNIPPET
> #
> #   File "/usr/lib/python2.4/site-packages/Cheetah/Template.py", line 1536, 
> in _handleCheetahInclude
> #     self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
> #
> #   File 
> "cheetah__var_lib_cobbler_snippets_disk_double_big_opt_neutral_1233079619_04_60080.py",
>  line 148, in respond
> #
>
> <pre>
> Mod_python error: "PythonHandler services"
>
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in 
> HandlerDispatch
>     result = object(req)
>
>   File "/var/www/cobbler/svc/services.py", line 98, in handler
>     return apache.HTTP_ERROR
>
> AttributeError: 'module' object has no attribute 'HTTP_ERROR'
>
> </pre>
>

The very last bit about HTTP_ERROR is spurius, but irrelevant. (What OS
are you running? I think apache.HTTP_ERROR is valid code, which slightly
confuses me).

The text above it though, it correct.
It is saying getVar does not exist, because you need to be using
$getVar(...) instead.

$foo dereferences a variable in Cheetah, or calls a function. In this
case, $getVar(...) is a function.

--Michael


_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler


_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler

Reply via email to