summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2016-05-26 13:50:38 -0400
committerTim Rozet <trozet@redhat.com>2016-05-26 15:38:43 -0400
commit56e0013634afa6424eac9e2819faae0ad6eead39 (patch)
tree11b0978574d7389d68950bd802f4ff9c762c5fe7
parent1a5bfeacf2743cde6336e0e3f4e5f8be18a6237f (diff)
Apex: Converges separate virtual and baremetal deploy scripts
Changes Include: - Combined apex-deploy-baremetal and apex-deploy-virtual into the apex-deploy.sh into functions - JJB modified to only use single builder for deploy Change-Id: Ia129d8d6004b36c09bdb01685f2a0fced13bccea Signed-off-by: Tim Rozet <trozet@redhat.com>
-rwxr-xr-xjjb/apex/apex-deploy-baremetal.sh84
-rwxr-xr-xjjb/apex/apex-deploy-virtual.sh151
-rwxr-xr-xjjb/apex/apex-deploy.sh164
-rw-r--r--jjb/apex/apex.yml13
4 files changed, 168 insertions, 244 deletions
diff --git a/jjb/apex/apex-deploy-baremetal.sh b/jjb/apex/apex-deploy-baremetal.sh
deleted file mode 100755
index efb6561d7..000000000
--- a/jjb/apex/apex-deploy-baremetal.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/bash
-set -o errexit
-set -o nounset
-set -o pipefail
-
-# log info to console
-echo "Starting the Apex baremetal deployment."
-echo "--------------------------------------------------------"
-echo
-
-if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
- # if artifact name is passed the pull a
- # specific artifact from artifacts.opnfv.org
- RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
-else
- if [[ $BUILD_DIRECTORY == *apex-build* ]]; then
- BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
- echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
- fi
- if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
- # if opnfv.properties exists then use the
- # local build. Source the file so we get local OPNFV vars
- source ${BUILD_DIRECTORY}/../opnfv.properties
- RPM_INSTALL_PATH=${BUILD_DIRECTORY}/$(basename $OPNFV_RPM_URL)
- else
- # no opnfv.properties means use the latest from artifacts.opnfv.org
- # get the latest.properties to get the link to the latest artifact
- curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
- [[ -f opnfv.properties ]] || exit 1
- # source the file so we get OPNFV vars
- source opnfv.properties
- RPM_INSTALL_PATH=$OPNFV_RPM_URL
- fi
-fi
-
-if [ ! -e "$RPM_INSTALL_PATH" ]; then
- RPM_INSTALL_PATH=http://${OPNFV_RPM_URL}
-fi
-
-RPM_LIST=$RPM_INSTALL_PATH
-for pkg in common undercloud; do
- RPM_LIST+=" ${RPM_INSTALL_PATH/opnfv-apex/opnfv-apex-${pkg}}"
-done
-
-# update / install the new rpm
-if rpm -q opnfv-apex > /dev/null; then
- if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
- echo "RPM is already installed"
- elif sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
- if ! sudo yum downgrade -y $RPM_LIST; then
- sudo yum remove -y opnfv-undercloud opnfv-common
- sudo yum downgrade -y $RPM_INSTALL_PATH
- fi
- fi
-else
- sudo yum install -y $RPM_LIST;
-fi
-
-# cleanup environment before we start
-sudo opnfv-clean
-# initiate baremetal deployment
-if [ -e /etc/opnfv-apex/network_settings.yaml ]; then
- if [ -n "$DEPLOY_SCENARIO" ]; then
- echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
- if [ -e /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml ]; then
- sudo opnfv-deploy -i /root/inventory/pod_settings.yaml \
- -d /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml \
- -n /root/network/network_settings.yaml --debug
- else
- echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
- exit 1
- fi
- else
- echo "Deploy scenario not set!"
- exit 1
- fi
-else
- echo "File /etc/opnfv-apex/network_settings.yaml does not exist!"
- exit 1
-fi
-
-echo
-echo "--------------------------------------------------------"
-echo "Done!"
diff --git a/jjb/apex/apex-deploy-virtual.sh b/jjb/apex/apex-deploy-virtual.sh
deleted file mode 100755
index 4d9b03088..000000000
--- a/jjb/apex/apex-deploy-virtual.sh
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/bin/bash
-set -o errexit
-set -o nounset
-set -o pipefail
-
-# log info to console
-echo "Starting the Apex virtual deployment."
-echo "--------------------------------------------------------"
-echo
-
-if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
- cd $WORKSPACE/../${BUILD_DIRECTORY/build_output/}
- WORKSPACE=$(pwd)
- echo "WORKSPACE modified to $WORKSPACE"
- cd $WORKSPACE/ci
-elif [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
- # if artifact name is passed the pull a
- # specific artifact from artifacts.opnfv.org
- RPM_INSTALL_PATH=$GS_URL
- RPM_LIST=$RPM_INSTALL_PATH/$ARTIFACT_NAME
-else
- if [[ $BUILD_DIRECTORY == *verify* ]]; then
- BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
- echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
- elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
- BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
- echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
- fi
-
- if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
- # if opnfv.properties exists then use the
- # local build. Source the file so we get local OPNFV vars
- source ${BUILD_DIRECTORY}/../opnfv.properties
- RPM_INSTALL_PATH=${BUILD_DIRECTORY}/noarch
- RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
- else
- if [[ $BUILD_DIRECTORY == *verify* ]]; then
- echo "BUILD_DIRECTORY is from a verify job, so will not use latest from URL"
- echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
- exit 1
- elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
- echo "BUILD_DIRECTORY is from a daily job, so will not use latest from URL"
- echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
- exit 1
- fi
- # no opnfv.properties means use the latest from artifacts.opnfv.org
- # get the latest.properties to get the link to the latest artifact
- curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
- [[ -f opnfv.properties ]] || exit 1
- # source the file so we get OPNFV vars
- source opnfv.properties
- RPM_INSTALL_PATH=$(echo $OPNFV_RPM_URL | sed 's/'"$(basename $OPNFV_RPM_URL)"'//')
- RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
- fi
-fi
-
-if [ -z "$DEPLOY_SCENARIO" ]; then
- echo "Deploy scenario not set!"
- exit 1
-fi
-
-# use local build for verify
-if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
- if [ ! -e "${WORKSPACE}/build/lib" ]; then ln -s ${WORKSPACE}/lib ${WORKSPACE}/build/lib; fi
- DEPLOY_CMD="CONFIG=${WORKSPACE}/build RESOURCES=${WORKSPACE}/build/images/ ./deploy.sh -c ${WORKSPACE}/build -r ${WORKSPACE}/build/images/"
- DEPLOY_FILE="${WORKSPACE}/config/deploy/${DEPLOY_SCENARIO}.yaml"
- NETWORK_FILE="${WORKSPACE}/config/network/network_settings.yaml"
- # Make sure python34 is installed
- if ! rpm -q python34 > /dev/null; then
- sudo yum install -y epel-release
- if ! sudo yum install -y python34; then
- echo "Failed to install python34"
- exit 1
- fi
- fi
- if ! rpm -q python34-PyYAML > /dev/null; then
- sudo yum install -y epel-release
- if ! sudo yum install -y python34-PyYAML; then
- echo "Failed to install python34-PyYAML"
- exit 1
- fi
- fi
- if ! rpm -q python34-setuptools > /dev/null; then
- if ! sudo yum install -y python34-setuptools; then
- echo "Failed to install python34-setuptools"
- exit 1
- fi
- fi
- if [ -z ${PYTHONPATH:-} ]; then
- export PYTHONPATH=${WORKSPACE}/lib/python
- else
- export PYTHONPATH=$PYTHONPATH:${WORKSPACE}/lib/python
- fi
-else
- VERSION_EXTENSION=$(echo $(basename $RPM_LIST) | grep -Eo '[0-9]+\.[0-9]+-[0-9]{8}')
- for pkg in common undercloud opendaylight-sfc onos; do
- RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}.noarch.rpm"
- done
-
- # update / install the new rpm
- if rpm -q opnfv-apex > /dev/null; then
- INSTALLED_RPMS=$(rpm -qa | grep apex)
- for x in $INSTALLED_RPMS; do
- INSTALLED_RPM_VER=$(echo $x | grep -Eo '[0-9]+\.[0-9]+-[0-9]{8}')
- # Does each RPM's version match the version required for deployment
- if [ "$INSTALLED_RPM_VER" == "$VERSION_EXTENSION" ]; then
- echo "RPM $x is already installed"
- else
- echo "RPM $x does not match version $VERSION_EXTENSION"
- echo "Will upgrade/downgrade RPMs..."
- # Try to upgrade/downgrade RPMS
- if sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
- if ! sudo yum downgrade -y $RPM_LIST; then
- sudo yum remove -y opnfv-apex-undercloud opnfv-apex-common opnfv-apex-opendaylight-sfc opnfv-apex-onos
- if ! sudo yum downgrade -y $RPM_LIST; then
- echo "Unable to downgrade RPMs: $RPM_LIST"
- exit 1
- fi
- fi
- fi
- break
- fi
- done
- else
- sudo yum install -y $RPM_LIST;
- fi
- DEPLOY_CMD=opnfv-deploy
- DEPLOY_FILE="/etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
- NETWORK_FILE="/etc/opnfv-apex/network_settings.yaml"
- export RESOURCES="/var/opt/opnfv/images"
- export CONFIG="/var/opt/opnfv"
-fi
-
-if [ "$OPNFV_CLEAN" == 'yes' ]; then
- if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
- sudo CONFIG=${WORKSPACE}/build ./clean.sh
- else
- sudo opnfv-clean
- fi
-fi
-# initiate virtual deployment
-echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
-if [ -e $DEPLOY_FILE ]; then
- sudo $DEPLOY_CMD -v -d ${DEPLOY_FILE} -n $NETWORK_FILE --debug
-else
- echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
- exit 1
-fi
-echo
-echo "--------------------------------------------------------"
-echo "Done!"
diff --git a/jjb/apex/apex-deploy.sh b/jjb/apex/apex-deploy.sh
new file mode 100755
index 000000000..a5a4e8454
--- /dev/null
+++ b/jjb/apex/apex-deploy.sh
@@ -0,0 +1,164 @@
+#!/bin/bash
+set -o errexit
+set -o nounset
+set -o pipefail
+
+APEX_PKGS="common undercloud opendaylight-sfc onos"
+
+# log info to console
+echo "Starting the Apex virtual deployment."
+echo "--------------------------------------------------------"
+echo
+
+if ! rpm -q wget > /dev/null; then
+ sudo yum -y install wget
+fi
+
+if [[ $BUILD_DIRECTORY == *verify* ]]; then
+ # Build is from a verify, use local build artifacts (not RPMs)
+ cd $WORKSPACE/../${BUILD_DIRECTORY}
+ WORKSPACE=$(pwd)
+ echo "WORKSPACE modified to $WORKSPACE"
+ cd $WORKSPACE/ci
+elif [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
+ # if artifact name is passed the pull a
+ # specific artifact from artifacts.opnfv.org
+ # artifact specified should be opnfv-apex-<version>.noarch.rpm
+ RPM_INSTALL_PATH=$GS_URL
+ RPM_LIST=$RPM_INSTALL_PATH/$ARTIFACT_NAME
+else
+ # Use latest RPMS
+ if [[ $BUILD_DIRECTORY == *apex-build* ]]; then
+ # Triggered from a daily so RPMS should be in local directory
+ BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
+ echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
+
+ if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
+ # if opnfv.properties exists then use the
+ # local build. Source the file so we get local OPNFV vars
+ source ${BUILD_DIRECTORY}/../opnfv.properties
+ RPM_INSTALL_PATH=${BUILD_DIRECTORY}/noarch
+ RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
+ else
+ echo "BUILD_DIRECTORY is from a daily job, so will not use latest from URL"
+ echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
+ exit 1
+ fi
+ else
+ # use the latest from artifacts.opnfv.org
+ # get the latest.properties to get the link to the latest artifact
+ if ! wget -O $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties; then
+ echo "ERROR: Unable to find latest.properties at ${GS_URL}...exiting"
+ exit 1
+ fi
+ # source the file so we get OPNFV vars
+ source opnfv.properties
+ RPM_INSTALL_PATH=$(echo $OPNFV_RPM_URL | sed 's/'"$(basename $OPNFV_RPM_URL)"'//')
+ RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
+ fi
+fi
+
+if [ -z "$DEPLOY_SCENARIO" ]; then
+ echo "Deploy scenario not set!"
+ exit 1
+fi
+
+# use local build for verify
+if [[ "$BUILD_DIRECTORY" == *verify* ]]; then
+ if [ ! -e "${WORKSPACE}/build/lib" ]; then
+ ln -s ${WORKSPACE}/lib ${WORKSPACE}/build/lib
+ fi
+ DEPLOY_SETTINGS_DIR="${WORKSPACE}/config/deploy"
+ NETWORK_SETTINGS_DIR="${WORKSPACE}/config/network"
+ DEPLOY_CMD="$(pwd)/deploy.sh"
+ export RESOURCES="${WORKSPACE}/build/images/"
+ export CONFIG="${WORKSPACE}/build"
+ export LIB="${WORKSPACE}/lib"
+ # Make sure python34 deps are installed
+ for dep_pkg in epel-release python34 python34-PyYAML python34-setuptools; do
+ if ! rpm -q ${dep_pkg} > /dev/null; then
+ if ! sudo yum install -y ${dep_pkg}; then
+ echo "Failed to install ${dep_pkg}"
+ exit 1
+ fi
+ fi
+ done
+
+ if [ -z ${PYTHONPATH:-} ]; then
+ export PYTHONPATH=${WORKSPACE}/lib/python
+ else
+ export PYTHONPATH=$PYTHONPATH:${WORKSPACE}/lib/python
+ fi
+# use RPMs
+else
+ # find version of RPM
+ VERSION_EXTENSION=$(echo $(basename $RPM_LIST) | grep -Eo '[0-9]+\.[0-9]+-[0-9]{8}')
+ # build RPM List which already includes base Apex RPM
+ for pkg in ${APEX_PKGS}; do
+ RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}.noarch.rpm"
+ done
+
+ # remove old / install new RPMs
+ if rpm -q opnfv-apex > /dev/null; then
+ INSTALLED_RPMS=$(rpm -qa | grep apex)
+ if [ -n "$INSTALLED_RPMS" ]; then
+ sudo yum remove -y ${INSTALLED_RPMS}
+ fi
+ fi
+
+ if ! sudo yum install -y $RPM_LIST; then
+ echo "Unable to install new RPMs: $RPM_LIST"
+ exit 1
+ fi
+
+ DEPLOY_CMD=opnfv-deploy
+ DEPLOY_SETTINGS_DIR="/etc/opnfv-apex/"
+ NETWORK_SETTINGS_DIR="/etc/opnfv-apex/"
+ export RESOURCES="/var/opt/opnfv/images"
+ export CONFIG="/var/opt/opnfv"
+fi
+
+if [ "$OPNFV_CLEAN" == 'yes' ]; then
+ if [[ "$BUILD_DIRECTORY" == *verify* ]]; then
+ sudo ./clean.sh
+ else
+ sudo opnfv-clean
+ fi
+fi
+
+echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
+DEPLOY_FILE="${DEPLOY_SETTINGS_DIR}/${DEPLOY_SCENARIO}.yaml"
+
+if [ ! -e "$DEPLOY_FILE" ]; then
+ echo "ERROR: Required settings file missing: Deploy settings file ${DEPLOY_FILE}"
+fi
+
+if [[ "$JOB_NAME" == *virtual* ]]; then
+ # settings for virtual deployment
+ NETWORK_FILE="${NETWORK_SETTINGS_DIR}/network_settings.yaml"
+ DEPLOY_CMD="${DEPLOY_CMD} -v"
+else
+ # settings for bare metal deployment
+ NETWORK_FILE="/root/network/network_settings.yaml"
+ INVENTORY_FILE="/root/inventory/pod_settings.yaml"
+
+ if [ ! -e "$INVENTORY_FILE" ]; then
+ echo "ERROR: Required settings file missing: Inventory settings file ${INVENTORY_FILE}"
+ fi
+ # include inventory file for bare metal deployment
+ DEPLOY_CMD="${DEPLOY_CMD} -i ${INVENTORY_FILE}"
+fi
+
+# Check that network settings file exists
+if [ ! -e "$NETWORK_FILE" ]; then
+ echo "ERROR: Required settings file missing for Network Settings"
+ echo "Network settings file: ${NETWORK_FILE}"
+ exit 1
+fi
+
+# start deployment
+sudo ${DEPLOY_CMD} -d ${DEPLOY_FILE} -n ${NETWORK_FILE} --debug
+
+echo
+echo "--------------------------------------------------------"
+echo "Done!"
diff --git a/jjb/apex/apex.yml b/jjb/apex/apex.yml
index ed06113d5..c121d635f 100644
--- a/jjb/apex/apex.yml
+++ b/jjb/apex/apex.yml
@@ -412,7 +412,7 @@
max-total: 10
builders:
- - 'apex-deploy-virtual'
+ - 'apex-deploy'
- 'apex-workspace-cleanup'
- job-template:
@@ -453,7 +453,7 @@
builders:
- - 'apex-deploy-baremetal'
+ - 'apex-deploy'
- 'apex-workspace-cleanup'
# Brahmaputra Daily
@@ -754,16 +754,11 @@
!include-raw: ./apex-gs-cleanup.sh
- builder:
- name: 'apex-deploy-virtual'
+ name: 'apex-deploy'
builders:
- shell:
- !include-raw: ./apex-deploy-virtual.sh
+ !include-raw: ./apex-deploy.sh
-- builder:
- name: 'apex-deploy-baremetal'
- builders:
- - shell:
- !include-raw: ./apex-deploy-baremetal.sh
#######################
# trigger macros