Move tripleo.sh into tripleo-ci repo

We're discovering that everything needs backporting into both branches
despite the script handling both branches anyway.  Given that this
is designed only for developer and CI usage, we may as well save this
effort and move the script here instead.

When this is all working, we can remove the script from tripleo-common
and add a README instead pointing developers to the new location.

This is based on the content of tripleo-common at 6031198 - tripleo.sh
is unchanged except for adjusting the TENANT_PINGTEST_TEMPLATE path.

Change-Id: I9f3df108514a9d5f456e1c467993b778a2f91d89
This commit is contained in:
Steven Hardy 2016-01-25 18:00:46 +00:00 committed by Derek Higgins
parent 2a33763a7e
commit 118ee50747
7 changed files with 940 additions and 20 deletions

70
scripts/common_functions.sh Executable file
View File

@ -0,0 +1,70 @@
# Tripleo CI functions
# Revert a commit for tripleo ci
# $1 : project name e.g. nova
# $2 : hash id of commit to revert
# $3 : bug id of reason for revert (used to skip revert if found in commit
# that triggers ci).
function temprevert(){
# Before reverting check to ensure this isn't the related fix
if git --git-dir=/opt/stack/new/${ZUUL_PROJECT#*/}/.git log -1 | grep -iE "bug.*$3" ; then
echo "Skipping temprevert because bug fix $3 was found in git message."
return 0
fi
pushd /opt/stack/new/$1
# Abort on fail so we're not left in a conflict state
git revert --no-edit $2 || git revert --abort || true
popd
}
# Pin to a commit for tripleo ci
# $1 : project name e.g. nova
# $2 : hash id of commit to pin too
# $3 : bug id of reason for the pin (used to skip revert if found in commit
# that triggers ci).
function pin(){
# Before reverting check to ensure this isn't the related fix
if git --git-dir=/opt/stack/new/${ZUUL_PROJECT#*/}/.git log -1 | grep -iE "bug.*$3" ; then
echo "Skipping pin because bug fix $3 was found in git message."
return 0
fi
pushd /opt/stack/new/$1
git reset --hard $2
popd
}
# Cherry-pick a commit for tripleo ci
# $1 : project name e.g. nova
# $2 : Gerrit refspec to cherry pick
# $3 : bug id of reason for the cherry pick (used to skip cherry pick if found
# in commit that triggers ci).
function cherrypick(){
local PROJ_NAME=$1
local REFSPEC=$2
# Before cherrypicking check to ensure this isn't the related fix
if git --git-dir=/opt/stack/new/${ZUUL_PROJECT#*/}/.git log -1 | grep -iE "bug.*$3" ; then
echo "Skipping cherrypick because bug fix $3 was found in git message."
return 0
fi
pushd /opt/stack/new/$PROJ_NAME
git fetch https://review.openstack.org/openstack/$PROJ_NAME "$REFSPEC"
# Abort on fail so we're not left in a conflict state
git cherry-pick FETCH_HEAD || git cherry-pick --abort
popd
# Export a DIB_REPOREF variable as well
export DIB_REPOREF_${PROJ_NAME//-/_}=$REFSPEC
}
# echo's out a project name from a ref
# $1 : e.g. openstack/nova:master:refs/changes/87/64787/3 returns nova
function filterref(){
PROJ=${1%%:*}
PROJ=${PROJ##*/}
echo $PROJ
}

View File

@ -8,7 +8,7 @@ export DIB_DISTRIBUTION_MIRROR=$CENTOS_MIRROR
export DIB_EPEL_MIRROR=$EPEL_MIRROR
echo "INFO: Check /var/log/undercloud_install.txt for undercloud install output"
/tmp/tripleo-common/scripts/tripleo.sh --undercloud 2>&1 | sudo dd of=/var/log/undercloud_install.txt
/tmp/tripleo-ci/scripts/tripleo.sh --undercloud 2>&1 | sudo dd of=/var/log/undercloud_install.txt
if [ $INTROSPECT == 1 ] ; then
# I'm removing most of the nodes in the env to speed up discovery
# This could be in jq but I don't know how
@ -52,12 +52,12 @@ fi
export DIB_NO_TMPFS=1
# Directing the output of this command to a file as its extreemly verbose
echo "INFO: Check /var/log/image_build.txt for image build output"
/tmp/tripleo-common/scripts/tripleo.sh --overcloud-images | sudo dd of=/var/log/image_build.txt
/tmp/tripleo-ci/scripts/tripleo.sh --overcloud-images | sudo dd of=/var/log/image_build.txt
/tmp/tripleo-common/scripts/tripleo.sh --register-nodes
/tmp/tripleo-ci/scripts/tripleo.sh --register-nodes
if [ $INTROSPECT == 1 ] ; then
/tmp/tripleo-common/scripts/tripleo.sh --introspect-nodes
/tmp/tripleo-ci/scripts/tripleo.sh --introspect-nodes
fi
sleep 60
@ -68,8 +68,8 @@ nova flavor-delete baremetal
nova flavor-create --swap 1024 baremetal auto 4096 39 1
nova flavor-key baremetal set capabilities:boot_option=local
export OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS -e /tmp/worker-config.yaml"
http_proxy= /tmp/tripleo-common/scripts/tripleo.sh --overcloud-deploy ${TRIPLEO_SH_ARGS:-}
export OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS -e /tmp/tripleo-ci/test-environments/worker-config.yaml"
http_proxy= /tmp/tripleo-ci/scripts/tripleo.sh --overcloud-deploy ${TRIPLEO_SH_ARGS:-}
# Sanity test we deployed what we said we would
source ~/stackrc
@ -85,4 +85,4 @@ if [ $PACEMAKER == 1 ] ; then
fi
source ~/overcloudrc
OVERCLOUD_PINGTEST_OLD_HEATCLIENT=0 /tmp/tripleo-common/scripts/tripleo.sh --overcloud-pingtest
OVERCLOUD_PINGTEST_OLD_HEATCLIENT=0 /tmp/tripleo-ci/scripts/tripleo.sh --overcloud-pingtest

52
scripts/set-os-type Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
TRIPLEO_OS_FAMILY='unsupported' # Generic OS Family: debian, redhat, suse
TRIPLEO_OS_DISTRO='unsupported' # Specific distro: centos, fedora, rhel,
# opensuse, sles, ubuntu
if [ -f /etc/redhat-release ]; then
TRIPLEO_OS_FAMILY='redhat'
if $(grep -Eqs 'Red Hat Enterprise Linux' /etc/redhat-release); then
TRIPLEO_OS_DISTRO='rhel'
fi
if $(grep -Eqs 'Derived from Red Hat Enterprise Linux' /etc/redhat-release); then
TRIPLEO_OS_DISTRO='centos'
fi
if $(grep -Eqs 'CentOS' /etc/redhat-release); then
TRIPLEO_OS_DISTRO='centos'
fi
if $(grep -Eqs 'Fedora' /etc/redhat-release); then
TRIPLEO_OS_DISTRO='fedora'
fi
fi
if [ -f /etc/debian_version ]; then
TRIPLEO_OS_FAMILY='debian'
if $(grep -Eqs 'Ubuntu' /etc/lsb-release); then
TRIPLEO_OS_DISTRO='ubuntu'
fi
if $(grep -Eqs 'Debian' /etc/os-release); then
TRIPLEO_OS_DISTRO='debian'
fi
fi
function get_os_release {
(
source /etc/os-release
echo $ID
)
}
if [ -f /etc/os-release ]; then
if [ "$(get_os_release)" = "opensuse" ]; then
TRIPLEO_OS_FAMILY='suse'
TRIPLEO_OS_DISTRO='opensuse'
fi
if [ "$(get_os_release)" = "sles" ]; then
TRIPLEO_OS_FAMILY='suse'
TRIPLEO_OS_DISTRO='sles'
fi
fi
export TRIPLEO_OS_FAMILY
export TRIPLEO_OS_DISTRO

677
scripts/tripleo.sh Executable file
View File

@ -0,0 +1,677 @@
#!/bin/bash
# Copyright 2015 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
##############################################################################
# tripleo.sh is a script to automate a TripleO setup. It's goals are to be
# used in aiding:
#
# - developer setups
# - CI
# - documentation generation (hopefully)
#
# It's not a new CLI, or end user facing wrapper around existing TripleO
# CLI's.
#
# tripleo.sh should never contain any "business" logic in it that is
# necessary for a successful deployment. It should instead just mirror the
# steps that we document for TripleO end users.
#
##############################################################################
set -eu
set -o pipefail
SCRIPT_NAME=${SCRIPT_NAME:-$(basename $0)}
function show_options {
echo "Usage: $SCRIPT_NAME [options]"
echo
echo "Automates TripleO setup steps."
echo
echo "$SCRIPT_NAME is also configurable via environment variables, most of"
echo "which are not exposed via cli args for simplicity. See the source"
echo "for the set of environment variables that can be overridden."
echo
echo "Note that cli args always take precedence over environment"
echo "variables."
echo
echo "Options:"
echo " --repo-setup -- Perform repository setup."
echo " --delorean-setup -- Install local delorean build environment."
echo " --delorean-build -- Build a delorean package locally"
echo " --undercloud -- Install the undercloud."
echo " --overcloud-images -- Build and load overcloud images."
echo " --register-nodes -- Register and configure nodes."
echo " --introspect-nodes -- Introspect nodes."
echo " --overcloud-deploy -- Deploy an overcloud."
echo " --overcloud-update -- Update a deployed overcloud."
echo " --overcloud-delete -- Delete the overcloud."
echo " --use-containers -- Use a containerized compute node."
echo " --enable-check -- Enable checks on update."
echo " --overcloud-pingtest -- Run a tenant vm, attach and ping floating IP."
echo " --all, -a -- Run all of the above commands."
echo " -x -- enable tracing"
echo " --help, -h -- Print this help message."
echo
exit 1
}
if [ ${#@} = 0 ]; then
show_options
exit 1
fi
TEMP=$(getopt -o ,h \
-l,help,repo-setup,delorean-setup,delorean-build,undercloud,overcloud-images,register-nodes,introspect-nodes,overcloud-deploy,overcloud-update,overcloud-delete,use-containers,overcloud-pingtest,all,enable-check \
-o,x,h,a \
-n $SCRIPT_NAME -- "$@")
if [ $? != 0 ]; then
show_options
exit 1
fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
ALL=${ALL:-""}
CONTAINER_ARGS=${CONTAINER_ARGS:-"-e /usr/share/openstack-tripleo-heat-templates/environments/docker.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/docker-network.yaml --libvirt-type=qemu"}
STABLE_RELEASE=${STABLE_RELEASE:-}
DELOREAN_REPO_FILE=${DELOREAN_REPO_FILE:-"delorean.repo"}
DELOREAN_REPO_URL=${DELOREAN_REPO_URL:-"\
http://trunk.rdoproject.org/centos7/current-tripleo/"}
DELOREAN_STABLE_REPO_URL=${DELOREAN_STABLE_REPO_URL:-"\
https://trunk.rdoproject.org/centos7-$STABLE_RELEASE/current/"}
ATOMIC_URL=${ATOMIC_URL:-"https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Atomic-22-20150521.x86_64.qcow2"}
INSTACKENV_JSON_PATH=${INSTACKENV_JSON_PATH:-"$HOME/instackenv.json"}
INTROSPECT_NODES=${INTROSPECT_NODES:-""}
REGISTER_NODES=${REGISTER_NODES:-""}
OVERCLOUD_DEPLOY=${OVERCLOUD_DEPLOY:-""}
OVERCLOUD_DELETE=${OVERCLOUD_DELETE:-""}
OVERCLOUD_DELETE_TIMEOUT=${OVERCLOUD_DELETE_TIMEOUT:-"300"}
OVERCLOUD_DEPLOY_ARGS=${OVERCLOUD_DEPLOY_ARGS:-""}
OVERCLOUD_UPDATE=${OVERCLOUD_UPDATE:-""}
OVERCLOUD_UPDATE_RM_FILES=${OVERCLOUD_UPDATE_RM_FILES:-"1"}
OVERCLOUD_UPDATE_ARGS=${OVERCLOUD_UPDATE_ARGS:-"$OVERCLOUD_DEPLOY_ARGS"}
OVERCLOUD_UPDATE_CHECK=${OVERCLOUD_UPDATE_CHECK:-}
OVERCLOUD_IMAGES_PATH=${OVERCLOUD_IMAGES_PATH:-"$HOME"}
OVERCLOUD_IMAGES=${OVERCLOUD_IMAGES:-""}
OVERCLOUD_IMAGES_ARGS=${OVERCLOUD_IMAGES_ARGS='--all'}
OVERCLOUD_NAME=${OVERCLOUD_NAME:-"overcloud"}
OVERCLOUD_PINGTEST=${OVERCLOUD_PINGTEST:-""}
REPO_SETUP=${REPO_SETUP:-""}
REPO_PREFIX=${REPO_PREFIX:-"/etc/yum.repos.d/"}
OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF=${OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF:-"\
$REPO_PREFIX/delorean.repo \
$REPO_PREFIX/delorean-current.repo \
$REPO_PREFIX/delorean-deps.repo"}
DELOREAN_SETUP=${DELOREAN_SETUP:-""}
DELOREAN_BUILD=${DELOREAN_BUILD:-""}
STDERR=/dev/null
UNDERCLOUD=${UNDERCLOUD:-""}
UNDERCLOUD_CONF=${UNDERCLOUD_CONF:-"/usr/share/instack-undercloud/undercloud.conf.sample"}
TRIPLEO_ROOT=${TRIPLEO_ROOT:-$HOME/tripleo}
USE_CONTAINERS=${USE_CONTAINERS:-""}
# TODO: remove this when Image create in openstackclient supports the v2 API
export OS_IMAGE_API_VERSION=1
# Temporary workarounds
while true ; do
case "$1" in
--all|-a ) ALL="1"; shift 1;;
--use-containers) USE_CONTAINERS="1"; shift 1;;
--enable-check) OVERCLOUD_UPDATE_CHECK="1"; shift 1;;
--introspect-nodes) INTROSPECT_NODES="1"; shift 1;;
--register-nodes) REGISTER_NODES="1"; shift 1;;
--overcloud-deploy) OVERCLOUD_DEPLOY="1"; shift 1;;
--overcloud-update) OVERCLOUD_UPDATE="1"; shift 1;;
--overcloud-delete) OVERCLOUD_DELETE="1"; shift 1;;
--overcloud-images) OVERCLOUD_IMAGES="1"; shift 1;;
--overcloud-pingtest) OVERCLOUD_PINGTEST="1"; shift 1;;
--repo-setup) REPO_SETUP="1"; shift 1;;
--delorean-setup) DELOREAN_SETUP="1"; shift 1;;
--delorean-build) DELOREAN_BUILD="1"; shift 1;;
--undercloud) UNDERCLOUD="1"; shift 1;;
-x) set -x; STDERR=/dev/stderr; shift 1;;
-h | --help) show_options 0;;
--) shift ; break ;;
*) echo "Error: unsupported option $1." ; exit 1 ;;
esac
done
function log {
echo "#################"
echo -n "$SCRIPT_NAME -- "
echo $@
echo "#################"
}
function source_rc {
if [ $1 = "stackrc" ] ; then cloud="Undercloud"; else cloud="Overcloud"; fi
echo "You must source a $1 file for the $cloud."
echo "Attempting to source $HOME/$1"
source $HOME/$1
echo "Done"
}
function stackrc_check {
source_rc "stackrc"
}
function overcloudrc_check {
source_rc "overcloudrc"
}
function repo_setup {
log "Repository setup"
# sets $TRIPLEO_OS_FAMILY and $TRIPLEO_OS_DISTRO
source $(dirname ${BASH_SOURCE[0]:-$0})/set-os-type
if [ "$TRIPLEO_OS_DISTRO" = "centos" ]; then
# Enable epel
rpm -q epel-release || sudo yum -y install epel-release
fi
if [ -z "$STABLE_RELEASE" ]; then
# Enable the Delorean Deps repository
sudo curl -o $REPO_PREFIX/delorean-deps.repo http://trunk.rdoproject.org/centos7/delorean-deps.repo
sudo sed -i -e 's%priority=.*%priority=30%' $REPO_PREFIX/delorean-deps.repo
# Enable last known good RDO Trunk Delorean repository
sudo curl -o $REPO_PREFIX/delorean.repo $DELOREAN_REPO_URL/$DELOREAN_REPO_FILE
sudo sed -i -e 's%priority=.*%priority=20%' $REPO_PREFIX/delorean.repo
# Enable latest RDO Trunk Delorean repository
sudo curl -o $REPO_PREFIX/delorean-current.repo http://trunk.rdoproject.org/centos7/current/delorean.repo
sudo sed -i -e 's%priority=.*%priority=10%' $REPO_PREFIX/delorean-current.repo
sudo sed -i 's/\[delorean\]/\[delorean-current\]/' $REPO_PREFIX/delorean-current.repo
sudo /bin/bash -c "cat <<-EOF>>$REPO_PREFIX/delorean-current.repo
includepkgs=diskimage-builder,instack,instack-undercloud,os-apply-config,os-cloud-config,os-collect-config,os-net-config,os-refresh-config,python-tripleoclient,tripleo-common,openstack-tripleo-heat-templates,openstack-tripleo-image-elements,openstack-tripleo,openstack-tripleo-puppet-elements
EOF"
else
# Enable the Delorean Deps repository
sudo curl -o $REPO_PREFIX/delorean-deps.repo http://trunk.rdoproject.org/centos7-$STABLE_RELEASE/delorean-deps.repo
sudo sed -i -e 's%priority=.*%priority=30%' $REPO_PREFIX/delorean-deps.repo
# Enable delorean current for the stable version
sudo curl -o $REPO_PREFIX/delorean.repo $DELOREAN_STABLE_REPO_URL/$DELOREAN_REPO_FILE
sudo sed -i -e 's%priority=.*%priority=20%' /etc/yum.repos.d/delorean.repo
# Create empty delorean-current for dib image building
sudo sh -c "> $REPO_PREFIX/delorean-current.repo"
fi
# Install the yum-plugin-priorities package so that the Delorean repository
# takes precedence over the main RDO repositories.
sudo yum -y install yum-plugin-priorities
log "Repository setup - DONE."
}
function delorean_setup {
log "Delorean setup"
# Install delorean as per combination of toci-instack and delorean docs
sudo yum install -y createrepo git mock python-virtualenv rpm-build yum-plugin-priorities yum-utils gcc
# Add the current user to the mock group
sudo usermod -G mock -a $(id -nu)
mkdir -p $TRIPLEO_ROOT
[ -d $TRIPLEO_ROOT/delorean ] || git clone https://github.com/openstack-packages/delorean.git $TRIPLEO_ROOT/delorean
pushd $TRIPLEO_ROOT/delorean
sudo rm -rf data commits.sqlite
mkdir -p data
sed -i -e "s%reponame=.*%reponame=delorean-ci%" projects.ini
sed -i -e "s%target=.*%target=centos%" projects.ini
# Remove the rpm install test to speed up delorean (our ci test will to this)
# TODO: add an option for this in delorean
sed -i -e 's%.*installed.*%touch $OUTPUT_DIRECTORY/installed%' scripts/build_rpm.sh
virtualenv venv
./venv/bin/pip install -r requirements.txt
./venv/bin/python setup.py install
popd
log "Delorean setup - DONE."
}
function delorean_build {
log "Delorean build"
export PATH=/sbin:/usr/sbin:$PATH
source $(dirname ${BASH_SOURCE[0]:-$0})/common_functions.sh
pushd $TRIPLEO_ROOT/delorean
if [ -z "$STABLE_RELEASE" ]; then
sed -i -e "s%baseurl=.*%baseurl=https://trunk.rdoproject.org/centos7%" projects.ini
sed -i -e "s%distro=.*%distro=rpm-master%" projects.ini
sed -i -e "s%source=.*%source=master%" projects.ini
else
sed -i -e "s%baseurl=.*%baseurl=https://trunk.rdoproject.org/centos7-$STABLE_RELEASE%" projects.ini
sed -i -e "s%distro=.*%distro=rpm-$STABLE_RELEASE%" projects.ini
sed -i -e "s%source=.*%source=stable/$STABLE_RELEASE%" projects.ini
fi
sudo rm -rf data commits.sqlite
mkdir -p data
# build packages
# loop through each of the projects listed in DELOREAN_BUILD_REFS, if it is a project we
# are capable of building an rpm for then build it.
# e.g. DELOREAN_BUILD_REFS="openstack/cinder openstack/heat etc.."
for PROJ in $DELOREAN_BUILD_REFS ; do
log "Building $PROJ"
PROJ=$(filterref $PROJ)
# Clone the repo if it doesn't yet exist
if [ ! -d $TRIPLEO_ROOT/$PROJ ]; then
git clone https://git.openstack.org/openstack/$PROJ.git $TRIPLEO_ROOT/$PROJ
if [ ! -z "$STABLE_RELEASE" ]; then
pushd $TRIPLEO_ROOT/$PROJ
git checkout -b stable/$STABLE_RELEASE origin/stable/$STABLE_RELEASE
popd
fi
fi
MAPPED_PROJ=$(./venv/bin/python scripts/map-project-name $PROJ || true)
[ -e data/$MAPPED_PROJ ] && continue
cp -r $TRIPLEO_ROOT/$PROJ data/$MAPPED_PROJ
pushd data/$MAPPED_PROJ
GITHASH=$(git rev-parse HEAD)
# Set the branches delorean reads to the same git hash as PROJ has left for us
for BRANCH in master origin/master stable/liberty origin/stable/liberty; do
git checkout -b $BRANCH || git checkout $BRANCH
git reset --hard $GITHASH
done
popd
while true; do
DELOREANCMD="./venv/bin/delorean --config-file projects.ini --head-only --package-name $MAPPED_PROJ --local --build-env DELOREAN_DEV=1 --build-env http_proxy=${http_proxy:-} --info-repo rdoinfo"
# Using sudo to su a command as ourselves to run the command with a new login
# to ensure the addition to the mock group has taken effect.
sudo su $(id -nu) -c "$DELOREANCMD" || true
# If delorean fails due to a network error it will mark it to be retried up to 3 times
# Test the status and run delorean again if it is not SUCCESS or FAILED
STATUS=$(echo "select status from commits where project_name == \"$MAPPED_PROJ\" order by id desc limit 1;" | sqlite3 commits.sqlite)
if [ "$STATUS" == "FAILED" ] ; then
exit 1
elif [ "$STATUS" == "SUCCESS" ] ; then
break
elif [ "$STATUS" == "RETRY" ] ; then
continue
fi
exit 1
done
done
popd
log "Delorean build - DONE."
}
function undercloud {
log "Undercloud install"
# We use puppet modules from source by default for master, for stable we
# currently use a stable package (we may eventually want to use a
# stable-puppet-modules element instead so we can set DIB_REPOREF.., etc)
if [ -z "$STABLE_RELEASE" ]; then
export DIB_INSTALLTYPE_puppet_modules=${DIB_INSTALLTYPE_puppet_modules:-source}
else
export DIB_INSTALLTYPE_puppet_modules=${DIB_INSTALLTYPE_puppet_modules:-}
fi
# pin for https://bugs.launchpad.net/tripleo/+bug/1539797
export DIB_REPOREF_puppetlabs_concat=f3de395019928ceaca479a830a9fa63909941736
sudo yum install -y python-tripleoclient
if [ ! -f ~/undercloud.conf ]; then
cp -b -f $UNDERCLOUD_CONF ~/undercloud.conf
else
log "~/undercloud.conf already exists, not overwriting"
fi
# Hostname check, add to /etc/hosts if needed
if ! grep -E "^127.0.0.1\s*$HOSTNAME" /etc/hosts; then
sudo /bin/bash -c "echo \"127.0.0.1 $HOSTNAME\" >> /etc/hosts"
fi
openstack undercloud install
log "Undercloud install - DONE."
}
function overcloud_images {
log "Overcloud images"
log "Overcloud images saved in $OVERCLOUD_IMAGES_PATH"
# We use puppet modules from source by default for master, for stable we
# currently use a stable package (we may eventually want to use a
# stable-puppet-modules element instead so we can set DIB_REPOREF.., etc)
if [ -z "$STABLE_RELEASE" ]; then
export DIB_INSTALLTYPE_puppet_modules=${DIB_INSTALLTYPE_puppet_modules:-source}
else
export DIB_INSTALLTYPE_puppet_modules=${DIB_INSTALLTYPE_puppet_modules:-}
fi
# pin for https://bugs.launchpad.net/tripleo/+bug/1539797
export DIB_REPOREF_puppetlabs_concat=f3de395019928ceaca479a830a9fa63909941736
# (slagle) TODO: This needs to be fixed in python-tripleoclient or
# diskimage-builder!
# Ensure yum-plugin-priorities is installed
echo -e '#!/bin/bash\nyum install -y yum-plugin-priorities' | sudo tee /usr/share/diskimage-builder/elements/yum/pre-install.d/99-tmphacks
sudo chmod +x /usr/share/diskimage-builder/elements/yum/pre-install.d/99-tmphacks
# To install the undercloud instack-undercloud is run as root,
# as a result all of the git repositories get cached to
# ~root/.cache/image-create/source-repositories, lets not clone them again
if [ -d ~root/.cache/image-create/source-repositories ] && \
[ ! -d ~/.cache/image-create/source-repositories ] ; then
sudo cp -r ~root/.cache/image-create/source-repositories ~/.cache/image-create/source-repositories
sudo chown -R $(id -u) ~/.cache/image-create/source-repositories
fi
log "Overcloud images saved in $OVERCLOUD_IMAGES_PATH"
pushd $OVERCLOUD_IMAGES_PATH
DIB_YUM_REPO_CONF=$OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF \
openstack overcloud image build $OVERCLOUD_IMAGES_ARGS 2>&1 | \
tee -a overcloud-image-build.log
stackrc_check
openstack overcloud image upload --update-existing
popd
log "Overcloud images - DONE."
}
function register_nodes {
log "Register nodes"
if [ ! -f $INSTACKENV_JSON_PATH ]; then
echo Could not find instackenv.json at $INSTACKENV_JSON_PATH
echo Specify the path to instackenv.json with '$INSTACKENV_JSON_PATH'
exit 1
fi
stackrc_check
openstack baremetal import --json $INSTACKENV_JSON_PATH
ironic node-list
openstack baremetal configure boot
log "Register nodes - DONE."
}
function introspect_nodes {
log "Introspect nodes"
stackrc_check
openstack baremetal introspection bulk start
log "Introspect nodes - DONE."
}
function overcloud_deploy {
log "Overcloud deploy"
# Force use of --templates
if [[ ! $OVERCLOUD_DEPLOY_ARGS =~ --templates ]]; then
OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS --templates"
fi
stackrc_check
if [[ $USE_CONTAINERS == 1 ]]; then
if ! glance image-list | grep -q atomic-image; then
wget --progress=dot:mega $ATOMIC_URL
glance image-create --name atomic-image --file `basename $ATOMIC_URL` --disk-format qcow2 --container-format bare
fi
OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS $CONTAINER_ARGS"
fi
log "Overcloud create started."
openstack overcloud deploy $OVERCLOUD_DEPLOY_ARGS
log "Overcloud create - DONE."
}
function overcloud_update {
# Force use of --templates
if [[ ! $OVERCLOUD_UPDATE_ARGS =~ --templates ]]; then
OVERCLOUD_UPDATE_ARGS="$OVERCLOUD_UPDATE_ARGS --templates"
fi
stackrc_check
if heat stack-show "$OVERCLOUD_NAME" | grep "stack_status " | egrep "(CREATE|UPDATE)_COMPLETE"; then
FILE_PREFIX=$(date "+overcloud-update-resources-%s")
BEFORE_FILE="/tmp/${FILE_PREFIX}-before.txt"
AFTER_FILE="/tmp/${FILE_PREFIX}-after.txt"
# This is an update, so if enabled, compare the before/after resource lists
if [ ! -z "$OVERCLOUD_UPDATE_CHECK" ]; then
heat resource-list -n5 overcloud | awk '{print $2, $4, $6}' | sort > $BEFORE_FILE
fi
log "Overcloud update started."
openstack overcloud deploy $OVERCLOUD_UPDATE_ARGS
log "Overcloud update - DONE."
if [ ! -z "$OVERCLOUD_UPDATE_CHECK" ]; then
heat resource-list -n5 overcloud | awk '{print $2, $4, $6}' | sort > $AFTER_FILE
diff_rsrc=$(diff $BEFORE_FILE $AFTER_FILE)
if [ ! -z "$diff_rsrc" ]; then
log "Overcloud update - Completed but unexpected resource differences: $diff_rsrc"
exit 1
fi
fi
log "Overcloud update - DONE."
if [[ $OVERCLOUD_UPDATE_RM_FILES == 1 ]]; then
rm -f $BEFORE_FILE $AFTER_FILE
fi
else
log "Overcloud FAILED - No stack $OVERCLOUD_NAME."
exit 1
fi
}
function overcloud_delete {
log "Overcloud delete"
stackrc_check
# We delete the stack via heat, then wait for it to be deleted
# This should be fairly quick, but we poll for OVERCLOUD_DELETE_TIMEOUT
heat stack-delete "$OVERCLOUD_NAME"
# Note, we need the ID, not the name, as stack-show will only return
# soft-deleted stacks by ID (not name, as it may be reused)
OVERCLOUD_ID=$(heat stack-list | grep "$OVERCLOUD_NAME" | awk '{print $2}')
if $(tripleo wait_for -w $OVERCLOUD_DELETE_TIMEOUT -d 10 -s "DELETE_COMPLETE" -- "heat stack-show $OVERCLOUD_ID"); then
log "Overcloud $OVERCLOUD_ID DELETE_COMPLETE"
else
log "Overcloud $OVERCLOUD_ID delete failed or timed out:"
heat stack-show $OVERCLOUD_ID
exit 1
fi
}
function cleanup_pingtest {
log "Overcloud pingtest, starting cleanup"
overcloudrc_check
heat stack-delete tenant-stack
if $(tripleo wait_for -w 300 -d 10 -s "Stack not found" -- "heat stack-show tenant-stack" ); then
log "Overcloud pingtest - deleted the tenant-stack heat stack"
else
log "Overcloud pingtest - time out waiting to delete tenant heat stack, please check manually"
fi
log "Overcloud pingtest - cleaning demo network 'nova' and 'pingtest_image' image"
glance image-delete pingtest_image
neutron net-delete nova
log "Overcloud pingtest - DONE"
}
function overcloud_pingtest {
log "Overcloud pingtest"
exitval=0
overcloudrc_check
IMAGE_PATH=$OVERCLOUD_IMAGES_PATH/fedora-user.qcow2
if [ ! -e $IMAGE_PATH ]; then
log "Overcloud pingtest, trying to download Fedora image"
curl -L -o $IMAGE_PATH http://cloud.fedoraproject.org/fedora-21.x86_64.qcow2
fi
log "Overcloud pingtest, uploading demo tenant image to glance"
glance image-create --progress --name pingtest_image --is-public True --disk-format qcow2 --container-format bare --file $IMAGE_PATH
log "Overcloud pingtest, creating demo tenant keypair and external network"
if ! nova keypair-show default 2>/dev/null; then tripleo user-config; fi
neutron net-create nova --shared --router:external=True --provider:network_type flat \
--provider:physical_network datacentre
FLOATING_IP_CIDR=${FLOATING_IP_CIDR:-"192.0.2.0/24"}
FLOATING_IP_START=${FLOATING_IP_START:-"192.0.2.50"}
FLOATING_IP_END=${FLOATING_IP_END:-"192.0.2.64"}
EXTERNAL_NETWORK_GATEWAY=${EXTERNAL_NETWORK_GATEWAY:-"192.0.2.1"}
TENANT_STACK_DEPLOY_ARGS=${TENANT_STACK_DEPLOY_ARGS:-""}
neutron subnet-create --name ext-subnet --allocation-pool start=$FLOATING_IP_START,end=$FLOATING_IP_END --disable-dhcp --gateway $EXTERNAL_NETWORK_GATEWAY nova $FLOATING_IP_CIDR
TENANT_PINGTEST_TEMPLATE=/usr/share/tripleo-ci/tenantvm_floatingip.yaml
if [ ! -e $TENANT_PINGTEST_TEMPLATE ]; then
TENANT_PINGTEST_TEMPLATE=$(dirname `readlink -f -- $0`)/../templates/tenantvm_floatingip.yaml
fi
log "Overcloud pingtest, creating tenant-stack heat stack:"
heat stack-create -f $TENANT_PINGTEST_TEMPLATE $TENANT_STACK_DEPLOY_ARGS tenant-stack || exitval=1
if tripleo wait_for -w 360 -d 10 -s "CREATE_COMPLETE" -- "heat stack-list | grep tenant-stack"; then
log "Overcloud pingtest, heat stack CREATE_COMPLETE";
vm1_ip=`heat output-show tenant-stack server1_public_ip -F raw`
# On new Heat clients the above command returns a big long string.
# If the resulting value is longer than an IP address we need the alternate command.
if [ ${#vm1_ip} -gt 15 ]; then
vm1_ip=`heat output-show tenant-stack server1_public_ip -F raw -v`
fi
log "Overcloud pingtest, trying to ping the floating IPs $vm1_ip"
if tripleo wait_for -w 360 -d 10 -s "bytes from $vm1_ip" -- "ping -c 1 $vm1_ip" ; then
ping -c 1 $vm1_ip
log "Overcloud pingtest, SUCCESS"
else
ping -c 1 $vm1_ip || :
nova show Server1 || :
nova service-list || :
neutron agent-list || :
nova console-log Server1 || :
log "Overloud pingtest, FAIL"
exitval=1
fi
else
heat stack-show tenant-stack || :
heat event-list tenant-stack || :
heat resource-list -n 5 tenant-stack || :
log "Overcloud pingtest, failed to create heat stack, trying cleanup"
exitval=1
fi
cleanup_pingtest
exit $exitval
}
if [ "$REPO_SETUP" = 1 ]; then
repo_setup
fi
if [ "$DELOREAN_SETUP" = 1 ]; then
delorean_setup
fi
if [ "$DELOREAN_BUILD" = 1 ]; then
export DELOREAN_BUILD_REFS="${DELOREAN_BUILD_REFS:-$@}"
if [ -z "$DELOREAN_BUILD_REFS" ]; then
echo "Usage: $0 --delorean-build openstack/heat openstack/nova"
exit 1
fi
delorean_build
fi
if [ "$UNDERCLOUD" = 1 ]; then
undercloud
fi
if [ "$OVERCLOUD_IMAGES" = 1 ]; then
overcloud_images
fi
if [ "$REGISTER_NODES" = 1 ]; then
register_nodes
fi
if [ "$INTROSPECT_NODES" = 1 ]; then
introspect_nodes
fi
if [ "$OVERCLOUD_DEPLOY" = 1 ]; then
overcloud_deploy
fi
if [ "$OVERCLOUD_UPDATE" = 1 ]; then
overcloud_update
fi
if [ "$OVERCLOUD_DELETE" = 1 ]; then
overcloud_delete
fi
if [[ "$USE_CONTAINERS" == 1 && "$OVERCLOUD_DEPLOY" != 1 ]]; then
echo "Error: --overcloud-deploy flag is required with the flag --use-containers"
exit 1
fi
if [ "$OVERCLOUD_PINGTEST" = 1 ]; then
overcloud_pingtest
fi
if [ "$ALL" = 1 ]; then
repo_setup
undercloud
overcloud_images
register_nodes
introspect_nodes
overcloud_deploy
fi

View File

@ -0,0 +1,121 @@
heat_template_version: 2013-05-23
# TODO(bnemec): Something with Cinder to verify it is working too.
description: >
HOT template to create a new neutron network plus a router to the public
network, and for deploying a server into the new network. The template also
assigns a floating IP address and sets security group rules. ADAPTED FROM
https://raw.githubusercontent.com/openstack/heat-templates/master/hot/servers_in_new_neutron_net.yaml
parameters:
key_name:
type: string
description: Name of keypair to assign to servers
default: 'default'
image:
type: string
description: Name of image to use for servers
default: 'pingtest_image'
flavor:
type: string
description: Flavor to use for servers
default: 'm1.demo'
public_net_name:
type: string
default: 'nova'
description: >
ID or name of public network for which floating IP addresses will be allocated
private_net_name:
type: string
description: Name of private network to be created
default: 'default-net'
private_net_cidr:
type: string
description: Private network address (CIDR notation)
default: '192.168.2.0/24'
private_net_gateway:
type: string
description: Private network gateway address
default: '192.168.2.1'
private_net_pool_start:
type: string
description: Start of private network IP address allocation pool
default: '192.168.2.100'
private_net_pool_end:
type: string
default: '192.168.2.200'
description: End of private network IP address allocation pool
resources:
private_net:
type: OS::Neutron::Net
properties:
name: { get_param: private_net_name }
private_subnet:
type: OS::Neutron::Subnet
properties:
network_id: { get_resource: private_net }
cidr: { get_param: private_net_cidr }
gateway_ip: { get_param: private_net_gateway }
allocation_pools:
- start: { get_param: private_net_pool_start }
end: { get_param: private_net_pool_end }
router:
type: OS::Neutron::Router
properties:
external_gateway_info:
network: { get_param: public_net_name }
router_interface:
type: OS::Neutron::RouterInterface
properties:
router_id: { get_resource: router }
subnet_id: { get_resource: private_subnet }
server1:
type: OS::Nova::Server
properties:
name: Server1
image: { get_param: image }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: server1_port }
server1_port:
type: OS::Neutron::Port
properties:
network_id: { get_resource: private_net }
fixed_ips:
- subnet_id: { get_resource: private_subnet }
security_groups: [{ get_resource: server_security_group }]
server1_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network: { get_param: public_net_name }
port_id: { get_resource: server1_port }
server_security_group:
type: OS::Neutron::SecurityGroup
properties:
description: Add security group rules for server
name: pingtest-security-group
rules:
- remote_ip_prefix: 0.0.0.0/0
protocol: tcp
port_range_min: 22
port_range_max: 22
- remote_ip_prefix: 0.0.0.0/0
protocol: icmp
outputs:
server1_private_ip:
description: IP address of server1 in private network
value: { get_attr: [ server1, first_address ] }
server1_public_ip:
description: Floating IP address of server1 in public network
value: { get_attr: [ server1_floating_ip, floating_ip_address ] }

View File

@ -32,7 +32,7 @@ export PACEMAKER=0
# in under the gate timeout so we can collect logs.
OVERCLOUD_DEPLOY_TIMEOUT=$((DEVSTACK_GATE_TIMEOUT-90))
export OVERCLOUD_DEPLOY_ARGS="--libvirt-type=qemu -t $OVERCLOUD_DEPLOY_TIMEOUT"
export OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS -e /tmp/swap-partition.yaml"
export OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS -e /tmp/tripleo-ci/test-environments/swap-partition.yaml"
export TRIPLEO_SH_ARGS=
export NETISO_V4=0
@ -52,7 +52,7 @@ for JOB_TYPE_PART in $(sed 's/-/ /g' <<< "${TOCI_JOBTYPE:-}") ; do
;;
ceph)
NODECOUNT=4
OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS --ceph-storage-scale 2 -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-ceph-devel.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/net-multiple-nics.yaml -e /tmp/net-iso.yaml"
OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS --ceph-storage-scale 2 -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-ceph-devel.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/net-multiple-nics.yaml -e /tmp/tripleo-ci/test-environments/net-iso.yaml"
export NETISO_V4=1
;;
ha)
@ -60,7 +60,7 @@ for JOB_TYPE_PART in $(sed 's/-/ /g' <<< "${TOCI_JOBTYPE:-}") ; do
# In ci our overcloud nodes don't have access to an external netwrok
# --ntp-server is here to make the deploy command happy, the ci env
# is on virt so the clocks should be in sync without it.
OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS --control-scale 3 --ntp-server 0.centos.pool.ntp.org -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/net-multiple-nics.yaml -e /tmp/net-iso.yaml"
OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS --control-scale 3 --ntp-server 0.centos.pool.ntp.org -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/net-multiple-nics.yaml -e /tmp/tripleo-ci/test-environments/net-iso.yaml"
export NETISO_V4=1
PACEMAKER=1
;;

View File

@ -9,7 +9,7 @@ fi
export TRIPLEO_ROOT=/opt/stack/new
export PATH=/sbin:/usr/sbin:$PATH
source $TRIPLEO_ROOT/tripleo-common/scripts/common_functions.sh
source $TRIPLEO_ROOT/tripleo-ci/scripts/common_functions.sh
mkdir -p $WORKSPACE/logs
@ -30,7 +30,7 @@ if [[ $OVERRIDE_ZUUL_BRANCH =~ ^stable/ ]]; then
fi
# Setup delorean
$TRIPLEO_ROOT/tripleo-common/scripts/tripleo.sh --delorean-setup
$TRIPLEO_ROOT/tripleo-ci/scripts/tripleo.sh --delorean-setup
# If we have no ZUUL_CHANGES then this is a periodic job, we wont be
# building a ci repo, create a dummy one.
@ -53,7 +53,7 @@ function postci(){
fi
if [ "${SEED_IP:-}" != "" ] ; then
# Generate extra state information from the running undercloud
ssh root@${SEED_IP} /tmp/get_host_info.sh
ssh root@${SEED_IP} /tmp/tripleo-ci/scripts/get_host_info.sh
# Get logs from the undercloud
ssh root@${SEED_IP} $TARCMD > $WORKSPACE/logs/undercloud.tar.xz
@ -62,8 +62,8 @@ function postci(){
for INSTANCE in $(ssh root@${SEED_IP} cat /tmp/nova-list.txt | grep ACTIVE | awk '{printf"%s=%s\n", $4, $12}') ; do
IP=${INSTANCE//*=}
NAME=${INSTANCE//=*}
ssh $SSH_OPTIONS root@${SEED_IP} su stack -c \"scp $SSH_OPTIONS /tmp/get_host_info.sh heat-admin@$IP:/tmp\"
ssh $SSH_OPTIONS root@${SEED_IP} su stack -c \"ssh $SSH_OPTIONS heat-admin@$IP sudo /tmp/get_host_info.sh\"
ssh $SSH_OPTIONS root@${SEED_IP} su stack -c \"scp $SSH_OPTIONS /tmp/tripleo-ci/scripts/get_host_info.sh heat-admin@$IP:/tmp\"
ssh $SSH_OPTIONS root@${SEED_IP} su stack -c \"ssh $SSH_OPTIONS heat-admin@$IP sudo /tmp/tripleo-ci/scripts/get_host_info.sh\"
ssh $SSH_OPTIONS root@${SEED_IP} su stack -c \"ssh $SSH_OPTIONS heat-admin@$IP $TARCMD\" > $WORKSPACE/logs/${NAME}.tar.xz
done
destroy_vms &> $WORKSPACE/logs/destroy_vms.log
@ -90,7 +90,7 @@ done
# Build packages
if [ -n "$DELOREAN_BUILD_REFS" ] ; then
$TRIPLEO_ROOT/tripleo-common/scripts/tripleo.sh --delorean-build $DELOREAN_BUILD_REFS
$TRIPLEO_ROOT/tripleo-ci/scripts/tripleo.sh --delorean-build $DELOREAN_BUILD_REFS
fi
# kill the http server if its already running
@ -100,7 +100,7 @@ sudo iptables -I INPUT -p tcp --dport 8766 -i eth1 -j ACCEPT
python -m SimpleHTTPServer 8766 1>$WORKSPACE/logs/yum_mirror.log 2>$WORKSPACE/logs/yum_mirror_error.log &
# Install all of the repositories we need
$TRIPLEO_ROOT/tripleo-common/scripts/tripleo.sh --repo-setup
$TRIPLEO_ROOT/tripleo-ci/scripts/tripleo.sh --repo-setup
# Layer the ci repository on top of it
sudo wget http://$MY_IP:8766/current/delorean-ci.repo -O /etc/yum.repos.d/delorean-ci.repo
@ -179,8 +179,8 @@ done
# copy in required ci files
cd "$TRIPLEO_ROOT"
scp $SSH_OPTIONS deploy.env tripleo-ci/scripts/deploy.sh tripleo-ci/scripts/get_host_info.sh tripleo-ci/test-environments/* root@$SEED_IP:/tmp/
tar -cf - tripleo-common | ssh $SSH_OPTIONS root@$SEED_IP tar -C /tmp -xf -
scp $SSH_OPTIONS deploy.env root@$SEED_IP:/tmp/
tar -cf - tripleo-ci | ssh $SSH_OPTIONS root@$SEED_IP tar -C /tmp -xf -
# Copy the puppet modules to the undercloud where we are building the images
tar -czf - /opt/stack/new/puppet-*/.git | ssh $SSH_OPTIONS root@$SEED_IP tar -C / -xzf -
@ -209,7 +209,7 @@ mkswap /swapfile
swapon /swapfile
# Run the deployment as the stack user
su -l -c "bash /tmp/deploy.sh" stack
su -l -c "bash /tmp/tripleo-ci/scripts/deploy.sh" stack
EOF
exit 0