From d244c9d6661a4595533fcbb972798771791f4ed5 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Sat, 5 Oct 2019 13:11:20 +1300 Subject: [PATCH] Support to specify branch when building the image - Explicity specify branch name for building non-dev image - Use branch name for building dev image in devstack - Update the doc Candidate backport for stable/train Change-Id: I4d2fe38fac34c75b42234fa7a20aba51e6dc1c4e --- devstack/plugin.sh | 7 ++++++- doc/source/admin/trovestack.rst | 3 +++ .../elements/guest-agent/source-repository-guest-agent | 2 +- .../elements/ubuntu-guest/extra-data.d/15-trove-dep | 9 +++------ integration/scripts/functions_qemu | 2 ++ integration/scripts/trovestack | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index f5ee71ec1d..a2a88a7e34 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -447,7 +447,12 @@ function create_guest_image { echo "Starting to create guest image..." - $DEST/trove/integration/scripts/trovestack build-image ${TROVE_DATASTORE_TYPE} ${TROVE_IMAGE_OS} ${TROVE_IMAGE_OS_RELEASE} true + TROVE_BRANCH=${TROVE_BRANCH} $DEST/trove/integration/scripts/trovestack \ + build-image \ + ${TROVE_DATASTORE_TYPE} \ + ${TROVE_IMAGE_OS} \ + ${TROVE_IMAGE_OS_RELEASE} \ + true image_name="trove-${TROVE_IMAGE_OS}-${TROVE_IMAGE_OS_RELEASE}-${TROVE_DATASTORE_TYPE}" image_file=$HOME/images/${image_name}.qcow2 diff --git a/doc/source/admin/trovestack.rst b/doc/source/admin/trovestack.rst index a4998c2260..e023f610fc 100644 --- a/doc/source/admin/trovestack.rst +++ b/doc/source/admin/trovestack.rst @@ -80,6 +80,9 @@ The trove guest agent image could be created by running the following command: environment, it should be the ``stack`` user. * ``GUEST_WORKING_DIR``: The place to save the guest image, default value is ``$HOME/images``. + * ``TROVE_BRANCH``: only used in dev mode. The branch name of Trove code + repository, by default it's master, use other branches as needed such as + stable/train. For example, in order to build a MySQL image for Ubuntu Xenial operating system in development mode: diff --git a/integration/scripts/files/elements/guest-agent/source-repository-guest-agent b/integration/scripts/files/elements/guest-agent/source-repository-guest-agent index ff2a8b0b9e..9860bac640 100644 --- a/integration/scripts/files/elements/guest-agent/source-repository-guest-agent +++ b/integration/scripts/files/elements/guest-agent/source-repository-guest-agent @@ -1,3 +1,3 @@ # This is used for source-based builds -guest-agent git /opt/guest-agent https://opendev.org/openstack/trove +guest-agent git /opt/guest-agent https://opendev.org/openstack/trove master upper-constraints file /opt/upper-constraints.txt https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt diff --git a/integration/scripts/files/elements/ubuntu-guest/extra-data.d/15-trove-dep b/integration/scripts/files/elements/ubuntu-guest/extra-data.d/15-trove-dep index f563406a2c..bf71faa779 100755 --- a/integration/scripts/files/elements/ubuntu-guest/extra-data.d/15-trove-dep +++ b/integration/scripts/files/elements/ubuntu-guest/extra-data.d/15-trove-dep @@ -8,7 +8,7 @@ set -o xtrace source $_LIB/die -BRANCH_OVERRIDE=${BRANCH_OVERRIDE:-default} +TROVE_BRANCH=${TROVE_BRANCH:-'master'} REQUIREMENTS_FILE=${TROVESTACK_SCRIPTS}/../../requirements.txt [ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set" @@ -30,13 +30,10 @@ if [ -f "${DEST}/requirements/${UC_FILE}" ]; then of="${TMP_HOOKS_PATH}/${UC_FILE}" else UC_DIR=$(pwd) - UC_BRANCH=${BRANCH_OVERRIDE} - if [ "${UC_BRANCH}" == "default" ]; then - UC_BRANCH=master - fi + UC_BRANCH=${TROVE_BRANCH##stable/} set +e - curl -o "${UC_DIR}/${UC_FILE}" "https://opendev.org/openstack/requirements/raw/branch/${UC_BRANCH}/${UC_FILE}" + curl -L -o "${UC_DIR}/${UC_FILE}" "https://releases.openstack.org/constraints/upper/${UC_BRANCH}" set -e if [ -f "${UC_DIR}/${UC_FILE}" ]; then diff --git a/integration/scripts/functions_qemu b/integration/scripts/functions_qemu index b40adcea54..acc624401e 100644 --- a/integration/scripts/functions_qemu +++ b/integration/scripts/functions_qemu @@ -36,6 +36,8 @@ function build_vm() { export HOST_SCP_USERNAME=${HOST_SCP_USERNAME:-$(whoami)} export HOST_USERNAME=${HOST_SCP_USERNAME} export SSH_DIR=${SSH_DIR:-"$HOME/.ssh"} + export DEST=${DEST:-'/opt/stack'} + export TROVE_BRANCH=${TROVE_BRANCH:-'master'} manage_ssh_keys fi diff --git a/integration/scripts/trovestack b/integration/scripts/trovestack index 8ad5e341a4..ecc88f0ff7 100755 --- a/integration/scripts/trovestack +++ b/integration/scripts/trovestack @@ -827,7 +827,7 @@ function cmd_build_image() { local IMAGE_GUEST_OS=${2:-'ubuntu'} local IMAGE_GUEST_RELEASE=${3:-'xenial'} local DEV_MODE=${4:-'true'} - local guest_username=${5:-"ubuntu"} + local guest_username=${5:-'ubuntu'} local output=$6 if [[ -z "$output" ]]; then