Skip to content

Commit e4fa721

Browse files
author
Dean Troyer
committed
Begin is_service_enabled() cleanup
This converts the special cases in the is_service_enabled() function to call individual functions declared by the projects. This allows projects that are not in the DevStack repo and called via the extras.d plugin to handle an equivalent service alias. * Ceilometer * Cinder * Glance * Neutron * Nova * Swift TODO: remove the tests from is_service_enabled() after a transition period Patch Set 2: Rebased Change-Id: Ic78be433f93a9dd5f46be548bdbd4c984e0da6e7
1 parent f583a04 commit e4fa721

16 files changed

Lines changed: 82 additions & 25 deletions

clean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ if is_service_enabled ldap; then
9797
fi
9898

9999
# Do the hypervisor cleanup until this can be moved back into lib/nova
100-
if [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
100+
if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
101101
cleanup_nova_hypervisor
102102
fi
103103

exercises/boot_from_volume.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
3030
# Import common functions
3131
source $TOP_DIR/functions
3232

33+
# Import project functions
34+
source $TOP_DIR/lib/cinder
35+
3336
# Import configuration
3437
source $TOP_DIR/openrc
3538

36-
# Import neutron functions if needed
37-
if is_service_enabled neutron; then
38-
source $TOP_DIR/lib/neutron
39-
fi
40-
4139
# Import exercise configuration
4240
source $TOP_DIR/exerciserc
4341

exercises/euca.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ source $TOP_DIR/functions
3333
# Import EC2 configuration
3434
source $TOP_DIR/eucarc
3535

36-
# Import neutron functions if needed
37-
if is_service_enabled neutron; then
38-
source $TOP_DIR/lib/neutron
39-
fi
40-
4136
# Import exercise configuration
4237
source $TOP_DIR/exerciserc
4338

exercises/floating_ips.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
2727
# Import common functions
2828
source $TOP_DIR/functions
2929

30+
# Import project functions
31+
source $TOP_DIR/lib/neutron
32+
3033
# Import configuration
3134
source $TOP_DIR/openrc
3235

33-
# Import neutron functions if needed
34-
if is_service_enabled neutron; then
35-
source $TOP_DIR/lib/neutron
36-
fi
37-
3836
# Import exercise configuration
3937
source $TOP_DIR/exerciserc
4038

exercises/volumes.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
2727
# Import common functions
2828
source $TOP_DIR/functions
2929

30+
# Import project functions
31+
source $TOP_DIR/lib/cinder
32+
3033
# Import configuration
3134
source $TOP_DIR/openrc
3235

33-
# Import neutron functions if needed
34-
if is_service_enabled neutron; then
35-
source $TOP_DIR/lib/neutron
36-
fi
37-
3836
# Import exercise configuration
3937
source $TOP_DIR/exerciserc
4038

functions

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,16 @@ function is_service_enabled() {
840840
services=$@
841841
for service in ${services}; do
842842
[[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0
843+
844+
# Look for top-level 'enabled' function for this service
845+
if type is_${service}_enabled >/dev/null 2>&1; then
846+
# A function exists for this service, use it
847+
is_${service}_enabled
848+
return $?
849+
fi
850+
851+
# TODO(dtroyer): Remove these legacy special-cases after the is_XXX_enabled()
852+
# are implemented
843853
[[ ${service} == n-cell-* && ${ENABLED_SERVICES} =~ "n-cell" ]] && return 0
844854
[[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0
845855
[[ ${service} == "cinder" && ${ENABLED_SERVICES} =~ "c-" ]] && return 0

lib/ceilometer

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ TEMPEST_SERVICES+=,ceilometer
5959

6060
# Functions
6161
# ---------
62-
#
62+
63+
# Test if any Ceilometer services are enabled
64+
# is_ceilometer_enabled
65+
function is_ceilometer_enabled {
66+
[[ ,${ENABLED_SERVICES} =~ ,"ceilometer-" ]] && return 0
67+
return 1
68+
}
69+
6370
# create_ceilometer_accounts() - Set up common required ceilometer accounts
6471

6572
create_ceilometer_accounts() {

lib/cinder

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ TEMPEST_SERVICES+=,cinder
8585

8686
# Functions
8787
# ---------
88+
89+
# Test if any Cinder services are enabled
90+
# is_cinder_enabled
91+
function is_cinder_enabled {
92+
[[ ,${ENABLED_SERVICES} =~ ,"c-" ]] && return 0
93+
return 1
94+
}
95+
8896
# _clean_lvm_lv removes all cinder LVM volumes
8997
#
9098
# Usage: _clean_lvm_lv $VOLUME_GROUP $VOLUME_NAME_PREFIX

lib/glance

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ TEMPEST_SERVICES+=,glance
5959
# Functions
6060
# ---------
6161

62+
# Test if any Glance services are enabled
63+
# is_glance_enabled
64+
function is_glance_enabled {
65+
[[ ,${ENABLED_SERVICES} =~ ,"g-" ]] && return 0
66+
return 1
67+
}
68+
6269
# cleanup_glance() - Remove residual data files, anything left over from previous
6370
# runs that a clean run would need to clean up
6471
function cleanup_glance() {

lib/neutron

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ TEMPEST_SERVICES+=,neutron
244244
# Functions
245245
# ---------
246246

247+
# Test if any Neutron services are enabled
248+
# is_neutron_enabled
249+
function is_neutron_enabled {
250+
[[ ,${ENABLED_SERVICES} =~ ,"q-" ]] && return 0
251+
return 1
252+
}
253+
247254
# configure_neutron()
248255
# Set common config for all neutron server and agents.
249256
function configure_neutron() {

0 commit comments

Comments
 (0)