Developers

Checking out

To check out the source code use git:

$ git clone https://code.grnet.gr/git/snf-image

Configure and install snf-image-host

Once you have checkout the source code, it's time to configure. For the simplest default configuration run:

 $ cd snf-image-host
 $ ./autogen.sh
 $ ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc

Other configuration options you may find useful:
  • --with-progress-monitor : if enabled, it monitors the progress of the dd command while the Image is being copied and produces read/write statistics. To use this option you need to have snf-ganeti-tools installed on your cluster, so that the snf-progress-monitor program is present on your system.
  • --with-helper-dir=/path/to/helper/dir : specify the path where the helper data are going to be stored
  • --with-helper-img=/path/to/img/file : specify the path to the helper VM image
  • --with-helper-kernel=/path/to/kernel : specify the path to the helper VM kernel
  • --with-helper-initrd=/path/to/initrd : specify the path to the helper VM initrd
  • --with-os-dir=/path/to/os/dir : specify the top-level OS Provider's directory under which to install itself

After configuring install the package by running:

 $ make && make install

Preparing snf-image-helper

Using snf-image-update-helper

The snf-image-helper must be installed inside the helper VM and NOT the Ganeti node. The smoothest way to accomplish that, is by making a snf-image-helper debian package, store it under snf-image-host's $HELPER_DIR and run snf-image-update-helper (part of snf-image-host) to create the helper VM and install the snf-image-helper debian package inside it. See the last section on how to build the debian package.

Manually

If you want to create your own helper VM manually and then install snf-image-helper inside (the hard way), do the following:
  1. Customize a helper VM image of your choice
  2. Once you have customized your helper VM image, mount it on a tmp directory.
  3. Checkout the source code as described in the first section.
  4. Run:
    $ cd snf-image-helper
    $ ./autogen.sh
    $ ./configure
    $ make
    $ make DESTDIR=/path/to/mounted/tmpdir install 
    
  5. snf-image-helper should run automatically in the helper VM upon boot, when the snf_image_activate_helper kernel command line argument is present. To do so you can e.g. customize the helper VM's rc.local script:
    $ cat > "/path/to/mounted/tmpdir/etc/rc.local" <<EOF
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing. 
    
    if ! grep -q snf_image_activate_helper /proc/cmdline; then
        echo "WARNING: NOT calling snf-image-helper, add snf_image_activate_helper" 
        echo "to the kernel command line if you want to do so." 
    else
        /usr/bin/snf-image-helper --force
    fi
    
    exit 0
    EOF
    
    $ chmod +x "/path/to/mounted/tmpdir/etc/rc.local" 
    
  6. snf-image-helper requires the --force argument to run. This stands to avert possible halt of the system by mistake.
  7. Once snf-image-helper is installed correctly inside your helper VM image, umount the image and store it under $HELPER_DIR

Building debian packages

If you want to build debian packages from the latest source, after checking out the source, do the following:

 $ git checkout debian
 $ cd snf-image-host
 $ mkdir .git; git-buildpackage --git-upstream-branch=master --git-debian-branch=debian; rmdir .git
 $ cd ..

Copy or move the .deb package and associated files (.orig.tar.gz, .build, .changes, .debian.tar.gz, .dsc) out of the git tree, then:

 $ git clean -df
 $ cd snf-image-helper
 $ mkdir .git; git-buildpackage --git-upstream-branch=master --git-debian-branch=debian; rmdir .git
 $ cd ..

Again move the generated files somewhere else and optionally, you may clean any leftover files and directories when you're done:

 $ git clean -df