Add devstack plugin
Implements: blueprint bilean-devstack Change-Id: Iad273d97806b939f7f10356eb6deae256f760cc2
This commit is contained in:
parent
2408d71cb4
commit
3274078d80
26
devstack/README.rst
Normal file
26
devstack/README.rst
Normal file
@ -0,0 +1,26 @@
|
||||
===========================
|
||||
Enabling Bilean in DevStack
|
||||
===========================
|
||||
|
||||
1. Download DevStack:
|
||||
git clone https://git.openstack.org/openstack-dev/devstack
|
||||
cd devstack
|
||||
|
||||
2. Add this repo as an external repository::
|
||||
|
||||
cat > /opt/stack/devstack/local.conf << END
|
||||
[[local|localrc]]
|
||||
enable_plugin bilean https://github.com/openstack/bilean master
|
||||
END
|
||||
|
||||
3. Add Plugin Configuration Hooks
|
||||
|
||||
Bilean service is driven using a plugin mechanism for integrating to other
|
||||
services. Each integrated service may require additional configuration
|
||||
settings. For example, typically, you will need to add the
|
||||
``billing_notifications`` notification topic to each service's configuration.
|
||||
|
||||
4. Then run devstack normally::
|
||||
|
||||
cd /opt/stack/devstack
|
||||
./stack.sh
|
176
devstack/lib/bilean
Normal file
176
devstack/lib/bilean
Normal file
@ -0,0 +1,176 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# lib/bilean
|
||||
# Functions to control the configuration and operation of the **bilean** service
|
||||
|
||||
# To enable, add the following to local.conf
|
||||
#
|
||||
# [[local|localrc]]
|
||||
# enable_plugin bilean https://git.openstack.org/openstack/bilean
|
||||
|
||||
# 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_bilean
|
||||
# - install_bileanclient
|
||||
# - configure_bilean
|
||||
# - init_bilean
|
||||
# - start_bilean
|
||||
# - stop_bilean
|
||||
# - cleanup_bilean
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
# Functions
|
||||
# ---------
|
||||
|
||||
# Test if any bilean services are enabled
|
||||
function is_bilean_enabled {
|
||||
[[ ,${ENABLED_SERVICES} =~ ,"m-" ]] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
# cleanup_bilean() - Remove residual data files, anything left over from previous
|
||||
# runs that a clean run would need to clean up
|
||||
function cleanup_bilean {
|
||||
sudo rm -rf $BILEAN_STATE_PATH $BILEAN_AUTH_CACHE_DIR
|
||||
sudo rm -rf $BILEAN_CONF_DIR
|
||||
}
|
||||
|
||||
# configure_bilean() - Set config files, create data dirs, etc
|
||||
function configure_bilean {
|
||||
# Put config files in ``/etc/bilean`` for everyone to find
|
||||
if [[ ! -d $BILEAN_CONF_DIR ]]; then
|
||||
sudo mkdir -p $BILEAN_CONF_DIR
|
||||
fi
|
||||
sudo install -d -o $STACK_USER $BILEAN_CONF_DIR
|
||||
|
||||
BILEAN_API_PASTE_FILE=$BILEAN_CONF_DIR/api-paste.ini
|
||||
BILEAN_POLICY_FILE=$BILEAN_CONF_DIR/policy.json
|
||||
BILEAN_RES_DEF_FILE=$BILEAN_CONF_DIR/resource_definitions.yaml
|
||||
|
||||
cp $BILEAN_DIR/etc/bilean/api-paste.ini $BILEAN_API_PASTE_FILE
|
||||
cp $BILEAN_DIR/etc/bilean/policy.json $BILEAN_POLICY_FILE
|
||||
cp $BILEAN_DIR/etc/bilean/resource_definitions.yaml $BILEAN_RES_DEF_FILE
|
||||
|
||||
# common options
|
||||
iniset $BILEAN_CONF DEFAULT debug "$ENABLE_DEBUG_LOG_LEVEL"
|
||||
iniset $BILEAN_CONF DEFAULT use_syslog $SYSLOG
|
||||
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
||||
# Add color to logging output
|
||||
setup_colorized_logging $BILEAN_CONF DEFAULT
|
||||
fi
|
||||
|
||||
# rpc
|
||||
iniset_rpc_backend bilean $BILEAN_CONF
|
||||
|
||||
# OpenStack API
|
||||
iniset $BILEAN_CONF bilean_api bilean_host $BILEAN_SERVICE_HOST
|
||||
iniset $BILEAN_CONF bilean_api bind_port $BILEAN_SERVICE_PORT
|
||||
|
||||
# Database connection
|
||||
iniset $BILEAN_CONF database connection `database_connection_url bilean`
|
||||
|
||||
# Keystone authtoken middleware
|
||||
#configure_auth_token_middleware $BILEAN_CONF bilean $BILEAN_AUTH_CACHE_DIR
|
||||
iniset $BILEAN_CONF keystone_authtoken identity_uri $KEYSTONE_AUTH_URI
|
||||
iniset $BILEAN_CONF keystone_authtoken cafile $SSL_BUNDLE_FILE
|
||||
iniset $BILEAN_CONF keystone_authtoken signing_dir $BILEAN_AUTH_CACHE_DIR
|
||||
iniset $BILEAN_CONF keystone_authtoken auth_uri $KEYSTONE_AUTH_URI/v3
|
||||
iniset $BILEAN_CONF keystone_authtoken admin_user bilean
|
||||
iniset $BILEAN_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
|
||||
iniset $BILEAN_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
|
||||
|
||||
# Bilean service credentials
|
||||
iniset $BILEAN_CONF authentication auth_url $KEYSTONE_AUTH_URI/v3
|
||||
iniset $BILEAN_CONF authentication service_username bilean
|
||||
iniset $BILEAN_CONF authentication service_password $SERVICE_PASSWORD
|
||||
iniset $BILEAN_CONF authentication service_project_name $SERVICE_TENANT_NAME
|
||||
}
|
||||
|
||||
# create_bilean_accounts() - Set up common required bilean accounts
|
||||
#
|
||||
# Project User Roles
|
||||
# ------------------------------------------------------------------
|
||||
# SERVICE_TENANT_NAME bilean service
|
||||
function create_bilean_accounts {
|
||||
|
||||
create_service_user "bilean" "admin"
|
||||
|
||||
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
|
||||
|
||||
local bilean_service=$(get_or_create_service "bilean" \
|
||||
"billing" "Billing Service")
|
||||
get_or_create_endpoint $bilean_service \
|
||||
"$REGION_NAME" \
|
||||
"$BILEAN_SERVICE_PROTOCOL://$BILEAN_SERVICE_HOST:$BILEAN_SERVICE_PORT/v1" \
|
||||
"$BILEAN_SERVICE_PROTOCOL://$BILEAN_SERVICE_HOST:$BILEAN_SERVICE_PORT/v1" \
|
||||
"$BILEAN_SERVICE_PROTOCOL://$BILEAN_SERVICE_HOST:$BILEAN_SERVICE_PORT/v1"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
# create_bilean_cache_dir() - Part of the init_bilean() process
|
||||
function create_bilean_cache_dir {
|
||||
# Create cache dir
|
||||
sudo mkdir -p $BILEAN_AUTH_CACHE_DIR
|
||||
sudo chown $STACK_USER $BILEAN_AUTH_CACHE_DIR
|
||||
rm -f $BILEAN_AUTH_CACHE_DIR/*
|
||||
}
|
||||
|
||||
# init_bilean() - Initialize databases, etc.
|
||||
function init_bilean {
|
||||
|
||||
# (Re)create bilean database
|
||||
recreate_database bilean
|
||||
|
||||
# Migrate bilean database
|
||||
$BILEAN_BIN_DIR/bilean-manage db_sync
|
||||
create_bilean_cache_dir
|
||||
}
|
||||
|
||||
# install_bileanclient() - Collect source and prepare
|
||||
function install_bileanclient {
|
||||
git_clone $BILEANCLIENT_REPO $BILEANCLIENT_DIR $BILEANCLIENT_BRANCH
|
||||
setup_develop $BILEANCLIENT_DIR
|
||||
}
|
||||
|
||||
# install_bilean() - Collect source and prepare
|
||||
function install_bilean {
|
||||
git_clone $BILEAN_REPO $BILEAN_DIR $BILEAN_BRANCH
|
||||
setup_develop $BILEAN_DIR
|
||||
}
|
||||
|
||||
# start_bilean() - Start running processes, including screen
|
||||
function start_bilean {
|
||||
|
||||
# ``run_process`` checks ``is_service_enabled``, it is not needed here
|
||||
run_process bl-api "$BILEAN_BIN_DIR/bilean-api --config-file=$BILEAN_CONF"
|
||||
run_process bl-eng "$BILEAN_BIN_DIR/bilean-engine --config-file=$BILEAN_CONF"
|
||||
run_process bl-sch "$BILEAN_BIN_DIR/bilean-scheduler --config-file=$BILEAN_CONF"
|
||||
run_process bl-noti "$BILEAN_BIN_DIR/bilean-notification --config-file=$BILEAN_CONF"
|
||||
}
|
||||
|
||||
# stop_bilean() - Stop running processes (non-screen)
|
||||
function stop_bilean {
|
||||
for serv in bl-api bl-eng bl-sch bl-noti; do
|
||||
stop_process $serv
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Restore xtrace
|
||||
$XTRACE
|
||||
|
||||
# Tell emacs to use shell-script-mode
|
||||
## Local variables:
|
||||
## mode: shell-script
|
||||
## End:
|
48
devstack/plugin.sh
Executable file
48
devstack/plugin.sh
Executable file
@ -0,0 +1,48 @@
|
||||
# bilean.sh - Devstack extras script to install bilean
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set -o xtrace
|
||||
|
||||
echo_summary "bilean's plugin.sh was called..."
|
||||
source $DEST/bilean/devstack/lib/bilean
|
||||
(set -o posix; set)
|
||||
|
||||
if is_service_enabled bl-api bl-eng bl-sch bl-noti; then
|
||||
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
|
||||
echo_summary "Before Installing bilean"
|
||||
mkdir -p $SCREEN_LOGDIR
|
||||
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
echo_summary "Installing bilean"
|
||||
install_bilean
|
||||
echo_summary "Installing bileanclient"
|
||||
install_bileanclient
|
||||
cleanup_bilean
|
||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||
echo_summary "Configuring bilean"
|
||||
configure_bilean
|
||||
|
||||
if is_service_enabled key; then
|
||||
create_bilean_accounts
|
||||
fi
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
|
||||
# Initialize bilean
|
||||
init_bilean
|
||||
|
||||
# Start the bilean API and bilean taskmgr components
|
||||
echo_summary "Starting bilean"
|
||||
start_bilean
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
stop_bilean
|
||||
fi
|
||||
|
||||
if [[ "$1" == "clean" ]]; then
|
||||
cleanup_bilean
|
||||
fi
|
||||
fi
|
||||
|
||||
# Restore xtrace
|
||||
$XTRACE
|
41
devstack/settings
Normal file
41
devstack/settings
Normal file
@ -0,0 +1,41 @@
|
||||
# Turn on all bilean services by default
|
||||
# API service
|
||||
enable_service bl-api
|
||||
# Engine
|
||||
enable_service bl-eng
|
||||
# Scheduler service
|
||||
enable_service bl-sch
|
||||
# Notification service
|
||||
enable_service bl-noti
|
||||
|
||||
# Set up default directories
|
||||
BILEAN_REPO=${BILEAN_REPO:-${GIT_BASE}/openstack/bilean.git}
|
||||
BILEAN_BRANCH=${BILEAN_BRANCH:-master}
|
||||
BILEAN_DIR=$DEST/bilean
|
||||
|
||||
BILEANCLIENT_REPO=${BILEANCLIENT_REPO:-${GIT_BASE}/openstack/python-bileanclient.git}
|
||||
BILEANCLIENT_BRANCH=${BILEANCLIENT_BRANCH:-master}
|
||||
BILEANCLIENT_DIR=$DEST/python-bileanclient
|
||||
|
||||
BILEAN_STATE_PATH=${BILEAN_STATE_PATH:=$DATA_DIR/bilean}
|
||||
BILEAN_AUTH_CACHE_DIR=${BILEAN_AUTH_CACHE_DIR:-/var/cache/bilean}
|
||||
|
||||
BILEAN_CONF_DIR=/etc/bilean
|
||||
BILEAN_CONF=$BILEAN_CONF_DIR/bilean.conf
|
||||
BILEAN_POLICY_JSON=$BILEAN_CONF_DIR/policy.json
|
||||
|
||||
# Public facing bits
|
||||
BILEAN_SERVICE_HOST=${BILEAN_SERVICE_HOST:-$SERVICE_HOST}
|
||||
BILEAN_SERVICE_PORT=${BILEAN_SERVICE_PORT:-8770}
|
||||
BILEAN_SERVICE_PROTOCOL=http
|
||||
|
||||
# Support entry points installation of console scripts
|
||||
if [[ -d $BILEAN_DIR/bin ]]; then
|
||||
BILEAN_BIN_DIR=$BILEAN_DIR/bin
|
||||
else
|
||||
BILEAN_BIN_DIR=$(get_python_exec_prefix)
|
||||
fi
|
||||
|
||||
# Log all output to files
|
||||
LOGFILE=$HOME/devstack.log
|
||||
SCREEN_LOGDIR=$HOME/logs
|
Loading…
Reference in New Issue
Block a user