Skip to content

Commit

Permalink
Begin is_service_enabled() cleanup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Dean Troyer committed Feb 7, 2014
1 parent f583a04 commit e4fa721
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 25 deletions.
2 changes: 1 addition & 1 deletion clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if is_service_enabled ldap; then
fi

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

Expand Down
8 changes: 3 additions & 5 deletions exercises/boot_from_volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
# Import common functions
source $TOP_DIR/functions

# Import project functions
source $TOP_DIR/lib/cinder

# Import configuration
source $TOP_DIR/openrc

# Import neutron functions if needed
if is_service_enabled neutron; then
source $TOP_DIR/lib/neutron
fi

# Import exercise configuration
source $TOP_DIR/exerciserc

Expand Down
5 changes: 0 additions & 5 deletions exercises/euca.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ source $TOP_DIR/functions
# Import EC2 configuration
source $TOP_DIR/eucarc

# Import neutron functions if needed
if is_service_enabled neutron; then
source $TOP_DIR/lib/neutron
fi

# Import exercise configuration
source $TOP_DIR/exerciserc

Expand Down
8 changes: 3 additions & 5 deletions exercises/floating_ips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
# Import common functions
source $TOP_DIR/functions

# Import project functions
source $TOP_DIR/lib/neutron

# Import configuration
source $TOP_DIR/openrc

# Import neutron functions if needed
if is_service_enabled neutron; then
source $TOP_DIR/lib/neutron
fi

# Import exercise configuration
source $TOP_DIR/exerciserc

Expand Down
8 changes: 3 additions & 5 deletions exercises/volumes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
# Import common functions
source $TOP_DIR/functions

# Import project functions
source $TOP_DIR/lib/cinder

# Import configuration
source $TOP_DIR/openrc

# Import neutron functions if needed
if is_service_enabled neutron; then
source $TOP_DIR/lib/neutron
fi

# Import exercise configuration
source $TOP_DIR/exerciserc

Expand Down
10 changes: 10 additions & 0 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,16 @@ function is_service_enabled() {
services=$@
for service in ${services}; do
[[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0

# Look for top-level 'enabled' function for this service
if type is_${service}_enabled >/dev/null 2>&1; then
# A function exists for this service, use it
is_${service}_enabled
return $?
fi

# TODO(dtroyer): Remove these legacy special-cases after the is_XXX_enabled()
# are implemented
[[ ${service} == n-cell-* && ${ENABLED_SERVICES} =~ "n-cell" ]] && return 0
[[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0
[[ ${service} == "cinder" && ${ENABLED_SERVICES} =~ "c-" ]] && return 0
Expand Down
9 changes: 8 additions & 1 deletion lib/ceilometer
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ TEMPEST_SERVICES+=,ceilometer

# Functions
# ---------
#

# Test if any Ceilometer services are enabled
# is_ceilometer_enabled
function is_ceilometer_enabled {
[[ ,${ENABLED_SERVICES} =~ ,"ceilometer-" ]] && return 0
return 1
}

# create_ceilometer_accounts() - Set up common required ceilometer accounts

create_ceilometer_accounts() {
Expand Down
8 changes: 8 additions & 0 deletions lib/cinder
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ TEMPEST_SERVICES+=,cinder

# Functions
# ---------

# Test if any Cinder services are enabled
# is_cinder_enabled
function is_cinder_enabled {
[[ ,${ENABLED_SERVICES} =~ ,"c-" ]] && return 0
return 1
}

# _clean_lvm_lv removes all cinder LVM volumes
#
# Usage: _clean_lvm_lv $VOLUME_GROUP $VOLUME_NAME_PREFIX
Expand Down
7 changes: 7 additions & 0 deletions lib/glance
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ TEMPEST_SERVICES+=,glance
# Functions
# ---------

# Test if any Glance services are enabled
# is_glance_enabled
function is_glance_enabled {
[[ ,${ENABLED_SERVICES} =~ ,"g-" ]] && return 0
return 1
}

# cleanup_glance() - Remove residual data files, anything left over from previous
# runs that a clean run would need to clean up
function cleanup_glance() {
Expand Down
7 changes: 7 additions & 0 deletions lib/neutron
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ TEMPEST_SERVICES+=,neutron
# Functions
# ---------

# Test if any Neutron services are enabled
# is_neutron_enabled
function is_neutron_enabled {
[[ ,${ENABLED_SERVICES} =~ ,"q-" ]] && return 0
return 1
}

# configure_neutron()
# Set common config for all neutron server and agents.
function configure_neutron() {
Expand Down
14 changes: 14 additions & 0 deletions lib/nova
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ TEMPEST_SERVICES+=,nova
# Functions
# ---------

# Test if any Nova services are enabled
# is_nova_enabled
function is_nova_enabled {
[[ ,${ENABLED_SERVICES} =~ ,"n-" ]] && return 0
return 1
}

# Test if any Nova Cell services are enabled
# is_nova_enabled
function is_n-cell_enabled {
[[ ,${ENABLED_SERVICES} =~ ,"n-cell-" ]] && return 0
return 1
}

# Helper to clean iptables rules
function clean_iptables() {
# Delete rules
Expand Down
7 changes: 7 additions & 0 deletions lib/swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ TEMPEST_SERVICES+=,swift
# Functions
# ---------

# Test if any Swift services are enabled
# is_swift_enabled
function is_swift_enabled {
[[ ,${ENABLED_SERVICES} =~ ,"s-" ]] && return 0
return 1
}

# cleanup_swift() - Remove residual data files
function cleanup_swift() {
rm -f ${SWIFT_CONF_DIR}{*.builder,*.ring.gz,backups/*.builder,backups/*.ring.gz}
Expand Down
8 changes: 8 additions & 0 deletions lib/template
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# ``stack.sh`` calls the entry points in this order:
#
# - is_XXXX_enabled
# - install_XXXX
# - configure_XXXX
# - init_XXXX
Expand All @@ -35,6 +36,13 @@ XXX_CONF_DIR=/etc/XXXX
# Entry Points
# ------------

# Test if any XXXX services are enabled
# is_XXXX_enabled
function is_XXXX_enabled {
[[ ,${ENABLED_SERVICES} =~ ,"XX-" ]] && return 0
return 1
}

# cleanup_XXXX() - Remove residual data files, anything left over from previous
# runs that a clean run would need to clean up
function cleanup_XXXX() {
Expand Down
2 changes: 1 addition & 1 deletion stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ if is_service_enabled s-proxy; then
fi

# Launch the Glance services
if is_service_enabled g-api g-reg; then
if is_service_enabled glance; then
echo_summary "Starting Glance"
start_glance
fi
Expand Down
2 changes: 1 addition & 1 deletion stackrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fi
# enable_service neutron
# # Optional, to enable tempest configuration as part of devstack
# enable_service tempest
ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,cinder,c-sch,c-api,c-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,rabbit,tempest,mysql
ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,c-sch,c-api,c-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,rabbit,tempest,mysql

# Tell Tempest which services are available. The default is set here as
# Tempest falls late in the configuration sequence. This differs from
Expand Down
2 changes: 1 addition & 1 deletion unstack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ if is_service_enabled nova; then
stop_nova
fi

if is_service_enabled g-api g-reg; then
if is_service_enabled glance; then
stop_glance
fi

Expand Down

0 comments on commit e4fa721

Please sign in to comment.