The fixes/ directory will be recursively copied to /usr/lib/ganeti/fixes on the bootstrap OS. It contains a few executable scripts which will be run with run-parts. If these are to be python scripts, most of their code should be contained in modules in fixes/fixlib/, so that they can be unit tested.
This patch: - Updates p2v-target.conf.in so that python will be available on the bootstap os - Adds the hook script to install the fixes directory on the boostrap OS - Creates the fixes/fixlib directory where python modules for the scripts will live Signed-off-by: Ben Lipton <[email protected]> --- instance-p2v-target/Makefile.am | 6 +++- instance-p2v-target/fixes/fixlib/__init__.py | 27 ++++++++++++++++++++++++++ instance-p2v-target/hooks/install-fixes.in | 21 ++++++++++++++++++++ instance-p2v-target/p2v-target.conf.in | 2 +- 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 instance-p2v-target/fixes/fixlib/__init__.py create mode 100644 instance-p2v-target/hooks/install-fixes.in diff --git a/instance-p2v-target/Makefile.am b/instance-p2v-target/Makefile.am index 06d8017..b201da1 100644 --- a/instance-p2v-target/Makefile.am +++ b/instance-p2v-target/Makefile.am @@ -11,8 +11,9 @@ dist_os_SCRIPTS = create import export rename config_DATA = p2v-target.conf dist_hook_SCRIPTS = hooks/ramboot hooks/interfaces hooks/xen-hvc0 \ hooks/clear-root-password +hook_SCRIPTS = hooks/install-fixes -subst_files = common.sh p2v-target.conf +subst_files = hooks/install-fixes common.sh p2v-target.conf dist_os_DATA = ganeti_api_version variants.list os_SCRIPTS = common.sh @@ -20,7 +21,8 @@ os_SCRIPTS = common.sh dist_sbin_SCRIPTS = scripts/make_ramboot_initrd.py dist_fixes_SCRIPTS = -dist_fixlib_DATA = +dist_fixlib_DATA = \ + fixes/fixlib/__init__.py EXTRA_DIST = $(patsubst %,%.in,$(subst_files)) \ $(dist_TESTS) \ diff --git a/instance-p2v-target/fixes/fixlib/__init__.py b/instance-p2v-target/fixes/fixlib/__init__.py new file mode 100644 index 0000000..0fb4bea --- /dev/null +++ b/instance-p2v-target/fixes/fixlib/__init__.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +# +# Copyright 2011 Google Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +"""Code for python fix scripts. + +Fixlib is a package for the actual code of the python fix scripts, so that they +can be unit tested but also run with run-parts. +""" + +class FixError(Exception): + pass diff --git a/instance-p2v-target/hooks/install-fixes.in b/instance-p2v-target/hooks/install-fixes.in new file mode 100644 index 0000000..961de1d --- /dev/null +++ b/instance-p2v-target/hooks/install-fixes.in @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +# Make sure we're not working on the root directory +if [ -z "$TARGET" -o "$TARGET" = "/" ]; then + echo "Invalid target directory '$TARGET', aborting." 1>&2 + exit 1 +fi + +if [ "$(mountpoint -d /)" = "$(mountpoint -d "$TARGET")" ]; then + echo "The target directory seems to be the root dir, aborting." 1>&2 + exit 1 +fi + +# Copy the fixes from @configdir@/fixes to the instance: +mkdir -p "$TARGET/usr/lib/ganeti" +cp -r "@configdir@/fixes" "$TARGET/usr/lib/ganeti" + +exit 0 + diff --git a/instance-p2v-target/p2v-target.conf.in b/instance-p2v-target/p2v-target.conf.in index 615777f..3decbbb 100644 --- a/instance-p2v-target/p2v-target.conf.in +++ b/instance-p2v-target/p2v-target.conf.in @@ -37,7 +37,7 @@ # EXTRA_PKGS="acpi-support-base,console-tools,udev,linux-image-amd64" # Additional packages required for p2v-target image -EXTRA_PKGS+=",rsync,openssh-server" +EXTRA_PKGS+=",rsync,openssh-server,python" # CUSTOMIZE_DIR: a directory containing scripts to customize the installation. # The scripts are executed using run-parts -- 1.7.3.1
