diff --git a/devstack/plugin.sh b/devstack/plugin.sh index ae517a9f9b..4250ea93c2 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -34,6 +34,8 @@ function octavia_lib_install { if use_library_from_git "octavia-lib"; then git_clone_by_name "octavia-lib" setup_dev_lib "octavia-lib" + export DIB_REPOLOCATION_octavia_lib=${GITDIR["octavia-lib"]} + export DIB_REPOREF_octavia_lib=$(git --git-dir="${GITDIR["octavia-lib"]}/.git" log -1 --pretty="format:%H") else pip_install_gr octavia-lib fi diff --git a/diskimage-create/README.rst b/diskimage-create/README.rst index 292418efbc..f650fa88c3 100644 --- a/diskimage-create/README.rst +++ b/diskimage-create/README.rst @@ -218,6 +218,18 @@ DIB_REPOREF_amphora_agent - Example: stable/stein - Example: refs/changes/40/674140/7 +DIB_REPOLOCATION_octavia_lib + - Location of the octavia-lib code that will be installed in the image. + - Default: https://opendev.org/openstack/octavia-lib + - Example: /tmp/octavia-lib + +DIB_REPOREF_octavia_lib + - The Git reference to checkout for the octavia-lib code inside the + image. + - Default: master or stable branch for released OpenStack series installs. + - Example: stable/ussuri + - Example: refs/changes/19/744519/2 + DIB_REPOLOCATION_upper_constraints - Location of the upper-constraints.txt file used for the image. - Default: The upper-constraints.txt for the current branch diff --git a/diskimage-create/diskimage-create.sh b/diskimage-create/diskimage-create.sh index 2c70165b1d..cab300b4a5 100755 --- a/diskimage-create/diskimage-create.sh +++ b/diskimage-create/diskimage-create.sh @@ -433,6 +433,7 @@ fi AMP_element_sequence="$AMP_element_sequence rebind-sshd" AMP_element_sequence="$AMP_element_sequence no-resolvconf" AMP_element_sequence="$AMP_element_sequence amphora-agent" +AMP_element_sequence="$AMP_element_sequence octavia-lib" AMP_element_sequence="$AMP_element_sequence sos" AMP_element_sequence="$AMP_element_sequence cloud-init-datasources" AMP_element_sequence="$AMP_element_sequence remove-default-ints" diff --git a/elements/octavia-lib/README.rst b/elements/octavia-lib/README.rst new file mode 100644 index 0000000000..be75612456 --- /dev/null +++ b/elements/octavia-lib/README.rst @@ -0,0 +1,24 @@ +Element to install octavia-lib from a Git source. + +This element allows octavia-lib installs from an arbitraty Git repository. +This is especially useful for development environments. + +By default, octavia-lib is installed from upstream master branch or from an +upstream stable branch for OpenStack release series. + +To install from an alternative Git location, define the following: + +.. sourcecode:: sh + + DIB_REPOLOCATION_octavia_lib= + DIB_REPOREF_octavia_lib= + +If you wish to build an image using code from a Gerrit review, you can set +``DIB_REPOLOCATION_octavia_lib`` and ``DIB_REPOREF_octavia_lib`` to the values +given by Gerrit in the fetch/pull section of a review. For example, installing +octavia-lib with change 744519 at patchset 2: + +.. sourcecode:: sh + + DIB_REPOLOCATION_octavia_lib=https://review.opendev.org/openstack/octavia-lib + DIB_REPOREF_octavia_lib=refs/changes/19/744519/2 diff --git a/elements/octavia-lib/element-deps b/elements/octavia-lib/element-deps new file mode 100644 index 0000000000..7bfe55bdc1 --- /dev/null +++ b/elements/octavia-lib/element-deps @@ -0,0 +1,2 @@ +source-repositories +amphora-agent diff --git a/elements/octavia-lib/install.d/octavia-lib-source-install/76-octavia-lib-install b/elements/octavia-lib/install.d/octavia-lib-source-install/76-octavia-lib-install new file mode 100755 index 0000000000..ea054f9d92 --- /dev/null +++ b/elements/octavia-lib/install.d/octavia-lib-source-install/76-octavia-lib-install @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +AMP_VENV=/opt/amphora-agent-venv + +sed -i 's|octavia-lib|#octavia-lib|' /opt/upper-constraints.txt +$AMP_VENV/bin/pip install -U -c /opt/upper-constraints.txt /opt/octavia-lib + +# Let's capture the git reference we installed in the venv +git --git-dir=/opt/octavia-lib/.git rev-parse HEAD >> /opt/octavia-lib.gitref diff --git a/elements/octavia-lib/post-install.d/89-remove-build-deps b/elements/octavia-lib/post-install.d/89-remove-build-deps new file mode 100755 index 0000000000..e397795a16 --- /dev/null +++ b/elements/octavia-lib/post-install.d/89-remove-build-deps @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi + +set -eu +set -o pipefail + +[ "${DIB_INSTALLTYPE_octavia_lib:-}" = "package" ] && exit 0 + +rm -rf /opt/octavia-lib diff --git a/elements/octavia-lib/source-repository-octavia-lib b/elements/octavia-lib/source-repository-octavia-lib new file mode 100644 index 0000000000..33694cbbb3 --- /dev/null +++ b/elements/octavia-lib/source-repository-octavia-lib @@ -0,0 +1,2 @@ +# This is used for source-based builds +octavia-lib git /opt/octavia-lib https://opendev.org/openstack/octavia-lib