move setting to devstack/settings

All user settable options should be stored the
devstack/setting file so they are defiend when it is
sourced early in devstack to allow values to be shared
between plugins if required.

This change moves the cyborg settings from
devstack/lib/cyborg to devstack/settings to conform to
the standard plugin interface.

The name of the folder where devstack clones the plugin
is specified in the first argument ot the enable_plugin
function invocation in the local.conf.
This change makes updates CYBORG_DIR to respect that
and adds TODOs for other issues that will be adressed in
follow up patches.

Change-Id: I5b6879e5ddb86659b8c7eb87b8d26cee33ed4754
This commit is contained in:
Sean Mooney 2020-02-19 20:55:23 +00:00
parent eb12f68421
commit 985b15287e
3 changed files with 54 additions and 43 deletions

View File

@ -19,52 +19,11 @@
# - stop_cyborg
# - cleanup_cyborg
# TODO(sean-k-mooney): this should not be required.
# ensure we don't re-source this in the same environment
[[ -z "$_CYBORG_DEVSTACK_LIB" ]] || return 0
declare -r -g _CYBORG_DEVSTACK_LIB=1
# Defaults
# --------
# Set up default repos
CYBORG_REPO=${CYBORG_REPO:-${GIT_BASE}/openstack/cyborg.git}
CYBORG_BRANCH=${CYBORG_BRANCH:-master}
# Set up default directories
CYBORG_DIR=$DEST/cyborg
CYBORG_DEVSTACK_DIR=$CYBORG_DIR/devstack
CYBORG_DEVSTACK_FILES_DIR=$CYBORG_DEVSTACK_DIR/files
CYBORG_DATA_DIR=$DATA_DIR/cyborg
CYBORG_STATE_PATH=/var/lib/cyborg
CYBORG_AUTH_CACHE_DIR=${CYBORG_AUTH_CACHE_DIR:-/var/cache/cyborg}
CYBORG_CONF_DIR=${CYBORG_CONF_DIR:-/etc/cyborg}
CYBORG_CONF_FILE=$CYBORG_CONF_DIR/cyborg.conf
CYBORG_API_PASTE_INI=$CYBORG_CONF_DIR/api-paste.ini
CYBORG_POLICY_JSON=$CYBORG_CONF_DIR/policy.json
CYBORG_SERVICE_HOST=${CYBORG_SERVICE_HOST:-$SERVICE_HOST}
CYBORG_SERVICE_PORT=${CYBORG_SERVICE_PORT:-6666}
CYBORG_SERVICE_PROTOCOL=${CYBORG_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
CYBORG_ENABLED_DRIVERS=${CYBORG_ENABLED_DRIVERS:-fake_driver}
if [[ -d ${CYBORG_DIR}/bin ]]; then
CYBORG_BIN_DIR=${CYBORG_DIR}/bin
else
CYBORG_BIN_DIR=$(get_python_exec_prefix)
fi
# Toggle for deploying Cyborg-API under a wsgi server
CYBORG_USE_UWSGI=${CYBORG_USE_UWSGI:-True}
CYBORG_UWSGI=$CYBORG_BIN_DIR/cyborg-wsgi-api
CYBORG_UWSGI_CONF=$CYBORG_CONF_DIR/cyborg-api-uwsgi.ini
if [[ "$CYBORG_USE_UWSGI" == "True" ]]; then
CYBORG_API_URL="$CYBORG_SERVICE_PROTOCOL://$CYBORG_SERVICE_HOST/accelerator"
else
CYBORG_API_URL="$CYBORG_SERVICE_PROTOCOL://$CYBORG_SERVICE_HOST:$CYBORG_SERVICE_PORT"
fi
function install_cyborg_in_controller {
if is_service_enabled cyborg-api; then
local req_services="key"
@ -81,7 +40,10 @@ function install_cyborg_in_controller {
function install_cyborg {
# make sure all needed services are enabled
install_cyborg_in_controller
# TODO(sean-k-mooney): This is a bug and does not conform to
# the devstack plugin interface. devstack plugins should not
# reclone the repo they are packaged in over the directory
# they are executing form.
git_clone $CYBORG_REPO $CYBORG_DIR $CYBORG_BRANCH
setup_develop $CYBORG_DIR

View File

@ -6,6 +6,7 @@
# Dependencies:
#
# TODO(sean-k-mooney): this should not be required.
# ensure we don't re-source this in the same environment
[[ -z "$_OPAE_PKG_FNS" ]] || return 0
declare -r -g _OPAE_PKG_FNS=1

View File

@ -1,5 +1,53 @@
enable_service cyborg cyborg-api cyborg-cond cyborg-agent
# cyborg setting
# Defaults
# --------
# NOTE(sean-k-mooney): these should be removed in the future as
# devstack plugins should not clone the repo they are packaged in.
# Cloning the repo from within the plugin will result in the plugin
# script replacing the directory it is executing form.
# Set up default repos
CYBORG_REPO=${CYBORG_REPO:-${GIT_BASE}/openstack/cyborg.git}
CYBORG_BRANCH=${CYBORG_BRANCH:-master}
# Set up default directories
# then name of the directory where cyborg is cloned is set by the first
# argument to enable_plugin so we should not assume it will be cyborg
CYBORG_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )
CYBORG_DEVSTACK_DIR=$CYBORG_DIR/devstack
CYBORG_DEVSTACK_FILES_DIR=$CYBORG_DEVSTACK_DIR/files
CYBORG_DATA_DIR=$DATA_DIR/cyborg
CYBORG_STATE_PATH=/var/lib/cyborg
CYBORG_AUTH_CACHE_DIR=${CYBORG_AUTH_CACHE_DIR:-/var/cache/cyborg}
CYBORG_CONF_DIR=${CYBORG_CONF_DIR:-/etc/cyborg}
CYBORG_CONF_FILE=$CYBORG_CONF_DIR/cyborg.conf
CYBORG_API_PASTE_INI=$CYBORG_CONF_DIR/api-paste.ini
CYBORG_POLICY_JSON=$CYBORG_CONF_DIR/policy.json
CYBORG_SERVICE_HOST=${CYBORG_SERVICE_HOST:-$SERVICE_HOST}
CYBORG_SERVICE_PORT=${CYBORG_SERVICE_PORT:-6666}
CYBORG_SERVICE_PROTOCOL=${CYBORG_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
CYBORG_ENABLED_DRIVERS=${CYBORG_ENABLED_DRIVERS:-fake_driver}
if [[ -d ${CYBORG_DIR}/bin ]]; then
CYBORG_BIN_DIR=${CYBORG_DIR}/bin
else
CYBORG_BIN_DIR=$(get_python_exec_prefix)
fi
# Toggle for deploying Cyborg-API under a wsgi server
CYBORG_USE_UWSGI=${CYBORG_USE_UWSGI:-True}
CYBORG_UWSGI=$CYBORG_BIN_DIR/cyborg-wsgi-api
CYBORG_UWSGI_CONF=$CYBORG_CONF_DIR/cyborg-api-uwsgi.ini
if [[ "$CYBORG_USE_UWSGI" == "True" ]]; then
CYBORG_API_URL="$CYBORG_SERVICE_PROTOCOL://$CYBORG_SERVICE_HOST/accelerator"
else
CYBORG_API_URL="$CYBORG_SERVICE_PROTOCOL://$CYBORG_SERVICE_HOST:$CYBORG_SERVICE_PORT"
fi
# OPAE settings
# OPAE packages are not yet upstreamed into OS repos
# We need to download them from OPAE releases page on GitHub