summaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
Diffstat (limited to 'ci')
-rwxr-xr-xci/build.sh458
-rwxr-xr-xci/clean.sh12
-rwxr-xr-xci/deploy.sh251
3 files changed, 231 insertions, 490 deletions
diff --git a/ci/build.sh b/ci/build.sh
index 82d5b637..b5bfc8ca 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -1,411 +1,113 @@
-#!/bin/bash
-set -e
+#!/bin/sh
##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-# stefan.k.berg@ericsson.com
-# jonas.bjurel@ericsson.com
-# dradez@redhat.com
+# Copyright (c) 2016 Dan Radez (Red Hat) and others.
+#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-trap 'echo "Exiting ..."; \
-if [ -f ${LOCK_FILE} ]; then \
- if [ $(cat ${LOCK_FILE}) -eq $$ ]; then \
- rm -f ${LOCK_FILE}; \
- fi; \
-fi;' EXIT
+set -e
-############################################################################
-# BEGIN of usage description
-#
-usage ()
+display_usage ()
{
cat << EOF
$0 Builds the Apex OPNFV Deployment Toolchain
-usage: $0 [-s spec-file] [-c cache-URI] [-l log-file] [-f Flags] build-directory
+usage: $0 [ -c cache_dir ] -r release_name [ --iso | --rpms ]
OPTIONS:
- -s spec-file ($BUILD_SPEC), define the build-spec file, default ../build/config.mk
- -c cache base URI ($BUILD_CACHE_URI), specifies the base URI to a build cache to be used/updated - the name is automatically generated from the md5sum of the spec-file, http://, ftp://, file://[absolute path] suported.
-
- -l log-file ($BUILD_LOG), specifies the output log-file (stdout and stderr), if not specified logs are output to console as normal
- -v version tag to be applied to the build result
- -r alternative remote access method script/program. curl is default.
- -t run small build-script unit test.
- -T run large build-script unit test.
- -f build flags ($BUILD_FLAGS):
- o s: Do nothing, succeed
- o f: Do nothing, fail
- o t: run build unit tests
- o M: Use master branch code
- o i: run interactive (-t flag to docker run)
- o P: Populate a new local cache and push it to the (-c cache-URI) cache artifactory if -c option is present, currently file://, http:// and ftp:// are supported
- o d: Detatch - NOT YET SUPPORTED
-
- build-directory ($BUILD_DIR), specifies the directory for the output artifacts (.iso file).
-
+ -c cache destination - directory of cached files, defaults to ./cache
+ -r release name/version of the build result
+ --iso build the iso (implies RPMs too)
+ --rpms build the rpms
+ --debug enable debug
-h help, prints this help text
-Description:
-build.sh builds opnfv .iso artifact.
-To reduce build time it uses build cache on a local or remote location. The cache is rebuilt and uploaded if either of the below conditions are met:
-1) The P(opulate) flag is set and the -c cache-base-URI is provided, if -c is not provided the cache will stay local.
-2) If the cache is invalidated by one of the following conditions:
- - The config spec md5sum does not compare to the md5sum for the spec which the cache was built.
- - The git Commit-Id on the remote repos/HEAD defined in the spec file does not correspont with the Commit-Id for what the cache was built with.
-3) A valid cache does not exist on the specified -c cache-base-URI.
-
-The cache URI object name is apex_cache-"md5sum(spec file)"
-
-Logging by default to console, but can be directed elsewhere with the -l option in which case both stdout and stderr is redirected to that destination.
-
-Built in unit testing of components is enabled by adding the t(est) flag.
-
-Return codes:
- - 0 Success!
- - 1-99 Unspecified build error
- - 100-199 Build system internal error (not build it self)
- o 101 Build system instance busy
- - 200 Build failure
-
-Examples:
-build -c http://opnfv.org/artifactory/apex/cache -d ~/jenkins/genesis/apex/ci/output -f ti
-NOTE: At current the build scope is set to the git root of the repository, -d destination locations outside that scope will not work
+Example:
+build -c file:///tmp/cache -r dev123
EOF
}
-#
-# END of usage description
-############################################################################
-############################################################################
-# BEGIN of variables to customize
-#
BUILD_BASE=$(readlink -e ../build/)
-RESULT_DIR="${BUILD_BASE}/release"
-BUILD_SPEC="${BUILD_BASE}/config.mk"
+CACHE_DEST=""
CACHE_DIR="cache"
-LOCAL_CACHE_ARCH_NAME="apex-cache"
-REMOTE_CACHE_ARCH_NAME="apex_cache-$(md5sum ${BUILD_SPEC}| cut -f1 -d " ")"
-REMOTE_ACCESS_METHD=curl
-INCLUDE_DIR=../include
-#
-# END of variables to customize
-############################################################################
-
-############################################################################
-# BEGIN of script assigned variables
-#
-SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-LOCK_FILE="${SCRIPT_DIR}/.build.lck"
-CACHE_TMP="${SCRIPT_DIR}/tmp"
-TEST_SUCCEED=0
-TEST_FAIL=0
-UNIT_TEST=0
-USE_MASTER=0
-UPDATE_CACHE=0
-POPULATE_CACHE=0
-RECURSIV=0
-DETACH=0
-DEBUG=0
-INTEGRATION_TEST=0
-FULL_INTEGRATION_TEST=0
-INTERACTIVE=0
-BUILD_CACHE_URI=
-BUILD_SPEC=
-BUILD_DIR=
-BUILD_LOG=
-BUILD_VERSION=
-MAKE_ARGS=
-#
-# END of script assigned variables
-############################################################################
-
-############################################################################
-# BEGIN of include pragmas
-#
-source ${INCLUDE_DIR}/build.sh.debug
-#
-# END of include
-############################################################################
-
-############################################################################
-# BEGIN of main
-#
-while getopts "s:c:d:v:f:l:r:RtTh" OPTION
-do
- case $OPTION in
- h)
- usage
- rc=0
- exit $rc
- ;;
-
- s)
- BUILD_SPEC=${OPTARG}
- ;;
-
- c)
- BUILD_CACHE_URI=${OPTARG}
- ;;
-
- d)
- BUILD_DIR=${OPTARG}
- ;;
-
- l)
- BUILD_LOG=${OPTARG}
- ;;
-
- v)
- BUILD_VERSION=${OPTARG}
- ;;
-
- f)
- BUILD_FLAGS=${OPTARG}
- ;;
-
- r) REMOTE_ACCESS_METHD=${OPTARG}
- ;;
-
- R)
- RECURSIVE=1
- ;;
-
- t)
- INTEGRATION_TEST=1
- ;;
-
- T)
- INTEGRATION_TEST=1
- FULL_INTEGRATION_TEST=1
- ;;
-
- *)
- echo "${OPTION} is not a valid argument"
- rc=100
- exit $rc
- ;;
+CACHE_NAME="apex-cache"
+MAKE_TARGET="images"
+
+parse_cmdline() {
+ while [ "${1:0:1}" = "-" ]
+ do
+ case "$1" in
+ -h|--help)
+ display_usage
+ exit 0
+ ;;
+ -c|--cache-dir)
+ CACHE_DEST=${2}
+ shift 2
+ ;;
+ -r|--release)
+ RELEASE=${2}
+ shift 2
+ ;;
+ --iso )
+ MAKE_TARGET="iso"
+ echo "Building opnfv-apex RPMs and ISO"
+ shift 1
+ ;;
+ --rpms )
+ MAKE_TARGET="rpms"
+ echo "Buiding opnfv-apex RPMs"
+ shift 1
+ ;;
+ --debug )
+ debug="TRUE"
+ echo "Enable debug output"
+ shift 1
+ ;;
+ *)
+ display_usage
+ exit 1
+ ;;
esac
-done
-
-if [ -z $BUILD_DIR ]; then
- BUILD_DIR=$(echo $@ | cut -d ' ' -f ${OPTIND})
-fi
-
-for ((i=0; i<${#BUILD_FLAGS};i++)); do
- case ${BUILD_FLAGS:$i:1} in
- s)
- rc=0
- exit $rc
- ;;
-
- f)
- rc=1
- exit $rc
- ;;
-
- t)
- UNIT_TEST=1
- ;;
-
- M)
- USE_MASTER=1
- ;;
+ done
- i)
- INTERACTIVE=1
- ;;
-
- P)
- POPULATE_CACHE=1
- ;;
-
- d)
- DETACH=1
- echo "Detach is not yet supported - exiting ...."
- rc=100
- exit $rc
- ;;
-
- D)
- DEBUG=1
- ;;
-
- *)
- echo "${BUILD_FLAGS:$i:1} is not a valid build flag - exiting ...."
- rc=100
- exit $rc
- ;;
- esac
-done
-
-shift $((OPTIND-1))
-
-if [ ${INTEGRATION_TEST} -eq 1 ]; then
- integration-test
- rc=0
- exit $rc
-fi
-
-if [ ! -f ${BUILD_SPEC} ]; then
- echo "spec file does not exist: $BUILD_SPEC - exiting ...."
- rc=100
- exit $rc
-fi
-
-if [ -z ${BUILD_DIR} ]; then
- echo "Missing build directory - exiting ...."
- rc=100
- exit $rc
-fi
-
-if [ ! -z ${BUILD_LOG} ]; then
- if [[ ${RECURSIVE} -ne 1 ]]; then
- set +e
- eval $0 -R $@ > ${BUILD_LOG} 2>&1
- rc=$?
- set -e
- if [ $rc -ne 0]; then
- exit $rc
- fi
- fi
-fi
-
-if [ ${TEST_SUCCEED} -eq 1 ]; then
- sleep 1
- rc=0
- exit $rc
-fi
-
-if [ ${TEST_FAIL} -eq 1 ]; then
- sleep 1
- rc=1
- exit $rc
-fi
-
-if [ -e ${LOCK_FILE} ]; then
- echo "A build job is already running, exiting....."
- rc=101
- exit $rc
-fi
-
-echo $$ > ${LOCK_FILE}
+}
-if [ ! -z ${BUILD_CACHE_URI} ]; then
- if [ ${POPULATE_CACHE} -ne 1 ]; then
- rm -rf ${CACHE_TMP}/cache
- mkdir -p ${CACHE_TMP}/cache
- echo "Downloading cach file ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME} ..."
- set +e
- ${REMOTE_ACCESS_METHD} -o ${CACHE_TMP}/cache/${LOCAL_CACHE_ARCH_NAME}.tgz ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME}.tgz
- rc=$?
- set -e
- if [ $rc -ne 0 ]; then
- echo "Remote cache does not exist, or is not accessible - a new cache will be built ..."
- POPULATE_CACHE=1
- else
- echo "Unpacking cache file ..."
- tar --atime-preserve -C ${CACHE_TMP}/cache -xvf ${CACHE_TMP}/cache/${LOCAL_CACHE_ARCH_NAME}.tgz
- cp ${CACHE_TMP}/cache/cache/.versions ${BUILD_BASE}/.
- set +e
- make -C ${BUILD_BASE} validate-cache;
- rc=$?
- set -e
+parse_cmdline "$@"
- if [ $rc -ne 0 ]; then
- echo "Cache invalid - a new cache will be built "
- POPULATE_CACHE=1
- else
- cp -rf ${CACHE_TMP}/cache/cache/. ${BUILD_BASE}
- fi
- rm -rf ${CACHE_TMP}/cache
- fi
- fi
-fi
+if [ -n "$RELEASE" ]; then MAKE_ARGS+="RELEASE=$RELEASE "; fi
-if [ ${POPULATE_CACHE} -eq 1 ]; then
- if [ ${DEBUG} -eq 0 ]; then
- set +e
- cd ${BUILD_BASE} && make clean
- rc=$?
- set -e
- if [ $rc -ne 0 ]; then
- echo "Build - make clean failed, exiting ..."
- rc=100
- exit $rc
- fi
+# Get the Old Cache
+if [ -n "$CACHE_DEST" ]; then
+ echo "Retrieving Cache"
+ if [ -f $CACHE_DEST/${CACHE_NAME}.tgz ]; then
+ rm -rf $BUILD_BASE/$CACHE_DIR
+ cp -f $CACHE_DEST/${CACHE_NAME}.tgz $BUILD_BASE/${CACHE_NAME}.tgz
+ tar xzf $BUILD_BASE/${CACHE_NAME}.tgz
+ elif [ ! -d $BUILD_BASE/$CACHE_DIR ]; then
+ mkdir $BUILD_BASE/$CACHE_DIR
fi
fi
-if [ ! -z ${BUILD_VERSION} ]; then
- MAKE_ARGS+="REVSTATE=${BUILD_VERSION} "
+#create build_output for legecy functionality compatibiltiy in jenkins
+if [[ ! -d ../build_output ]]; then
+ rm -f ../build_output
+ ln -s build/noarch/ ../build_output
fi
-if [ ${UNIT_TEST} -eq 1 ]; then
- MAKE_ARGS+="UNIT_TEST=TRUE "
-else
- MAKE_ARGS+="UNIT_TEST=FALSE "
-fi
-
-if [ ${USE_MASTER} -eq 1 ]; then
- MAKE_ARGS+="USE_MASTER=-master "
-fi
+# Execute Make
+make $MAKE_ARGS -C ${BUILD_BASE} $MAKE_TARGET
+echo "Build Complete"
-if [ ${INTERACTIVE} -eq 1 ]; then
- MAKE_ARGS+="INTERACTIVE=TRUE "
-else
- MAKE_ARGS+="INTERACTIVE=FALSE "
+# Build new Cache
+if [ -n "$CACHE_DEST" ]; then
+ echo "Building Cache"
+ tar --atime-preserve --dereference -C $BUILD_BASE -caf $BUILD_BASE/${CACHE_NAME}.tgz $CACHE_DIR
+ echo "Copying Cache"
+ if [ ! -d $CACHE_DEST ]; then mkdir -p $CACHE_DEST; fi
+ cp $BUILD_BASE/${CACHE_NAME}.tgz $CACHE_DEST/${CACHE_NAME}.tgz
fi
-
-MAKE_ARGS+=all
-
-if [ ${DEBUG} -eq 0 ]; then
- set +e
- cd ${BUILD_BASE} && make ${MAKE_ARGS}
- rc=$?
- set -e
- if [ $rc -gt 0 ]; then
- echo "Build: make all failed, exiting ..."
- rc=200
- exit $rc
- fi
-else
-debug_make
-fi
-set +e
-make -C ${BUILD_BASE} prepare-cache
-rc=$?
-set -e
-
-if [ $rc -gt 0 ]; then
- echo "Build: make prepare-cache failed - exiting ..."
- rc=100
- exit $rc
-fi
-echo "Linking built OPNFV .iso file to target directory ${BUILD_DIR} ..."
-rm -rf ${BUILD_DIR}
-mkdir -p ${BUILD_DIR}
-ln -s ${BUILD_BASE}/.versions ${BUILD_DIR}
-ln -s ${RESULT_DIR}/*.iso* ${BUILD_DIR}
-echo "Linking built OPNFV .rpm files to target directory ${BUILD_DIR} ..."
-ln -s ${BUILD_BASE}/*.rpm ${BUILD_DIR}
-ln -s ${BUILD_BASE}/noarch/*.rpm ${BUILD_DIR}
-
-if [ $POPULATE_CACHE -eq 1 ]; then
- if [ ! -z ${BUILD_CACHE_URI} ]; then
- echo "Building cache ..."
- tar --atime-preserve --dereference -C ${BUILD_BASE} -caf ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz ${CACHE_DIR}
- echo "Uploading cache ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME}"
- ${REMOTE_ACCESS_METHD} -T ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME}.tgz
- rm ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz
- fi
-fi
-echo "Success!!!"
-exit 0
-#
-# END of main
-############################################################################
+echo "Complete"
diff --git a/ci/clean.sh b/ci/clean.sh
index f05b9136..58239cc6 100755
--- a/ci/clean.sh
+++ b/ci/clean.sh
@@ -17,7 +17,7 @@ CONFIG=/var/opt/opnfv
source $CONFIG/lib/common-functions.sh
vm_index=4
-ovs_bridges="brbm brbm1 brbm2 brbm3"
+ovs_bridges="br-admin br-private br-public br-storage"
# Clean off instack VM
virsh destroy instack 2> /dev/null || echo -n ''
virsh undefine instack --remove-all-storage 2> /dev/null || echo -n ''
@@ -32,11 +32,11 @@ rm -f /var/lib/libvirt/images/instack.qcow2 2> /dev/null
# Clean off baremetal VMs in case they exist
for i in $(seq 0 $vm_index); do
- virsh destroy baremetalbrbm_brbm1_brbm2_brbm3_$i 2> /dev/null || echo -n ''
- virsh undefine baremetalbrbm_brbm1_brbm2_brbm3_$i --remove-all-storage 2> /dev/null || echo -n ''
- /usr/bin/touch /var/lib/libvirt/images/baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2
- virsh vol-delete baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 --pool default 2> /dev/null
- rm -f /var/lib/libvirt/images/baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 2> /dev/null
+ virsh destroy baremetal$i 2> /dev/null || echo -n ''
+ virsh undefine baremetal$i --remove-all-storage 2> /dev/null || echo -n ''
+ /usr/bin/touch /var/lib/libvirt/images/baremetal${i}.qcow2
+ virsh vol-delete baremetal${i}.qcow2 --pool default 2> /dev/null
+ rm -f /var/lib/libvirt/images/baremetal${i}.qcow2 2> /dev/null
done
# Clean off created bridges
diff --git a/ci/deploy.sh b/ci/deploy.sh
index 8589226b..504fd507 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -17,17 +17,10 @@
set -e
##VARIABLES
-if [ "$TERM" != "unknown" ]; then
- reset=$(tput sgr0)
- blue=$(tput setaf 4)
- red=$(tput setaf 1)
- green=$(tput setaf 2)
-else
- reset=""
- blue=""
- red=""
- green=""
-fi
+reset=$(tput sgr0 || echo "")
+blue=$(tput setaf 4 || echo "")
+red=$(tput setaf 1 || echo "")
+green=$(tput setaf 2 || echo "")
vm_index=4
interactive="FALSE"
@@ -44,14 +37,14 @@ declare -A NET_MAP
SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o LogLevel=error)
DEPLOY_OPTIONS=""
-RESOURCES=/var/opt/opnfv/stack
+RESOURCES=/var/opt/opnfv/images
CONFIG=/var/opt/opnfv
OPNFV_NETWORK_TYPES="admin_network private_network public_network storage_network"
# Netmap used to map networks to OVS bridge names
-NET_MAP['admin_network']="brbm"
-NET_MAP['private_network']="brbm1"
-NET_MAP['public_network']="brbm2"
-NET_MAP['storage_network']="brbm3"
+NET_MAP['admin_network']="br-admin"
+NET_MAP['private_network']="br-private"
+NET_MAP['public_network']="br-public"
+NET_MAP['storage_network']="br-storage"
##FUNCTIONS
##translates yaml into variables
@@ -402,15 +395,30 @@ function configure_deps {
virsh_enabled_networks=$enabled_network_list
fi
- virsh net-list | grep default || virsh net-define /usr/share/libvirt/networks/default.xml
- virsh net-list | grep -E "default\s+active" > /dev/null || virsh net-start default
- virsh net-list | grep -E "default\s+active\s+yes" > /dev/null || virsh net-autostart --network default
+ # ensure default network is configured correctly
+ libvirt_dir="/usr/share/libvirt/networks"
+ virsh net-list --all | grep default || virsh net-define ${libvirt_dir}/default.xml
+ virsh net-list --all | grep -E "default\s+active" > /dev/null || virsh net-start default
+ virsh net-list --all | grep -E "default\s+active\s+yes" > /dev/null || virsh net-autostart --network default
for network in ${OPNFV_NETWORK_TYPES}; do
+ echo "${blue}INFO: Creating Virsh Network: $network & OVS Bridge: ${NET_MAP[$network]}${reset}"
ovs-vsctl list-br | grep ${NET_MAP[$network]} > /dev/null || ovs-vsctl add-br ${NET_MAP[$network]}
- virsh net-list --all | grep ${NET_MAP[$network]} > /dev/null || virsh net-define $CONFIG/${NET_MAP[$network]}-net.xml
- virsh net-list | grep -E "${NET_MAP[$network]}\s+active" > /dev/null || virsh net-start ${NET_MAP[$network]}
- virsh net-list | grep -E "${NET_MAP[$network]}\s+active\s+yes" > /dev/null || virsh net-autostart --network ${NET_MAP[$network]}
+ virsh net-list --all | grep $network > /dev/null || (cat > ${libvirt_dir}/apex-virsh-net.xml && virsh net-define ${libvirt_dir}/apex-virsh-net.xml) << EOF
+<network>
+ <name>$network</name>
+ <forward mode='bridge'/>
+ <bridge name='${NET_MAP[$network]}'/>
+ <virtualport type='openvswitch'/>
+</network>
+EOF
+ if ! (virsh net-list --all | grep $network > /dev/null); then
+ echo "${red}ERROR: unable to create network: ${network}${reset}"
+ exit 1;
+ fi
+ rm -f ${libvirt_dir}/apex-virsh-net.xml &> /dev/null;
+ virsh net-list | grep -E "$network\s+active" > /dev/null || virsh net-start $network
+ virsh net-list | grep -E "$network\s+active\s+yes" > /dev/null || virsh net-autostart --network $network
done
echo -e "${blue}INFO: Bridges set: ${reset}"
@@ -441,21 +449,8 @@ function configure_deps {
fi
# ensure storage pool exists and is started
- virsh pool-list --all | grep default > /dev/null || virsh pool-create $CONFIG/default-pool.xml
- virsh pool-list | grep -Eo "default\s+active" > /dev/null || virsh pool-start default
-
- if virsh net-list | grep default > /dev/null; then
- num_ints_same_subnet=$(ip addr show | grep "inet 192.168.122" | wc -l)
- if [ "$num_ints_same_subnet" -gt 1 ]; then
- virsh net-destroy default
- ##go edit /etc/libvirt/qemu/networks/default.xml
- sed -i 's/192.168.122/192.168.123/g' /etc/libvirt/qemu/networks/default.xml
- sed -i 's/192.168.122/192.168.123/g' instackenv-virt.json
- sleep 5
- virsh net-start default
- virsh net-autostart default
- fi
- fi
+ virsh pool-list --all | grep default > /dev/null || virsh pool-define-as --name default dir --target /var/lib/libvirt/images
+ virsh pool-list | grep -Eo "default\s+active" > /dev/null || (virsh pool-autostart default; virsh pool-start default)
if ! egrep '^flags.*(vmx|svm)' /proc/cpuinfo > /dev/null; then
echo "${red}virtualization extensions not found, kvm kernel module insertion may fail.\n \
@@ -482,31 +477,30 @@ Are you sure you have enabled vmx in your bios or hypervisor?${reset}"
##params: none
function setup_instack_vm {
if ! virsh list --all | grep instack > /dev/null; then
- #virsh vol-create default instack.qcow2.xml
- virsh define $CONFIG/instack.xml
-
- #Upload instack image
- #virsh vol-create default --file instack.qcow2.xml
- virsh vol-create-as default instack.qcow2 30G --format qcow2
+ undercloud_nets="default admin_network"
+ if [[ $enabled_network_list =~ "public_network" ]]; then
+ undercloud_nets+=" public_network"
+ fi
+ define_vm instack hd 30 "$undercloud_nets"
### this doesn't work for some reason I was getting hangup events so using cp instead
- #virsh vol-upload --pool default --vol instack.qcow2 --file $CONFIG/stack/instack.qcow2
+ #virsh vol-upload --pool default --vol undercloud.qcow2 --file $CONFIG/stack/undercloud.qcow2
#2015-12-05 12:57:20.569+0000: 8755: info : libvirt version: 1.2.8, package: 16.el7_1.5 (CentOS BuildSystem <http://bugs.centos.org>, 2015-11-03-13:56:46, worker1.bsys.centos.org)
#2015-12-05 12:57:20.569+0000: 8755: warning : virKeepAliveTimerInternal:143 : No response from client 0x7ff1e231e630 after 6 keepalive messages in 35 seconds
#2015-12-05 12:57:20.569+0000: 8756: warning : virKeepAliveTimerInternal:143 : No response from client 0x7ff1e231e630 after 6 keepalive messages in 35 seconds
- #error: cannot close volume instack.qcow2
+ #error: cannot close volume undercloud.qcow2
#error: internal error: received hangup / error event on socket
#error: Reconnected to the hypervisor
local instack_dst=/var/lib/libvirt/images/instack.qcow2
- cp -f $RESOURCES/instack.qcow2 $instack_dst
+ cp -f $RESOURCES/undercloud.qcow2 $instack_dst
# resize instack machine
echo "Checking if instack needs to be resized..."
instack_size=$(LIBGUESTFS_BACKEND=direct virt-filesystems --long -h --all -a $instack_dst |grep device | grep -Eo "[0-9\.]+G" | sed -n 's/\([0-9][0-9]*\).*/\1/p')
if [ "$instack_size" -lt 30 ]; then
qemu-img resize /var/lib/libvirt/images/instack.qcow2 +25G
- LIBGUESTFS_BACKEND=direct virt-resize --expand /dev/sda1 $RESOURCES/instack.qcow2 $instack_dst
+ LIBGUESTFS_BACKEND=direct virt-resize --expand /dev/sda1 $RESOURCES/undercloud.qcow2 $instack_dst
LIBGUESTFS_BACKEND=direct virt-customize -a $instack_dst --run-command 'xfs_growfs -d /dev/sda1 || true'
new_size=$(LIBGUESTFS_BACKEND=direct virt-filesystems --long -h --all -a $instack_dst |grep filesystem | grep -Eo "[0-9\.]+G" | sed -n 's/\([0-9][0-9]*\).*/\1/p')
if [ "$new_size" -lt 30 ]; then
@@ -534,30 +528,22 @@ function setup_instack_vm {
virsh start instack
fi
- sleep 3 # let DHCP happen
+ sleep 10 # let instack get started up
+ # get the instack VM IP
CNT=10
echo -n "${blue}Waiting for instack's dhcp address${reset}"
- while ! grep instack /var/lib/libvirt/dnsmasq/default.leases > /dev/null && [ $CNT -gt 0 ]; do
+ instack_mac=$(virsh domiflist instack | grep default | awk '{ print $5 }')
+ while ! $(arp -e | grep ${instack_mac} > /dev/null) && [ $CNT -gt 0 ]; do
echo -n "."
- sleep 3
- CNT=CNT-1
+ sleep 10
+ CNT=$((CNT-1))
done
+ UNDERCLOUD=$(arp -e | grep ${instack_mac} | awk {'print $1'})
- # get the instack VM IP
- UNDERCLOUD=$(grep instack /var/lib/libvirt/dnsmasq/default.leases | awk '{print $3}' | head -n 1)
if [ -z "$UNDERCLOUD" ]; then
- #if not found then dnsmasq may be using leasefile-ro
- instack_mac=$(virsh domiflist instack | grep default | \
- grep -Eo "[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+")
- UNDERCLOUD=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
-
- if [ -z "$UNDERCLOUD" ]; then
- echo "\n\nNever got IP for Instack. Can Not Continue."
- exit 1
- else
- echo -e "${blue}\rInstack VM has IP $UNDERCLOUD${reset}"
- fi
+ echo "\n\nCan't get IP for Instack. Can Not Continue."
+ exit 1
else
echo -e "${blue}\rInstack VM has IP $UNDERCLOUD${reset}"
fi
@@ -567,7 +553,7 @@ function setup_instack_vm {
while ! ping -c 1 $UNDERCLOUD > /dev/null && [ $CNT -gt 0 ]; do
echo -n "."
sleep 3
- CNT=$CNT-1
+ CNT=$((CNT-1))
done
if [ "$CNT" -eq 0 ]; then
echo "Failed to contact Instack. Can Not Continue"
@@ -577,7 +563,7 @@ function setup_instack_vm {
while ! ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "echo ''" 2>&1> /dev/null && [ $CNT -gt 0 ]; do
echo -n "."
sleep 3
- CNT=$CNT-1
+ CNT=$((CNT-1))
done
if [ "$CNT" -eq 0 ]; then
echo "Failed to connect to Instack. Can Not Continue"
@@ -586,13 +572,9 @@ function setup_instack_vm {
# extra space to overwrite the previous connectivity output
echo -e "${blue}\r ${reset}"
+ sleep 1
+ ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "if ! ip a s eth2 | grep ${public_network_provisioner_ip} > /dev/null; then ip a a ${public_network_provisioner_ip}/${public_network_cidr##*/} dev eth2; ip link set up dev eth2; fi"
- #add the instack public interface if net isolation is enabled (more than just admin network)
- if [[ "$net_isolation_enabled" == "TRUE" ]]; then
- virsh attach-interface --domain instack --type network --source ${NET_MAP['public_network']} --model rtl8139 --config --live
- sleep 1
- ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "if ! ip a s eth2 | grep ${public_network_provisioner_ip} > /dev/null; then ip a a ${public_network_provisioner_ip}/${public_network_cidr##*/} dev eth2; ip link set up dev eth2; fi"
- fi
# ssh key fix for stack user
ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "restorecon -r /home/stack"
}
@@ -600,24 +582,93 @@ function setup_instack_vm {
##Create virtual nodes in virsh
##params: none
function setup_virtual_baremetal {
+ #start by generating the opening json for instackenv.json
+ cat > $CONFIG/instackenv-virt.json << EOF
+{
+ "nodes": [
+EOF
+
+ # next create the virtual machines and add their definitions to the file
for i in $(seq 0 $vm_index); do
- if ! virsh list --all | grep baremetalbrbm_brbm1_brbm2_brbm3_${i} > /dev/null; then
- if [ ! -e $CONFIG/baremetalbrbm_brbm1_brbm2_brbm3_${i}.xml ]; then
- define_virtual_node baremetalbrbm_brbm1_brbm2_brbm3_${i}
- fi
- # Fix for ramdisk using wrong pxeboot interface
- # TODO: revisit this and see if there's a more proper fix
- sed -i "/^\s*<source network='brbm2'\/>/{
- N
- s/^\(.*\)virtio\(.*\)$/\1rtl8139\2/
- }" $CONFIG/baremetalbrbm_brbm1_brbm2_brbm3_${i}.xml
- virsh define $CONFIG/baremetalbrbm_brbm1_brbm2_brbm3_${i}.xml
+ if ! virsh list --all | grep baremetal${i} > /dev/null; then
+ define_vm baremetal${i} network 41 'admin_network'
+ for n in private_network public_network storage_network; do
+ if [[ $enabled_network_list =~ $n ]]; then
+ echo -n "$n "
+ virsh attach-interface --domain baremetal${i} --type network --source $n --model rtl8139 --config
+ fi
+ done
else
echo "Found Baremetal ${i} VM, using existing VM"
fi
- virsh vol-list default | grep baremetalbrbm_brbm1_brbm2_brbm3_${i} 2>&1> /dev/null || virsh vol-create-as default baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 40G --format qcow2
+ #virsh vol-list default | grep baremetal${i} 2>&1> /dev/null || virsh vol-create-as default baremetal${i}.qcow2 41G --format qcow2
+ mac=$(virsh domiflist baremetal${i} | grep admin_network | awk '{ print $5 }')
+
+ cat >> $CONFIG/instackenv-virt.json << EOF
+ {
+ "pm_addr": "192.168.122.1",
+ "pm_user": "root",
+ "pm_password": "INSERT_STACK_USER_PRIV_KEY",
+ "pm_type": "pxe_ssh",
+ "mac": [
+ "$mac"
+ ],
+ "cpu": "2",
+ "memory": "8192",
+ "disk": "41",
+ "arch": "x86_64"
+ },
+EOF
done
+ #truncate the last line to remove the comma behind the bracket
+ tail -n 1 $CONFIG/instackenv-virt.json | wc -c | xargs -I {} truncate $CONFIG/instackenv-virt.json -s -{}
+
+ #finally reclose the bracket and close the instackenv.json file
+ cat >> $CONFIG/instackenv-virt.json << EOF
+ }
+ ],
+ "arch": "x86_64",
+ "host-ip": "192.168.122.1",
+ "power_manager": "nova.virt.baremetal.virtual_power_driver.VirtualPowerManager",
+ "seed-ip": "",
+ "ssh-key": "INSERT_STACK_USER_PRIV_KEY",
+ "ssh-user": "root"
+}
+EOF
+}
+
+##Create virtual nodes in virsh
+##params: name - String: libvirt name for VM
+## bootdev - String: boot device for the VM
+## disksize - Number: size of the disk in Gig
+## ovs_bridges: - List: list of ovs bridges
+function define_vm () {
+ # Create the libvirt storage volume
+ if virsh vol-list default | grep ${1}.qcow2 2>&1> /dev/null; then
+ volume_path=$(virsh vol-path --pool default ${1}.qcow2 || echo "/var/lib/libvirt/images/${1}.qcow2")
+ echo "Volume ${1} exists. Deleting Existing Volume $volume_path"
+ virsh vol-dumpxml ${1}.qcow2 --pool default
+ touch $volume_path
+ virsh vol-delete ${1}.qcow2 --pool default
+ fi
+ virsh vol-create-as default ${1}.qcow2 ${3}G --format qcow2
+ volume_path=$(virsh vol-path --pool default ${1}.qcow2)
+ if [ ! -f $volume_path ]; then
+ echo "$volume_path Not created successfully... Aborting"
+ exit 1
+ fi
+
+ # create the VM
+ /usr/libexec/openstack-tripleo/configure-vm --name $1 \
+ --bootdev $2 \
+ --image "$volume_path" \
+ --diskbus sata \
+ --arch x86_64 \
+ --cpus 2 \
+ --memory 8388608 \
+ --libvirt-nic-driver virtio \
+ --baremetal-interface $4
}
##Set network-environment settings
@@ -666,11 +717,7 @@ function configure_network_environment {
# check for ODL L3
if [ "${deploy_options_array['sdn_l3']}" == 'true' ]; then
- nic_ext+=_br-ex
- fi
-
- if [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then
- nic_ext+=_no-public-ip
+ nic_ext+=_br-ex_no-public-ip
fi
# set nics appropriately
@@ -701,21 +748,6 @@ function configure_undercloud {
# vm power on the hypervisor
ssh ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "cat /home/stack/.ssh/id_rsa.pub" >> /root/.ssh/authorized_keys
- # fix MACs to match new setup
- for i in $(seq 0 $vm_index); do
- pyscript="import json
-data = json.load(open('$CONFIG/instackenv-virt.json'))
-print data['nodes'][$i]['mac'][0]"
-
- old_mac=$(python -c "$pyscript")
- new_mac=$(virsh dumpxml baremetalbrbm_brbm1_brbm2_brbm3_$i | grep "mac address" | cut -d = -f2 | grep -Eo "[0-9a-f:]+")
- # this doesn't work with multiple vnics on the vms
- #if [ "$old_mac" != "$new_mac" ]; then
- # echo "${blue}Modifying MAC for node from $old_mac to ${new_mac}${reset}"
- # sed -i 's/'"$old_mac"'/'"$new_mac"'/' $CONFIG/instackenv-virt.json
- #fi
- done
-
DEPLOY_OPTIONS+=" --libvirt-type qemu"
INSTACKENV=$CONFIG/instackenv-virt.json
@@ -777,7 +809,13 @@ cat << 'EOF' | sudo tee /usr/share/diskimage-builder/elements/yum/bin/install-pa
exit 0
EOF
-openstack undercloud install &> apex-undercloud-install.log
+openstack undercloud install &> apex-undercloud-install.log || {
+ # cat the undercloud install log incase it fails
+ echo "ERROR: openstack undercloud install has failed. Dumping Log:"
+ cat apex-undercloud-install.log
+ exit 1
+}
+
sleep 30
sudo systemctl restart openstack-glance-api
sudo systemctl restart openstack-nova-conductor
@@ -818,7 +856,7 @@ function undercloud_prep_overcloud_deploy {
SDN_IMAGE=opendaylight
elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then
DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos.yaml"
- SDN_IMAGE=opendaylight
+ SDN_IMAGE=onos
elif [ "${deploy_options_array['sdn_controller']}" == 'opencontrail' ]; then
echo -e "${red}ERROR: OpenContrail is currently unsupported...exiting${reset}"
exit 1
@@ -1110,6 +1148,7 @@ parse_cmdline() {
;;
--no-ha )
ha_enabled="FALSE"
+ vm_index=1
echo "HA Deployment Disabled"
shift 1
;;