Merge "Install XenServer tools from the iso on XenServer"

This commit is contained in:
Jenkins 2012-08-16 17:15:08 +00:00 committed by Gerrit Code Review
commit 7d8f036662
2 changed files with 28 additions and 5 deletions

View File

@ -18,6 +18,7 @@ set -o xtrace
GUEST_PASSWORD=${GUEST_PASSWORD:-secrete} GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
STAGING_DIR=${STAGING_DIR:-stage} STAGING_DIR=${STAGING_DIR:-stage}
DO_TGZ=${DO_TGZ:-1} DO_TGZ=${DO_TGZ:-1}
XS_TOOLS_PATH=${XS_TOOLS_PATH:-"/root/xs-tools.deb"}
# Install basics # Install basics
chroot $STAGING_DIR apt-get update chroot $STAGING_DIR apt-get update
@ -26,10 +27,8 @@ chroot $STAGING_DIR apt-get install -y curl wget ssh openssh-server python-pip g
chroot $STAGING_DIR pip install xenapi chroot $STAGING_DIR pip install xenapi
# Install XenServer guest utilities # Install XenServer guest utilities
XEGUEST=xe-guest-utilities_5.6.100-651_amd64.deb cp $XS_TOOLS_PATH ${STAGING_DIR}${XS_TOOLS_PATH}
wget http://images.ansolabs.com/xen/$XEGUEST -O $XEGUEST chroot $STAGING_DIR dpkg -i $XS_TOOLS_PATH
cp $XEGUEST $STAGING_DIR/root
chroot $STAGING_DIR dpkg -i /root/$XEGUEST
chroot $STAGING_DIR update-rc.d -f xe-linux-distribution remove chroot $STAGING_DIR update-rc.d -f xe-linux-distribution remove
chroot $STAGING_DIR update-rc.d xe-linux-distribution defaults chroot $STAGING_DIR update-rc.d xe-linux-distribution defaults

View File

@ -44,6 +44,28 @@ if [ ! -d $STAGING_DIR/etc ]; then
exit 1 exit 1
fi fi
# Copy XenServer tools deb into the VM
ISO_DIR="/opt/xensource/packages/iso"
XS_TOOLS_FILE_NAME="xs-tools.deb"
XS_TOOLS_PATH="/root/$XS_TOOLS_FILE_NAME"
if [ -e "$ISO_DIR" ]; then
TOOLS_ISO=$(ls $ISO_DIR/xs-tools-*.iso)
TMP_DIR=/tmp/temp.$RANDOM
mkdir -p $TMP_DIR
mount -o loop $TOOLS_ISO $TMP_DIR
DEB_FILE=$(ls $TMP_DIR/Linux/*amd64.deb)
echo "Copying XenServer tools into VM from: $DEB_FILE"
cp $DEB_FILE "${STAGING_DIR}${XS_TOOLS_PATH}"
umount $TMP_DIR
rm -rf $TMP_DIR
else
echo "WARNING: no XenServer tools found, falling back to 5.6 tools"
TOOLS_URL="http://images.ansolabs.com/xen/xe-guest-utilities_5.6.100-651_amd64.deb"
wget $TOOLS_URL -O $XS_TOOLS_FILE_NAME
cp $XS_TOOLS_FILE_NAME "${STAGING_DIR}${XS_TOOLS_PATH}"
rm -rf $XS_TOOLS_FILE_NAME
fi
# Copy prepare_guest.sh to VM # Copy prepare_guest.sh to VM
mkdir -p $STAGING_DIR/opt/stack/ mkdir -p $STAGING_DIR/opt/stack/
cp $TOP_DIR/prepare_guest.sh $STAGING_DIR/opt/stack/prepare_guest.sh cp $TOP_DIR/prepare_guest.sh $STAGING_DIR/opt/stack/prepare_guest.sh
@ -53,5 +75,7 @@ cp $STAGING_DIR/etc/rc.local $STAGING_DIR/etc/rc.local.preparebackup
# run prepare_guest.sh on boot # run prepare_guest.sh on boot
cat <<EOF >$STAGING_DIR/etc/rc.local cat <<EOF >$STAGING_DIR/etc/rc.local
GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/prepare_guest.sh > /opt/stack/prepare_guest.log 2>&1 GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ \
DO_TGZ=0 XS_TOOLS_PATH=$XS_TOOLS_PATH \
bash /opt/stack/prepare_guest.sh > /opt/stack/prepare_guest.log 2>&1
EOF EOF