support for multiple slice reference images
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 21 Mar 2008 16:35:32 +0000 (16:35 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 21 Mar 2008 16:35:32 +0000 (16:35 +0000)
* vserver-reference rpm names have changed and become
    vserver-@pldistro@-@fcdistro@-@arch@
    vserver-systemslices-@pldistro@-@fcdistro@-@arch@

* this contains the images located as
   /vservers/.vref/@pldistro@-@fcdistro@-@arch@
and
  /vservers/.vstub/@pldistro@-@fcdistro@-@arch@/planetflow
respectively

* a stamp gets created on the nodes as /etc/planetlab/defaultvref
  that contains the name for the default slicefamily to use

* nodemanager tries to be smart when chosing the right argument to pass to vuseradd
  for this purpose, the argument in 'vref' is taken as a dash-separated list of 'wishes'
  so e.g. is defaultvref is planetlab-f8-x86_64, then we should find for the image name:
vref=i386           -> vuseradd -t planetlab-f8-i386
vref=centos5        -> vuseradd -t planetlab-centos5-x86_64
vref=planetflow     -> vuseradd -t planetflow
vref=centos5-onelab -> vuseradd -t onelab-centos5-x86_64

for legacy reasons, if the stamp is not found, 'default' is taken instead

=== status
* this is only partly tested
* a given node can install several variants of vserver-*
  this would require a manual upload of the rpms into the right install-rpms
  and manual changes in yumgroups.
* next improvement would be to have the system (planetflow) slices have a smarter naming scheme as well
  this way a 'planetflow' vref would rather be rewritten as planetflow-f8-x86_64
  for the time being it is not supported to install several variants of vserver-systemslices
  on the node - although it should be harmless

build.sh
vserver-reference.init
vserver-reference.spec

index c4c117e..c5cfcb7 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -37,22 +37,21 @@ pl_process_fedora_options $@
 shiftcount=$?
 shift $shiftcount
 
-# pldistro expected as $1 - defaults to planetlab
+# pldistro expected as $1 
 pldistro=$1 ; shift
+# The vserver reference name - this comes from spec's slicefamily
+vrefname=$1; shift
 
 # Do not tolerate errors
 set -e
 
 # Path's to the vserver references images and stubs
 vrefdir=$PWD/vservers/.vref
-vstubdir=$PWD/vservers/.vstub
-
-# XXX: The vserver reference name should be passed in as an argument
-# rather than being hardcoded.
-vrefname=default
+vref=${vrefdir}/${vrefname}
+# stubs are created in a subdir per slicefamily
+vstubdir=$PWD/vservers/.vstub/${vrefname}
 
 # Make /vservers and default vserver reference image
-vref=${vrefdir}/${vrefname}
 install -d -m 755 ${vref}
 
 # Some of the PlanetLab RPMs attempt to (re)start themselves in %post,
index 8845eaf..f1e1434 100755 (executable)
@@ -57,11 +57,13 @@ setattr --barrier "$__DEFAULT_VSERVERDIR"
 
 # Set the attribute to unlink so vclone does the right thing wrt to 
 # conserving space by linking and not copying unified files.
-find "$__DEFAULT_VSERVERDIR/.vref/default" -type f -print0 | xargs -0 setattr --iunlink
+find "$__DEFAULT_VSERVERDIR/.vref/*" -type f -print0 | xargs -0 setattr --iunlink
 
 # Build reference images for system slices
-for systemvserver in "$__DEFAULT_VSERVERDIR/.vstub/"*.cloned ; do
+# xxx if several instances of systemslices get installed, only one gets instanciated
+for systemvserver in "$__DEFAULT_VSERVERDIR/.vstub/"*/*.cloned ; do
     NAME=$(basename $systemvserver .cloned)
+    DIR=$(dirname $systemvserver)
 
     # Copy base reference image
     if [ ! -d "$__DEFAULT_VSERVERDIR/.vref/$NAME" ] ; then
@@ -75,12 +77,16 @@ for systemvserver in "$__DEFAULT_VSERVERDIR/.vstub/"*.cloned ; do
        # build the systemvserver from the one it was originally cloned from
        TYPE=$(cat $systemvserver)
        REF="$__DEFAULT_VSERVERDIR/.vref/$TYPE"
-       "$_VCLONE" "$REF"/ "$TMP"/
-       RETVAL=$?
+       if [ -d "$REF" ] ; then
+           "$_VCLONE" "$REF"/ "$TMP"/
+           RETVAL=$?
+       else
+           RETVAL=1
+       fi
 
        # merge the stub with the reference to get the system vserver
        if [ $RETVAL -eq 0 ] ; then
-           (cd "$__DEFAULT_VSERVERDIR/.vstub/$NAME"/ && find . | cpio -m -d -u -p "$TMP"/)
+           (cd "$DIR/$NAME"/ && find . | cpio -m -d -u -p "$TMP"/)
            RETVAL=$?
        fi
 
@@ -92,6 +98,7 @@ for systemvserver in "$__DEFAULT_VSERVERDIR/.vstub/"*.cloned ; do
            mv "$TMP" "$__DEFAULT_VSERVERDIR/.vref/$NAME"
            success >&3 2>&4
        else
+           rm -rf "$TMP"
            failure >&3 2>&4
        fi
        echo >&3 2>&4
index aaf961b..d7ed7dc 100644 (file)
@@ -3,13 +3,17 @@
 #
 %define url $URL$
 
+%define slicefamily %{pldistro}-%{distroname}-%{_arch}
+
 %define name vserver
 %define version 4.2
 %define taglevel 2
 
-%define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
+# pldistro already in the rpm name
+#%define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
+%define release %{taglevel}%{?date:.%{date}}
 
-Summary: VServer reference image
+Summary: VServer reference image for slice family %{slicefamily}
 Name: %{name}
 Version: %{version}
 Release: %{release}
@@ -28,24 +32,24 @@ URL: %(echo %{url} | cut -d ' ' -f 2)
 %description
 This package does not really exist.
 
-%package reference
+%package %{slicefamily}
 Summary: VServer reference image
 Group: Applications/System
 AutoReqProv: no
 Requires: util-vserver, e2fsprogs, yum
 Requires(pre): /bin/sh, coreutils
 
-%description reference
+%description %{slicefamily}
 This package creates the virtual server (VServer) reference image used
 as the installation base for new PlanetLab slivers.
 
-%package system-packages
+%package systemslices-%{slicefamily}
 Summary: System slice packages
 Group: Applications/System
-Requires: vserver-reference >= %{version}-%{release}
+Requires: vserver-%{slicefamily} >= %{version}-%{release}
 AutoReqProv: no
 
-%description system-packages
+%description systemslices-%{slicefamily}
 This package installs the RPMS necessary to create system ("root
 resource") slices from the virtual server (VServer) reference image.
 
@@ -54,7 +58,7 @@ resource") slices from the virtual server (VServer) reference image.
 
 %build
 pushd VserverReference
-./build.sh %{pldistro}
+./build.sh %{pldistro} %{slicefamily}
 popd
 
 %install
@@ -81,20 +85,20 @@ if [ -n "$SUDO_USER" ] ; then
     chown -h -R $SUDO_USER %{_rpmdir}/%{_arch}
 fi
 
-%files reference
+%files %{slicefamily}
 %defattr(-,root,root)
 %{_initrddir}/vserver-reference
 %{_sysconfdir}/cron.d/vserver-reference
 %{_sysconfdir}/logrotate.d/vserver-reference
-/vservers/.vref/default
+/vservers/.vref/%{slicefamily}
 
-%files system-packages
+%files systemslices-%{slicefamily}
 %defattr(-,root,root)
 /vservers/.vstub
 
 %define vcached_pid /var/run/vcached.pid
 
-%pre reference
+%pre %{slicefamily}
 # Stop vcached
 if [ -r %{vcached_pid} ] ; then
     kill $(cat %{vcached_pid})
@@ -113,9 +117,11 @@ fi
 # Allow vcached to run again
 rm -f %{vcached_pid}
 
-%post reference
+%post %{slicefamily}
 chkconfig --add vserver-reference
 chkconfig vserver-reference on
+# store the default for nodemanager
+[ -f /etc/planetlab/defaultvref ] || echo %{slicefamily} > /etc/planetlab/defaultvref
 [ "$PL_BOOTCD" = "1" ] || service vserver-reference start
 
 # Randomize daily run time