Add options for Spark and Vanilla plugins

Add the '-p' commandline option to the diskimage-builder script to
select which Savanna plugin to target during image generation.
Vanilla and Spark plugins are supported. By default (if no option is
specified) the Vanilla plugin is selected.

Change-Id: I76af023ebd47bb026308b6034cacf01360739be1
This commit is contained in:
Daniele Venzano 2014-02-10 11:05:37 +01:00
parent f8567e5b2c
commit 15b81ac7d9
2 changed files with 72 additions and 29 deletions

View File

@ -1,7 +1,7 @@
Diskimage-builder script for creation cloud images
==================================================
This scrtips builds Ubuntu, Fedora, CentOS cloud images with default parameters.
This script builds Ubuntu, Fedora, CentOS cloud images for use in Savanna. By default the Vanilla plugin is targeted, the '-p' option can be used to select other plugins.
NOTE: You should use Ubuntu or Fedora host OS for building images, CentOS as a host OS has not been tested well.
@ -21,6 +21,12 @@ For users:
sudo USE_MIRRORS=true FEDORA_MIRROR="url_for_fedora_mirror" UBUNTU_MIRROR="url_for_ubuntu_mirror" bash savanna-image-elements/diskimage-create/diskimage-create.sh
4. To select which plugin to target use the '-p' commandline option like this:
.. sourcecode:: bash
sudo bash savanna-image-elements/diskimage-create/diskimage-create.sh -p [vanilla|spark]
For developers:
1. If you want to add your element to this repository, you should edit this script in your commit (you should export variables for your element and add name of element to variables 'element_sequence').

View File

@ -2,15 +2,43 @@
set -e
# Export variables for elements
while getopts "p:" opt; do
case $opt in
p)
PLUGIN=$OPTARG
;;
*)
echo
echo "Usage: $0 [-p vanilla|spark]"
echo "By default the vanilla plugin will be selected"
exit
;;
esac
done
export DIB_HADOOP_VERSION="1.2.1"
# Default
if [ -z "$PLUGIN" ]; then
PLUGIN="vanilla"
fi
# Sanity checks
if [ "$PLUGIN" != "vanilla" -a "$PLUGIN" != "spark" ]; then
echo -e "Unknown plugin selected.\nAborting"
exit 1
fi
echo "Selected Savanna plugin $PLUGIN"
# Export variables for elements
if [ $PLUGIN = "spark" ]; then
export DIB_HADOOP_VERSION="2.0.0-mr1-cdh4.5.0"
elif [ $PLUGIN = "vanilla" ]; then
export DIB_HADOOP_VERSION="1.2.1"
export fedora_image_name="fedora_savanna_latest"
export centos_image_name="centos_savanna_latest"
export OOZIE_DOWNLOAD_URL="http://savanna-files.mirantis.com/oozie-4.0.0.tar.gz"
export HIVE_VERSION="0.11.0"
fi
export JAVA_DOWNLOAD_URL="http://download.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-x64.tar.gz"
export ubuntu_image_name="ubuntu_savanna_latest"
export fedora_image_name="fedora_savanna_latest"
export centos_image_name="centos_savanna_latest"
export OOZIE_DOWNLOAD_URL="http://savanna-files.mirantis.com/oozie-4.0.0.tar.gz"
export HIVE_VERSION="0.11.0"
if [ -e /etc/os-release ]; then
platform=$(head -1 /etc/os-release)
@ -71,13 +99,17 @@ pushd $SIM_REPO_PATH
export SAVANNA_ELEMENTS_COMMIT_ID=`git rev-parse HEAD`
popd
ubuntu_elements_sequence="base vm ubuntu hadoop swift_hadoop oozie mysql hive"
fedora_elements_sequence="base vm fedora hadoop swift_hadoop oozie mysql hive"
centos_elements_sequence="vm rhel hadoop swift_hadoop oozie mysql hive redhat-lsb"
if [ $PLUGIN = "spark" ]; then
ubuntu_elements_sequence="base vm ubuntu hadoop-cdh spark"
elif [ $PLUGIN = "vanilla" ]; then
ubuntu_elements_sequence="base vm ubuntu hadoop swift_hadoop oozie mysql hive"
fedora_elements_sequence="base vm fedora hadoop swift_hadoop oozie mysql hive"
centos_elements_sequence="vm rhel hadoop swift_hadoop oozie mysql hive redhat-lsb"
fi
# Workaround for https://bugs.launchpad.net/diskimage-builder/+bug/1204824
# https://bugs.launchpad.net/savanna/+bug/1252684
if [ "$platform" = 'NAME="Ubuntu"' ]; then
if [ $PLUGIN != "spark" -a "$platform" = 'NAME="Ubuntu"' ]; then
echo "**************************************************************"
echo "WARNING: As a workaround for DIB bug 1204824, you are about to"
echo " create a Fedora and CentOS images that has SELinux "
@ -93,29 +125,34 @@ fi
if [ -n "$USE_MIRRORS" ]; then
mirror_element=" apt-mirror"
ubuntu_elements_sequence=$ubuntu_elements_sequence$mirror_element
mirror_element=" yum-mirror"
fedora_elements_sequence=$fedora_elements_sequence$mirror_element
if [ $PLUGIN != "spark" ]; then
mirror_element=" yum-mirror"
fedora_elements_sequence=$fedora_elements_sequence$mirror_element
fi
fi
# Creating Ubuntu cloud image
disk-image-create $ubuntu_elements_sequence -o $ubuntu_image_name
# Creating Fedora cloud image
disk-image-create $fedora_elements_sequence -o $fedora_image_name
# CentOS cloud image:
# - Disable including 'base' element for CentOS
# - Export link and filename for CentOS cloud image to download
# - Patameter 'DIB_IMAGE_SIZE' should be specified for CentOS only
export DIB_IMAGE_SIZE="10"
export BASE_IMAGE_FILE="CentOS-6.4-cloud-init.qcow2"
export DIB_CLOUD_IMAGES="http://savanna-files.mirantis.com"
# Read Create_CentOS_cloud_image.rst to know how to create CentOS image in qcow2 format
disk-image-create $centos_elements_sequence -n -o $centos_image_name
mv $fedora_image_name.qcow2 ../
mv $ubuntu_image_name.qcow2 ../
mv $centos_image_name.qcow2 ../
# Spark uses CDH that is available only for Ubuntu
if [ $PLUGIN != "spark" ]; then
# Creating Fedora cloud image
disk-image-create $fedora_elements_sequence -o $fedora_image_name
# CentOS cloud image:
# - Disable including 'base' element for CentOS
# - Export link and filename for CentOS cloud image to download
# - Patameter 'DIB_IMAGE_SIZE' should be specified for CentOS only
export DIB_IMAGE_SIZE="10"
export BASE_IMAGE_FILE="CentOS-6.4-cloud-init.qcow2"
export DIB_CLOUD_IMAGES="http://savanna-files.mirantis.com"
# Read Create_CentOS_cloud_image.rst to know how to create CentOS image in qcow2 format
disk-image-create $centos_elements_sequence -n -o $centos_image_name
mv $fedora_image_name.qcow2 ../
mv $centos_image_name.qcow2 ../
fi
popd # out of $TEMP
rm -rf $TEMP