
Service name in Openstack is in lower case. So we should also do it the same way. Change-Id: I78ec92c031e8731d9c37fa0bdd70ccaba82427d7
269 lines
8.8 KiB
Bash
269 lines
8.8 KiB
Bash
#!/bin/bash
|
|
#
|
|
# lib/higgins
|
|
# Functions to control the configuration and operation of the **higgins** service
|
|
|
|
# Dependencies:
|
|
#
|
|
# - ``functions`` file
|
|
# - ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
|
|
# - ``SERVICE_{TENANT_NAME|PASSWORD}`` must be defined
|
|
|
|
# ``stack.sh`` calls the entry points in this order:
|
|
#
|
|
# - install_higgins
|
|
# - configure_higgins
|
|
# - create_higgins_conf
|
|
# - create_higgins_accounts
|
|
# - init_higgins
|
|
# - start_higgins
|
|
# - stop_higgins
|
|
# - cleanup_higgins
|
|
|
|
# Save trace setting
|
|
XTRACE=$(set +o | grep xtrace)
|
|
set +o xtrace
|
|
|
|
|
|
# Defaults
|
|
# --------
|
|
|
|
# Set up default directories
|
|
HIGGINS_REPO=${HIGGINS_REPO:-${GIT_BASE}/openstack/higgins.git}
|
|
HIGGINS_BRANCH=${HIGGINS_BRANCH:-master}
|
|
HIGGINS_DIR=$DEST/higgins
|
|
|
|
HIGGINS_STATE_PATH=${HIGGINS_STATE_PATH:=$DATA_DIR/higgins}
|
|
HIGGINS_AUTH_CACHE_DIR=${HIGGINS_AUTH_CACHE_DIR:-/var/cache/higgins}
|
|
|
|
HIGGINS_CONF_DIR=/etc/higgins
|
|
HIGGINS_CONF=$HIGGINS_CONF_DIR/higgins.conf
|
|
HIGGINS_POLICY_JSON=$HIGGINS_CONF_DIR/policy.json
|
|
HIGGINS_API_PASTE=$HIGGINS_CONF_DIR/api-paste.ini
|
|
|
|
if is_ssl_enabled_service "higgins" || is_service_enabled tls-proxy; then
|
|
HIGGINS_SERVICE_PROTOCOL="https"
|
|
fi
|
|
|
|
# Public facing bits
|
|
HIGGINS_SERVICE_HOST=${HIGGINS_SERVICE_HOST:-$HOST_IP}
|
|
HIGGINS_SERVICE_PORT=${HIGGINS_SERVICE_PORT:-9517}
|
|
HIGGINS_SERVICE_PORT_INT=${HIGGINS_SERVICE_PORT_INT:-19517}
|
|
HIGGINS_SERVICE_PROTOCOL=${HIGGINS_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
|
|
|
|
HIGGINS_TRUSTEE_DOMAIN_ADMIN_PASSWORD=${HIGGINS_TRUSTEE_DOMAIN_ADMIN_PASSWORD:-secret}
|
|
|
|
# Support entry points installation of console scripts
|
|
if [[ -d $HIGGINS_DIR/bin ]]; then
|
|
HIGGINS_BIN_DIR=$HIGGINS_DIR/bin
|
|
else
|
|
HIGGINS_BIN_DIR=$(get_python_exec_prefix)
|
|
fi
|
|
|
|
# Functions
|
|
# ---------
|
|
|
|
# Test if any higgins services are enabled
|
|
# is_higgins_enabled
|
|
function is_higgins_enabled {
|
|
[[ ,${ENABLED_SERVICES} =~ ,"higgins-" ]] && return 0
|
|
return 1
|
|
}
|
|
# cleanup_higgins() - Remove residual data files, anything left over from previous
|
|
# runs that a clean run would need to clean up
|
|
function cleanup_higgins {
|
|
sudo rm -rf $HIGGINS_STATE_PATH $HIGGINS_AUTH_CACHE_DIR
|
|
}
|
|
|
|
# configure_higgins() - Set config files, create data dirs, etc
|
|
function configure_higgins {
|
|
# Put config files in ``/etc/higgins`` for everyone to find
|
|
if [[ ! -d $HIGGINS_CONF_DIR ]]; then
|
|
sudo mkdir -p $HIGGINS_CONF_DIR
|
|
sudo chown $STACK_USER $HIGGINS_CONF_DIR
|
|
fi
|
|
|
|
install_default_policy higgins
|
|
# Rebuild the config file from scratch
|
|
create_higgins_conf
|
|
|
|
create_api_paste_conf
|
|
|
|
}
|
|
|
|
# create_higgins_accounts() - Set up common required HIGGINS accounts
|
|
#
|
|
# Project User Roles
|
|
# ------------------------------------------------------------------
|
|
# SERVICE_PROJECT_NAME higgins service
|
|
function create_higgins_accounts {
|
|
|
|
create_service_user "higgins" "admin"
|
|
|
|
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
|
|
|
|
local higgins_service=$(get_or_create_service "higgins" \
|
|
"container" "Container As Service")
|
|
get_or_create_endpoint $higgins_service \
|
|
"$REGION_NAME" \
|
|
"$HIGGINS_SERVICE_PROTOCOL://$HIGGINS_SERVICE_HOST:$HIGGINS_SERVICE_PORT/v1" \
|
|
"$HIGGINS_SERVICE_PROTOCOL://$HIGGINS_SERVICE_HOST:$HIGGINS_SERVICE_PORT/v1" \
|
|
"$HIGGINS_SERVICE_PROTOCOL://$HIGGINS_SERVICE_HOST:$HIGGINS_SERVICE_PORT/v1"
|
|
fi
|
|
|
|
}
|
|
|
|
# create_higgins_conf() - Create a new higgins.conf file
|
|
function create_higgins_conf {
|
|
|
|
# (Re)create ``higgins.conf``
|
|
rm -f $HIGGINS_CONF
|
|
iniset $HIGGINS_CONF DEFAULT debug "$ENABLE_DEBUG_LOG_LEVEL"
|
|
iniset $HIGGINS_CONF oslo_messaging_rabbit rabbit_userid $RABBIT_USERID
|
|
iniset $HIGGINS_CONF oslo_messaging_rabbit rabbit_password $RABBIT_PASSWORD
|
|
iniset $HIGGINS_CONF oslo_messaging_rabbit rabbit_host $RABBIT_HOST
|
|
|
|
iniset $HIGGINS_CONF database connection `database_connection_url higgins`
|
|
iniset $HIGGINS_CONF api host "$HIGGINS_SERVICE_HOST"
|
|
iniset $HIGGINS_CONF api port "$HIGGINS_SERVICE_PORT"
|
|
|
|
iniset $HIGGINS_CONF oslo_policy policy_file $HIGGINS_POLICY_JSON
|
|
|
|
iniset $HIGGINS_CONF keystone_auth auth_type password
|
|
iniset $HIGGINS_CONF keystone_auth username higgins
|
|
iniset $HIGGINS_CONF keystone_auth password $SERVICE_PASSWORD
|
|
iniset $HIGGINS_CONF keystone_auth project_name $SERVICE_PROJECT_NAME
|
|
iniset $HIGGINS_CONF keystone_auth project_domain_id default
|
|
iniset $HIGGINS_CONF keystone_auth user_domain_id default
|
|
|
|
# FIXME(pauloewerton): keystone_authtoken section is deprecated. Remove it
|
|
# after deprecation period.
|
|
iniset $HIGGINS_CONF keystone_authtoken admin_user higgins
|
|
iniset $HIGGINS_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
|
|
iniset $HIGGINS_CONF keystone_authtoken admin_tenant_name $SERVICE_PROJECT_NAME
|
|
|
|
configure_auth_token_middleware $HIGGINS_CONF higgins $HIGGINS_AUTH_CACHE_DIR
|
|
|
|
iniset $HIGGINS_CONF keystone_auth auth_url $KEYSTONE_SERVICE_URI/v3
|
|
iniset $HIGGINS_CONF keystone_authtoken auth_uri \
|
|
${KEYSTONE_SERVICE_PROTOCOL}://${HOST_IP}:${KEYSTONE_SERVICE_PORT}/v3
|
|
iniset $HIGGINS_CONF keystone_authtoken auth_version v3
|
|
|
|
if is_fedora || is_suse; then
|
|
# higgins defaults to /usr/local/bin, but fedora and suse pip like to
|
|
# install things in /usr/bin
|
|
iniset $HIGGINS_CONF DEFAULT bindir "/usr/bin"
|
|
fi
|
|
|
|
if [ -n "$HIGGINS_STATE_PATH" ]; then
|
|
iniset $HIGGINS_CONF DEFAULT state_path "$HIGGINS_STATE_PATH"
|
|
iniset $HIGGINS_CONF oslo_concurrency lock_path "$HIGGINS_STATE_PATH"
|
|
fi
|
|
|
|
if [ "$SYSLOG" != "False" ]; then
|
|
iniset $HIGGINS_CONF DEFAULT use_syslog "True"
|
|
fi
|
|
|
|
# Format logging
|
|
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
|
setup_colorized_logging $HIGGINS_CONF DEFAULT
|
|
else
|
|
# Show user_name and project_name instead of user_id and project_id
|
|
iniset $HIGGINS_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
|
|
fi
|
|
|
|
# Register SSL certificates if provided
|
|
if is_ssl_enabled_service higgins; then
|
|
ensure_certificates higgins
|
|
|
|
iniset $HIGGINS_CONF DEFAULT ssl_cert_file "$HIGGINS_SSL_CERT"
|
|
iniset $HIGGINS_CONF DEFAULT ssl_key_file "$HIGGINS_SSL_KEY"
|
|
|
|
iniset $HIGGINS_CONF DEFAULT enabled_ssl_apis "$HIGGINS_ENABLED_APIS"
|
|
fi
|
|
}
|
|
|
|
function create_api_paste_conf {
|
|
# copy api_paste.ini
|
|
cp $HIGGINS_DIR/etc/higgins/api-paste.ini $HIGGINS_API_PASTE
|
|
}
|
|
|
|
# create_higgins_cache_dir() - Part of the init_HIGGINS() process
|
|
function create_higgins_cache_dir {
|
|
# Create cache dir
|
|
sudo mkdir -p $HIGGINS_AUTH_CACHE_DIR
|
|
sudo chown $STACK_USER $HIGGINS_AUTH_CACHE_DIR
|
|
rm -f $HIGGINS_AUTH_CACHE_DIR/*
|
|
}
|
|
|
|
|
|
# init_higgins() - Initialize databases, etc.
|
|
function init_higgins {
|
|
# Only do this step once on the API node for an entire cluster.
|
|
if is_service_enabled $DATABASE_BACKENDS && is_service_enabled higgins-api; then
|
|
# (Re)create higgins database
|
|
recreate_database higgins
|
|
|
|
# Migrate higgins database
|
|
# $HIGGINS_BIN_DIR/higgins-db-manage upgrade
|
|
fi
|
|
create_higgins_cache_dir
|
|
}
|
|
|
|
# install_higginsclient() - Collect source and prepare
|
|
function install_higginsclient {
|
|
if use_library_from_git "python-higginsclient"; then
|
|
echo "we don't have CLI yet.."
|
|
#git_clone_by_name "python-higginsclient"
|
|
#setup_dev_lib "python-higginsclient"
|
|
fi
|
|
}
|
|
|
|
# install_higgins() - Collect source and prepare
|
|
function install_higgins {
|
|
git_clone $HIGGINS_REPO $HIGGINS_DIR $HIGGINS_BRANCH
|
|
setup_develop $HIGGINS_DIR
|
|
}
|
|
|
|
# start_higgins_api() - Start the API process ahead of other things
|
|
function start_higgins_api {
|
|
# Get right service port for testing
|
|
local service_port=$HIGGINS_SERVICE_PORT
|
|
local service_protocol=$HIGGINS_SERVICE_PROTOCOL
|
|
if is_service_enabled tls-proxy; then
|
|
service_port=$HIGGINS_SERVICE_PORT_INT
|
|
service_protocol="http"
|
|
fi
|
|
|
|
run_process higgins-api "$HIGGINS_BIN_DIR/higgins-api"
|
|
echo "Waiting for higgins-api to start..."
|
|
if ! wait_for_service $SERVICE_TIMEOUT $service_protocol://$HIGGINS_SERVICE_HOST:$service_port; then
|
|
die $LINENO "higgins-api did not start"
|
|
fi
|
|
|
|
# Start proxies if enabled
|
|
if is_service_enabled tls-proxy; then
|
|
start_tls_proxy '*' $HIGGINS_SERVICE_PORT $HIGGINS_SERVICE_HOST $HIGGINS_SERVICE_PORT_INT &
|
|
fi
|
|
}
|
|
|
|
|
|
# start_higgins() - Start running processes, including screen
|
|
function start_higgins {
|
|
|
|
# ``run_process`` checks ``is_service_enabled``, it is not needed here
|
|
start_higgins_api
|
|
run_process higgins-conductor "$HIGGINS_BIN_DIR/higgins-conductor"
|
|
}
|
|
|
|
# stop_higgins() - Stop running processes (non-screen)
|
|
function stop_higgins {
|
|
for serv in higgins-api higgins-conductor; do
|
|
stop_process $serv
|
|
done
|
|
}
|
|
|
|
|
|
# Restore xtrace
|
|
$XTRACE
|