Add bootstrap initrd update for VPI discovery

This change provides extension for the bootstrap discovery image,
by adding an initrd update image, that includes the relevant modules
for the latest bootstrap kernel and extra configuration files.

Change-Id: Id2a5a3ffe97b5a5bd60254168775a4625e34922c
This commit is contained in:
Rawan Herzallah 2016-01-18 15:00:48 +00:00
parent 4d203269d2
commit c86e56b70a
3 changed files with 42 additions and 29 deletions

View File

@ -5,7 +5,7 @@ name: mellanox-plugin
title: Mellanox Openstack features
# Plugin version
version: 2.0.13
version: 2.0.14
# Description
description: Enable features over Mellanox hardware

View File

@ -15,16 +15,17 @@
# limitations under the License.
readonly PLUGIN_DIR="$(dirname $0)"
readonly PLUGIN_VERSION=`cat $PLUGIN_DIR/.version`
readonly REPOSITORY_PATH='bgate.mellanox.com/openstack/mellanox_fuel_plugin/'
readonly PLUGIN_VERSION=`cat ${PLUGIN_DIR}/.version`
readonly REPOSITORY_PATH='bgate.mellanox.com/openstack/mellanox_fuel_plugin'
function download {
FILE_TYPE=$1
FILE_NAME=$2
case ${FILE_TYPE} in
'bootstrap')
PREFIX_URL=$PLUGIN_VERSION/bootstrap
BUILD_DIR=bootstrap
PREFIX_URL=$PLUGIN_VERSION/bootstrap/latest-build
BUILD_DIR=bootstrap/
FILE_NAME=`curl http://${REPOSITORY_PATH}/${PREFIX_URL}/ | tr '<' '\n' | tr '>' '\n' | grep ^$FILE_NAME`
;;
'rpm')
PREFIX_URL=$PLUGIN_VERSION/repositories/centos/Packages
@ -77,8 +78,5 @@ deb_files="cirros-testvm-mellanox_0.3.2-ubuntu3_amd64.deb
get_packages "deb" "$old_debs" "$deb_files"
bootstrap_dir="${PLUGIN_DIR}/bootstrap/"
bootstrap_files="initramfs.img
linux
ofed
kernel"
#get_packages "bootstrap" "$bootstrap_dir" "$bootstrap_files" # Using original bootstrap in 7.0
bootstrap_files="initrd_mlnx_mos*"
get_packages "bootstrap" "$bootstrap_dir" "$bootstrap_files"

View File

@ -1,24 +1,39 @@
%%post
if [ -d "/var/www/nailgun/bootstrap/" ]; then
if [ ! -d "/opt/old_bootstrap_image/" ]; then
mkdir -p /opt/old_bootstrap_image/
#%%post
FUEL_BOOTSTRAP_DIR="/var/www/nailgun/bootstrap/"
PLUGINS_DIR="/var/www/nailgun/plugins/"
BOOTSTRAP_BACKUP_DIR="/opt/old_bootstrap_initrd/"
if [ -d $FUEL_BOOTSTRAP_DIR ]; then
if [ ! -d $BOOTSTRAP_BACKUP_DIR ]; then
mkdir -p $BOOTSTRAP_BACKUP_DIR
fi
# If an old bootstrap already exists in the backup dir do not override it with the plugins's new bootstrap
if [ ! -f /opt/old_bootstrap_image/initramfs.img ]; then
\cp /var/www/nailgun/bootstrap/initramfs.img /opt/old_bootstrap_image/
\cp /var/www/nailgun/bootstrap/linux /opt/old_bootstrap_image/
fi
if ! [[ `grep release /etc/fuel/version.yaml | grep "7.0"` ]]; then
\cp $(ls /var/www/nailgun/plugins/mellanox-plugin*/bootstrap/initramfs.img) /var/www/nailgun/bootstrap/
\cp $(ls /var/www/nailgun/plugins/mellanox-plugin*/bootstrap/linux) /var/www/nailgun/bootstrap/
command -v dockerctl >/dev/null 2>&1
if [ $? -eq 0 ];then
dockerctl copy /var/www/nailgun/bootstrap/initramfs.img cobbler:/var/lib/tftpboot/images/bootstrap/initramfs.img
dockerctl copy /var/www/nailgun/bootstrap/linux cobbler:/var/lib/tftpboot/images/bootstrap/linux
\cp $(ls /var/www/nailgun/plugins/mellanox-plugin*/scripts/reboot_bootstrap_nodes) /sbin/
echo " `tput bold`Bootstrap discovery image has been replaced for detecting Mellanox Infiniband HW."
echo " please reboot your old bootstrap nodes ('reboot_bootstrap_nodes [-e environment_id] [-a] [-h]' can be used).`tput sgr0`"
# Backup all available initrd_mlnx* in Fuel bootstrap dir
for i in `ls $FUEL_BOOTSTRAP_DIR | grep initrd_mlnx`
do
if [ ! -f $BOOTSTRAP_BACKUP_DIR/$i ]; then
\mv $FUEL_BOOTSTRAP_DIR/$i $BOOTSTRAP_BACKUP_DIR
fi
done
\cp $(ls $PLUGINS_DIR/mellanox-plugin*/bootstrap/initrd_mlnx*) $FUEL_BOOTSTRAP_DIR
command -v dockerctl >/dev/null 2>&1
if [ $? -eq 0 ];then
dockerctl copy $(ls $FUEL_BOOTSTRAP_DIR/initrd_mlnx*) cobbler:/var/lib/tftpboot/
\cp $(ls $PLUGINS_DIR/mellanox-plugin*/scripts/reboot_bootstrap_nodes) /sbin/
cobbler_profile_vars=$(dockerctl shell cobbler cobbler profile dumpvars --name=bootstrap | grep "kernel_options :" | cut -d':' -f2-)
initrd_update_image=$(ls $PLUGINS_DIR/mellanox-plugin*/bootstrap/ | grep initrd_mlnx* )
prefix=`echo "initrd=$initrd_update_image"`
if [[ ! $cobbler_profile_vars == *$initrd_update_image* ]]
then
# Add the initrd update if not in cobbler vars
new_cobbler_profile_vars=$(echo " $prefix $(echo $cobbler_profile_vars | sed s/initrd=.*img//)")
dockerctl shell cobbler cobbler profile edit --name bootstrap --kopts="${new_cobbler_profile_vars}"
fi
dockerctl shell cobbler cobbler sync
echo " `tput bold`Bootstrap discovery image has been replaced for detecting Mellanox Infiniband HW."
echo " please reboot your old bootstrap nodes ('reboot_bootstrap_nodes [-e environment_id] [-a] [-h]' can be used).`tput sgr0`"
fi
fi