Skip to content

Commit be26306

Browse files
committed
Support extras in Glance Store install
Recent change to devstack dropped installing test-requirements [1] However, this caused gate failures due to lack of glance-store deps for cinder and swift support. This patch makes devstack install relevant extras depending on enabled features. Additionally, relevant functions are added/fixed to make this possible. glance-store = glance_store (for gerrit search match) [1] https://review.opendev.org/715469 Change-Id: I0bf5792a6058b52936115b515ea8360f6264a7c9
1 parent 09b5b05 commit be26306

2 files changed

Lines changed: 41 additions & 6 deletions

File tree

inc/python

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ set +o xtrace
2121
# project. A null value installs to the system Python directories.
2222
declare -A -g PROJECT_VENV
2323

24+
# Utility Functions
25+
# =================
26+
27+
# Joins bash array of extras with commas as expected by other functions
28+
function join_extras {
29+
local IFS=","
30+
echo "$*"
31+
}
2432

2533
# Python Functions
2634
# ================
@@ -80,9 +88,9 @@ function pip_install_gr {
8088
function pip_install_gr_extras {
8189
local name=$1
8290
local extras=$2
83-
local clean_name
84-
clean_name=$(get_from_global_requirements $name)
85-
pip_install $clean_name[$extras]
91+
local version_constraints
92+
version_constraints=$(get_version_constraints_from_global_requirements $name)
93+
pip_install $name[$extras]$version_constraints
8694
}
8795

8896
# enable_python3_package() -- no-op for backwards compatibility
@@ -230,6 +238,19 @@ function get_from_global_requirements {
230238
echo $required_pkg
231239
}
232240

241+
# get only version constraints of a package from global requirements file
242+
# get_version_constraints_from_global_requirements <package>
243+
function get_version_constraints_from_global_requirements {
244+
local package=$1
245+
local required_pkg_version_constraint
246+
# drop the package name from output (\K)
247+
required_pkg_version_constraint=$(grep -i -h -o -P "^${package}\K.*" $REQUIREMENTS_DIR/global-requirements.txt | cut -d\# -f1)
248+
if [[ $required_pkg_version_constraint == "" ]]; then
249+
die $LINENO "Can't find package $package in requirements"
250+
fi
251+
echo $required_pkg_version_constraint
252+
}
253+
233254
# should we use this library from their git repo, or should we let it
234255
# get pulled in via pip dependencies.
235256
function use_library_from_git {
@@ -278,7 +299,7 @@ function setup_lib {
278299
#
279300
# use this for non namespaced libraries
280301
#
281-
# setup_dev_lib [-bindep] <name>
302+
# setup_dev_lib [-bindep] <name> [<extras>]
282303
function setup_dev_lib {
283304
local bindep
284305
if [[ $1 == -bindep* ]]; then
@@ -287,7 +308,8 @@ function setup_dev_lib {
287308
fi
288309
local name=$1
289310
local dir=${GITDIR[$name]}
290-
setup_develop $bindep $dir
311+
local extras=$2
312+
setup_develop $bindep $dir $extras
291313
}
292314

293315
# this should be used if you want to install globally, all libraries should

lib/glance

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,24 @@ function install_glanceclient {
355355

356356
# install_glance() - Collect source and prepare
357357
function install_glance {
358+
local glance_store_extras=()
359+
360+
if is_service_enabled cinder; then
361+
glance_store_extras=("cinder" "${glance_store_extras[@]}")
362+
fi
363+
364+
if is_service_enabled swift; then
365+
glance_store_extras=("swift" "${glance_store_extras[@]}")
366+
fi
367+
358368
# Install glance_store from git so we make sure we're testing
359369
# the latest code.
360370
if use_library_from_git "glance_store"; then
361371
git_clone_by_name "glance_store"
362-
setup_dev_lib "glance_store"
372+
setup_dev_lib "glance_store" $(join_extras "${glance_store_extras[@]}")
373+
else
374+
# we still need to pass extras
375+
pip_install_gr_extras glance-store $(join_extras "${glance_store_extras[@]}")
363376
fi
364377

365378
git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH

0 commit comments

Comments
 (0)