add devstack plugin for nimble

Change-Id: I45736f20848bb2bb37ecae4fbb272185c8cf553c
This commit is contained in:
shihanzhang 2016-09-14 16:01:26 +08:00
parent 312b5ad64c
commit 7ab4cff418
4 changed files with 267 additions and 0 deletions

16
devstack/README.rst Normal file
View File

@ -0,0 +1,16 @@
====================
Enabling in Devstack
====================
1. Download DevStack::
git clone https://git.openstack.org/openstack-dev/devstack.git
cd devstack
2. Add this repo as an external repository::
> cat local.conf
[[local|localrc]]
enable_plugin nimble https://git.openstack.org/openstack/nimble
3. run ``stack.sh``

219
devstack/plugin.sh Normal file
View File

@ -0,0 +1,219 @@
# ``stack.sh`` calls the entry points in this order:
#
# install_nimble
# install_python_nimbleclient
# configure_nimble
# start_nimble
# stop_nimble
# cleanup_nimble
# Save trace setting
XTRACE=$(set +o | grep xtrace)
set -o xtrace
# Defaults
# --------
# Support entry points installation of console scripts
if [[ -d ${NIMBLE_DIR}/bin ]]; then
NIMBLE_BIN_DIR=${NIMBLE_DIR}/bin
else
NIMBLE_BIN_DIR=$(get_python_exec_prefix)
fi
# create_nimble_accounts - Set up common required nimble accounts
#
# Tenant User Roles
# ------------------------------
# service nimble admin
function create_nimble_accounts {
create_service_user "nimble" "admin"
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
get_or_create_service "nimble" "baremetal_compute" "Baremetal Compute"
get_or_create_endpoint "baremetal_compute" \
"$REGION_NAME" \
"${NIMBLE_SERVICE_PROTOCOL}://${NIMBLE_SERVICE_HOST}:${NIMBLE_SERVICE_PORT}/v1" \
"${NIMBLE_SERVICE_PROTOCOL}://${NIMBLE_SERVICE_HOST}:${NIMBLE_SERVICE_PORT}/v1" \
"${NIMBLE_SERVICE_PROTOCOL}://${NIMBLE_SERVICE_HOST}:${NIMBLE_SERVICE_PORT}/v1"
fi
}
function mkdir_chown_stack {
if [[ ! -d "$1" ]]; then
sudo mkdir -p "$1"
fi
sudo chown $STACK_USER "$1"
}
# Entry points
# ------------
# configure_nimble - Set config files, create data dirs, etc
function configure_nimble {
mkdir_chown_stack "${NIMBLE_CONF_DIR}"
# Generate Nimble configuration file and configure common parameters.
oslo-config-generator --config-file ${NIMBLE_DIR}/tools/config/nimble-config-generator.conf --output-file ${NIMBLE_CONF_FILE}
iniset ${NIMBLE_CONF_FILE} DEFAULT debug ${NIMBLE_DEBUG}
NIMBLE_POLICY_FILE=${NIMBLE_CONF_DIR}/policy.json
cp ${NIMBLE_DIR}/etc/policy.json ${NIMBLE_POLICY_FILE}
# Nimble Configuration
#-------------------------
# Setup keystone_authtoken section
iniset ${NIMBLE_CONF_FILE} keystone_authtoken auth_uri ${KEYSTONE_SERVICE_URI}
iniset ${NIMBLE_CONF_FILE} keystone_authtoken project_domain_name ${SERVICE_DOMAIN_NAME}
iniset ${NIMBLE_CONF_FILE} keystone_authtoken project_name ${SERVICE_TENANT_NAME}
iniset ${NIMBLE_CONF_FILE} keystone_authtoken user_domain_name ${SERVICE_DOMAIN_NAME}
iniset ${NIMBLE_CONF_FILE} keystone_authtoken username ${NIMBLE_ADMIN_USER}
iniset ${NIMBLE_CONF_FILE} keystone_authtoken password ${SERVICE_PASSWORD}
iniset ${NIMBLE_CONF_FILE} keystone_authtoken auth_url ${KEYSTONE_AUTH_URI}
iniset ${NIMBLE_CONF_FILE} keystone_authtoken auth_type "password"
# Setup RabbitMQ credentials
iniset ${NIMBLE_CONF_FILE} oslo_messaging_rabbit rabbit_userid ${RABBIT_USERID}
iniset ${NIMBLE_CONF_FILE} oslo_messaging_rabbit rabbit_password ${RABBIT_PASSWORD}
# Configure the database.
iniset ${NIMBLE_CONF_FILE} database connection `database_connection_url nimble`
# Setup ironic section
iniset ${NIMBLE_CONF_FILE} ironic admin_tenant_name ${SERVICE_TENANT_NAME}
iniset ${NIMBLE_CONF_FILE} ironic admin_username "ironic"
iniset ${NIMBLE_CONF_FILE} ironic admin_password ${SERVICE_PASSWORD}
iniset ${NIMBLE_CONF_FILE} ironic admin_url "${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_AUTH_HOST}:${KEYSTONE_SERVICE_PORT}/v2.0"
iniset ${NIMBLE_CONF_FILE} ironic api_endpoint "${KEYSTONE_AUTH_PROTOCOL}://${SERVICE_HOST}:${IRONIC_SERVICE_PORT}"
# Setup neutron section
iniset ${NIMBLE_CONF_FILE} neutron url "${NIMBLE_SERVICE_PROTOCOL}://${SERVICE_HOST}:${NEUTRON_SERVICE_PORT}"
# Setup keystone section
iniset ${NIMBLE_CONF_FILE} keystone region_name ${REGION_NAME}
# Path of policy.json file.
iniset ${NIMBLE_CONF} oslo_policy policy_file ${NIMBLE_POLICY_FILE}
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
setup_colorized_logging ${NIMBLE_CONF_FILE} DEFAULT tenant user
fi
}
# init_nimble - Initialize the database
function init_nimble {
# (re)create Nimble database
recreate_database nimble utf8
${NIMBLE_BIN_DIR}/nimble-dbsync --config-file ${NIMBLE_CONF_FILE} upgrade
}
# install_nimble - Collect source and prepare
function install_nimble {
# make sure all needed service were enabled
local req_services="key glance neutron ironic"
for srv in $req_services; do
if ! is_service_enabled "$srv"; then
die $LINENO "$srv should be enabled for Nimble."
fi
done
setup_develop ${NIMBLE_DIR}
if is_service_enabled horizon; then
_install_nimble_dashboard
fi
}
function _install_nimble_dashboard {
# add it when nimble dashboard is ready
:
#git_clone ${NIMBLE_DASHBOARD_REPO} ${NIMBLE_DASHBOARD_DIR} ${NIMBLE_DASHBOARD_BRANCH}
#setup_develop ${NIMBLE_DASHBOARD_DIR}
# add it when nimble dashboard is ready
#ln -fs ${NIMBLE_DASHBOARD_DIR}/_xx_nimble.py.example ${HORIZON_DIR}/openstack_dashboard/local/enabled/_xx_nimble.py
}
function install_nimble_pythonclient {
if use_library_from_git "python-nimbleclient"; then
# add it when nimble nimble-pythonclient is ready
:
#git_clone ${NIMBLE_PYTHONCLIENT_REPO} ${NIMBLE_PYTHONCLIENT_DIR} ${NIMBLE_PYTHONCLIENT_BRANCH}
#setup_develop ${NIMBLE_PYTHONCLIENT_DIR}
fi
}
# start_nimble - Start running processes, including screen
function start_nimble {
if is_service_enabled nimble-api && is_service_enabled nimble-engine ; then
echo_summary "Installing all nimble services in separate processes"
run_process nimble-api "${NIMBLE_BIN_DIR}/nimble-api --config-file ${NIMBLE_CONF_DIR}/nimble.conf"
if ! wait_for_service ${SERVICE_TIMEOUT} ${NIMBLE_SERVICE_PROTOCOL}://${NIMBLE_SERVICE_HOST}:${NIMBLE_SERVICE_PORT}; then
die $LINENO "nimble-api did not start"
fi
run_process nimble-engine "${NIMBLE_BIN_DIR}/nimble-engine --config-file ${NIMBLE_CONF_DIR}/nimble.conf"
fi
}
# stop_nimble - Stop running processes
function stop_nimble {
# Kill the Nimble screen windows
for serv in nimble-api nimble-engine; do
stop_process $serv
done
}
function cleanup_nimble {
if is_service_enabled horizon; then
_nimble_cleanup_nimble_dashboard
fi
}
function _nimble_cleanup_nimble_dashboard {
rm -f ${HORIZON_DIR}/openstack_dashboard/local/enabled/_xx_nimble.py
}
if is_service_enabled nimble; then
if [[ "$1" == "stack" && "$2" == "install" ]]; then
echo_summary "Installing nimble"
install_nimble
install_nimble_pythonclient
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
echo_summary "Configuring nimble"
configure_nimble
create_nimble_accounts
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
echo_summary "Initializing nimble"
init_nimble
start_nimble
fi
if [[ "$1" == "unstack" ]]; then
echo_summary "Shutting down nimble"
stop_nimble
fi
if [[ "$1" == "clean" ]]; then
echo_summary "Cleaning nimble"
#add it when nimble dashboard
#cleanup_nimble
fi
fi
# Restore xtrace
$XTRACE
# Local variables:
# mode: shell-script
# End:

29
devstack/settings Normal file
View File

@ -0,0 +1,29 @@
# Devstack settings
# We have to add Nimble to enabled services for run_process to work
# Now we just support to run services in separate processes and screens:
# enable_service nimble nimble-api nimble-engine
enable_service nimble nimble-api nimble-engine
# Set up default repos
NIMBLE_REPO=${NIMBLE_REPO:-${GIT_BASE}/openstack/nimble.git}
NIMBLE_BRANCH=${NIMBLE_BRANCH:-master}
#NIMBLE_DASHBOARD_REPO=${NIMBLE_DASHBOARD_REPO:-${GIT_BASE}/openstack/nimble-dashboard.git}
#NIMBLE_DASHBOARD_BRANCH=${NIMBLE_DASHBOARD_BRANCH:-${NIMBLE_BRANCH}}
#NIMBLE_PYTHONCLIENT_REPO=${NIMBLE_PYTHONCLIENT_REPO:-${GIT_BASE}/openstack/python-nimbleclient.git}
#NIMBLE_PYTHONCLIENT_BRANCH=${NIMBLE_PYTHONCLIENT_BRANCH:-master}
#NIMBLE_PYTHONCLIENT_DIR=$DEST/python-nimbleclient
# Set up default directories
NIMBLE_DIR=$DEST/nimble
NIMBLE_DASHBOARD_DIR=$DEST/nimble-dashboard
NIMBLE_CONF_DIR=${NIMBLE_CONF_DIR:-/etc/nimble}
NIMBLE_CONF_FILE=${NIMBLE_CONF_DIR}/nimble.conf
NIMBLE_DEBUG=${NIMBLE_DEBUG:-True}
NIMBLE_SERVICE_HOST=${NIMBLE_SERVICE_HOST:-$SERVICE_HOST}
NIMBLE_SERVICE_PORT=${NIMBLE_SERVICE_PORT:-6688}
NIMBLE_SERVICE_PROTOCOL=${NIMBLE_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
NIMBLE_ADMIN_USER=${NIMBLE_ADMIN_USER:-nimble}

3
etc/policy.json Normal file
View File

@ -0,0 +1,3 @@
{
}