simplify devstack plugin
This change replaces the nested if used in plugin.sh with nested case statements for greater readablity. This change removes an unnecessary check to determine if services are enabled. By default all cyborg service are enabled by the plugin. Since the plugin is not loaded unless the user specifies the enable_plugin line in there local.conf we can assume they want the plugin to run and there for can remove the service check. This change removes the install_agent function and renames install_cyborg_in_controller function to check_cyborg_service_deps to better reflect what the function does. Change-Id: Ia5ad1235ae4a5a76bcd498a743ca6be6b3634c5c
This commit is contained in:
parent
b3aa875c3c
commit
dd2024ee95
|
@ -19,9 +19,7 @@
|
|||
# - stop_cyborg
|
||||
# - cleanup_cyborg
|
||||
|
||||
# TODO(sean-k-mooney): this does not install anything
|
||||
# consider renameing.
|
||||
function install_cyborg_in_controller {
|
||||
function check_cyborg_service_deps {
|
||||
if is_service_enabled cyborg-api; then
|
||||
local req_services="key"
|
||||
req_services+=" placement"
|
||||
|
@ -46,20 +44,6 @@ function pre_install_agent {
|
|||
fi
|
||||
}
|
||||
|
||||
# TODO(sean-k-mooney): this function is not required
|
||||
# cyborg does not depend on libvirt so if n-cpu is not
|
||||
# enabled it should not be installed.
|
||||
function install_agent {
|
||||
if is_service_enabled cyborg-agent; then
|
||||
# stack/install - Called after the layer 1 and 2 projects source and
|
||||
# their dependencies have been installed
|
||||
if ! is_service_enabled n-cpu; then
|
||||
source $RC_DIR/lib/nova_plugins/functions-libvirt
|
||||
install_libvirt
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanup_agent {
|
||||
if is_service_enabled cyborg-agent; then
|
||||
if [[ "$OPAE_INSTALL_ENABLE" == "True" ]]; then
|
||||
|
@ -71,7 +55,7 @@ function cleanup_agent {
|
|||
# install_cyborg() - Install the things!
|
||||
function install_cyborg {
|
||||
# make sure all needed services are enabled
|
||||
install_cyborg_in_controller
|
||||
check_cyborg_service_deps
|
||||
# install the cyborg project from git
|
||||
setup_develop $CYBORG_DIR
|
||||
}
|
||||
|
|
|
@ -8,43 +8,43 @@ echo_summary "cyborg devstack plugin.sh called: $1/$2"
|
|||
source $DEST/cyborg/devstack/lib/cyborg
|
||||
source $DEST/cyborg/devstack/lib/opae
|
||||
|
||||
|
||||
if is_service_enabled cyborg-api cyborg-cond || is_service_enabled cyborg-agent; then
|
||||
if [[ "$1" == "stack" ]]; then
|
||||
if [[ "$2" == "pre-install" ]]; then
|
||||
pre_install_agent
|
||||
elif [[ "$2" == "install" ]]; then
|
||||
echo_summary "Installing Cyborg"
|
||||
install_agent
|
||||
install_cyborg
|
||||
elif [[ "$2" == "post-config" ]]; then
|
||||
# stack/post-config - Called after the layer 0 and 2 services have been
|
||||
# configured. All configuration files for enabled services should exist
|
||||
# at this point.
|
||||
echo_summary "Configuring Cyborg"
|
||||
configure_cyborg
|
||||
create_cyborg_accounts
|
||||
elif [[ "$2" == "extra" ]]; then
|
||||
# stack/extra - Called near the end after layer 1 and 2 services have
|
||||
# been started.
|
||||
# Initialize cyborg
|
||||
init_cyborg
|
||||
|
||||
# Start the cyborg API and cyborg taskmgr components
|
||||
echo_summary "Starting Cyborg"
|
||||
start_cyborg
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
# unstack - Called by unstack.sh before other services are shut down.
|
||||
case $1 in
|
||||
"stack")
|
||||
case $2 in
|
||||
"pre-install")
|
||||
pre_install_agent
|
||||
;;
|
||||
"install")
|
||||
echo_summary "Installing Cyborg"
|
||||
install_cyborg
|
||||
;;
|
||||
"post-config")
|
||||
# stack/post-config - Called after the layer 0 and 2 services
|
||||
# have been configured. All configuration files for enabled
|
||||
# services should exist at this point.
|
||||
echo_summary "Configuring Cyborg"
|
||||
configure_cyborg
|
||||
create_cyborg_accounts
|
||||
;;
|
||||
"extra")
|
||||
# stack/extra - Called near the end after layer 1 and 2
|
||||
# services have been started.
|
||||
# Initialize cyborg
|
||||
init_cyborg
|
||||
# Start the cyborg API and cyborg taskmgr components
|
||||
echo_summary "Starting Cyborg"
|
||||
start_cyborg
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"unstack")
|
||||
# unstack - Called by unstack.sh before other services are shut down.
|
||||
stop_cyborg
|
||||
fi
|
||||
|
||||
if [[ "$1" == "clean" ]]; then
|
||||
# clean - Called by clean.sh before other services are cleaned, but after
|
||||
# unstack.sh has been called.
|
||||
;;
|
||||
"clean")
|
||||
# clean - Called by clean.sh before other services are cleaned, but after
|
||||
# unstack.sh has been called.
|
||||
cleanup_cyborg
|
||||
cleanup_agent
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in New Issue