Recursive fai-class

Björn Torkelsson torkel at hpc2n.umu.se
Mon Feb 18 22:34:14 CET 2008


Hi,

On Fri, 2008-02-15 at 10:01 +0100, Raphaël Pinson wrote:
> Hello FAI devs,
> 
> As I was looking at the list of FAI classes and dependencies we use
> for our production, I found that the system was a bit flat and that
> adding a recursive class declaration would make it more powerful.

I really agree with you. 

Instead of patching FAI we have been using the following in one of our
class files:

# If a machine specific hostfile exists with classes
# listed, cat it. catnc removes comments (#)
if [ -f hosts/$HOSTNAME ]; then
    catnc hosts/$HOSTNAME
fi

if [ -d subclass ]; then
    for c in $classes; do
        if [ -f subclass/$c ]; then
            catnc subclass/$c
        fi
    done
fi

But having an "official" way doing this would of course be better.

> I'm attaching a patch to make fai-class work recursively (patch based
> on FAI 3.2.4). 
> 
> This patch modifies the addclass() function to make it recursive, i.e.
> whenever a new class is added, it checks for the presence of a
> $classdir/$class file and includes the classes listed there, that way
> it is done with $classdir/$HOSTNAME. Additionaly, a file
> named /tmp/fai/parsed_classes is used to store the parsed files in
> order to prevent loops.
> 
> Attached is a graphviz graph (test_class.png) showing the kind of
> dependencies it allows
> 
> - the $classdir/10-base-classes script dynamiquely declares the
> DEBIAN_4 class. The $classdir/DEBIAN_4 file is found and contains
> GRUB, so the GRUB class is defined ;
> - "test" is $HOSTNAME given in the kernel arguments. The
> $classdir/test file contains three classes: HEBEX, KERNEL and
> PART_CCISS_C0D0_defosof ;
> - when the HEBEX class is added, a file $classdir/HEBEX is found and
> parsed, declaring the 4 new classes: BOOT, MBR, NETWORK and CFD ;
> 
> 
> Eventually, FAI_CLASS contains (# are added commentaries) :
> 
> ----
> # DEFAULT
> DEFAULT
> # Begin 10-base-classes
> SOPHIA
> LINUX
> SOPHIA
> AMD64
> DEBIAN
> DEBIAN_4
> # File /var/lib/fai/config/class/DEBIAN_4 found
> GRUB
> # Back to 10-base-classes
> DEBIAN_4_0
> DEBIAN_AMD64
> DEBIAN_4_AMD64
> DEBIAN_4_0_AMD64
> SOPHIA_AMD64
> SOPHIA_DEBIAN
> SOPHIA_DEBIAN_4
> SOPHIA_DEBIAN_4_0
> SOPHIA_DEBIAN_AMD64
> SOPHIA_DEBIAN_4_AMD64
> SOPHIA_DEBIAN_4_0_AMD64
> SOPHIA_test
> # Begin 25-disk-classes
> PART_CCISS_C0D0_test
> # Reading $classdir/test
> HEBEX
> # File /var/lib/fai/config/class/HEBEX found
> BOOT
> MBR
> NETWORK
> CFD
> # Back to $classdir/test
> KERNEL
> PART_CCISS_C0D0_defosof
> # $HOSTNAME
> test
> # LAST
> LAST
> ----
> 
> 
> I'd be happy if some of you can test the patch and give some feedback.
> 
> 
> Cheers,
> 
> 
> Raphaël
> 
> 
> 
> 
> 
> 
-- 
____________________________________________________________
Björn Torkelsson                  email: torkel at hpc2n.umu.se
HPC2N, Umeå University              tel: +46 (0)90 786 7928
> 



More information about the linux-fai-devel mailing list