DevStack cleanups

* Pull binary build steps into separate functions
* Add build.sh to call binary builds without the rest of DevStack
* Add new stx-fault-build job and tox build environment
* Make stx-fault-devstack voting (still only devstack/*)

Change-Id: I6692fc1f75db413860ede2657f4f1501b95c10c0
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
This commit is contained in:
Dean Troyer 2018-12-06 17:46:10 -06:00
parent 579ac41e6a
commit 68c99f6f66
6 changed files with 147 additions and 49 deletions

View File

@ -5,24 +5,37 @@
- build-openstack-docs-pti - build-openstack-docs-pti
check: check:
jobs: jobs:
- stx-devstack-fault:
voting: false
- build-openstack-api-ref - build-openstack-api-ref
- build-openstack-releasenotes - build-openstack-releasenotes
- openstack-tox-linters - openstack-tox-linters
- openstack-tox-pep8 - openstack-tox-pep8
- stx-fault-build
- stx-fault-devstack
gate: gate:
jobs: jobs:
- build-openstack-api-ref - build-openstack-api-ref
- build-openstack-releasenotes - build-openstack-releasenotes
- openstack-tox-linters - openstack-tox-linters
- openstack-tox-pep8 - openstack-tox-pep8
- stx-fault-devstack
post: post:
jobs: jobs:
- publish-stx-api-ref - publish-stx-api-ref
- publish-stx-tox - publish-stx-tox
- publish-stx-releasenotes - publish-stx-releasenotes
# Perform just a build
- job:
name: stx-fault-build
parent: tox
description: Run build for fault
irrelevant-files:
- api-ref/*
- docs/*
- releasenotes/*
vars:
tox_envlist: build
# This job is to begin testing a DevStack run here # This job is to begin testing a DevStack run here
- job: - job:
name: stx-devstack-base name: stx-devstack-base
@ -72,7 +85,7 @@
FORCE: yes FORCE: yes
- job: - job:
name: stx-devstack-fault name: stx-fault-devstack
parent: stx-devstack-base parent: stx-devstack-base
timeout: 7800 timeout: 7800
required-projects: required-projects:

35
devstack/build.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
# devstack/build.sh
# Run DevStack plugin builds
set -o xtrace
unset LANG
unset LANGUAGE
LC_ALL=en_US.utf8
export LC_ALL
# Keep track of the DevStack plugin directory
PLUGIN_DIR=$(cd $(dirname "$0")/.. && pwd)
PLUGIN_NAME=$(basename $PLUGIN_DIR)
# Keep plugin happy
declare -a GITDIR
GITDIR[$PLUGIN_NAME]=$PLUGIN_DIR
# Dummy function to keep plugin happy
function get_python_exec_prefix {
echo ""
}
function is_service_enabled {
return 0
}
# Get the build functions
source $PLUGIN_DIR/devstack/lib/stx-fault
# Call builds
build_fm_common
build_fm_mgr

View File

@ -5,9 +5,6 @@
# Dependencies: # Dependencies:
# #
# - ``functions`` file
# - ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
# - The stx-update plugin must be enabled # - The stx-update plugin must be enabled
# ``stack.sh`` calls the entry points in this order: # ``stack.sh`` calls the entry points in this order:
@ -26,13 +23,13 @@ set -o xtrace
# Defaults # Defaults
# -------- # --------
FAULT_DIR=${GITDIR[$STX_FAULT_NAME]} STX_FAULT_DIR=${GITDIR[$STX_FAULT_NAME]}
FAULT_CONF_DIR=/etc/fm STX_FAULT_CONF_DIR=/etc/fm
FM_RESTAPI_CONF=$FAULT_CONF_DIR/fm.conf FM_RESTAPI_CONF=$STX_FAULT_CONF_DIR/fm.conf
FM_RESTAPI_PASTE_INI=$FAULT_CONF_DIR/api-paste.ini FM_RESTAPI_PASTE_INI=$STX_FAULT_CONF_DIR/api-paste.ini
FM_RESTAPI_AUTH_CACHE_DIR=${FM_RESTAPI_AUTH_CACHE_DIR:-/var/cache/fault} FM_RESTAPI_AUTH_CACHE_DIR=${FM_RESTAPI_AUTH_CACHE_DIR:-/var/cache/fault}
FM_RESTAPI_DIR=${GITDIR[$STX_FAULT_NAME]}/fm-rest-api/fm FM_RESTAPI_DIR=$STX_FAULT_DIR/fm-rest-api/fm
if is_service_enabled tls-proxy; then if is_service_enabled tls-proxy; then
@ -49,6 +46,51 @@ PYTHON_SITE_DIR=$(python -c "from distutils.sysconfig import get_python_lib; pri
# Functions # Functions
# --------- # ---------
function build_fm_common {
pushd $STX_FAULT_DIR/fm-common/sources
local major minor version x
if [[ -z $1 || -z $2 ]]; then
# get fm-common version
read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-common/PKG-INFO)
major=${version%%.*}
minor=${version##*.}
else
major=$1
minor=$2
fi
# build
make MAJOR=$major MINOR=$minor
python setup.py build
popd
}
function build_fm_mgr {
pushd $STX_FAULT_DIR/fm-mgr/sources
local x version
local major minor version x
if [[ -z $1 || -z $2 ]]; then
# get fm-mgr version
read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-mgr/PKG-INFO)
local major=${version%%.*}
local minor=${version##*.}
else
major=$1
minor=$2
fi
# build
make MAJOR=$major MINOR=$minor
popd
}
function cleanup_fault { function cleanup_fault {
stop_fault stop_fault
@ -67,14 +109,14 @@ function cleanup_fm_common {
local x version local x version
# get fm-common version # get fm-common version
read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-common/PKG-INFO) read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-common/PKG-INFO)
local major=${version%%.*} local major=${version%%.*}
local minor=${version##*.} local minor=${version##*.}
local prefix=${STX_BIN_DIR%/*} local prefix=${STX_BIN_DIR%/*}
sudo rm /etc/ld.so.conf.d/stx-fault.conf sudo rm /etc/ld.so.conf.d/stx-fault.conf
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-common/sources pushd $STX_FAULT_DIR/fm-common/sources
sudo make \ sudo make \
DEST_DIR=$prefix \ DEST_DIR=$prefix \
@ -96,11 +138,11 @@ function cleanup_fm_mgr {
local x version local x version
# get fm-mgr version # get fm-mgr version
read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/PKG-INFO) read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-mgr/PKG-INFO)
local major=${version%%.*} local major=${version%%.*}
local minor=${version##*.} local minor=${version##*.}
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/sources pushd $STX_FAULT_DIR/fm-mgr/sources
sudo make \ sudo make \
BIN_DIR=/bin \ BIN_DIR=/bin \
@ -120,13 +162,15 @@ function cleanup_fm_rest_api {
function configure_fault { function configure_fault {
if is_service_enabled fm-rest-api; then if is_service_enabled fm-rest-api; then
configure_fm_rest_api configure_fm_rest_api
create_fault_user_group
create_fault_accounts
fi fi
} }
function configure_fm_rest_api { function configure_fm_rest_api {
sudo install -d -o $STACK_USER -m 755 $FAULT_CONF_DIR sudo install -d -o $STACK_USER -m 755 $STX_FAULT_CONF_DIR
cp -p $FAULT_DIR/devstack/files/api-paste.ini $FM_RESTAPI_PASTE_INI cp -p $STX_FAULT_DIR/devstack/files/api-paste.ini $FM_RESTAPI_PASTE_INI
configure_auth_token_middleware $FM_RESTAPI_CONF fm $FM_RESTAPI_AUTH_CACHE_DIR configure_auth_token_middleware $FM_RESTAPI_CONF fm $FM_RESTAPI_AUTH_CACHE_DIR
@ -159,14 +203,12 @@ function configure_fm_rest_api {
} }
function create_fault_accounts { function create_fault_accounts {
if [[ "$ENABLED_SERVICES" =~ "fm-rest-api" ]]; then create_service_user "fm"
create_service_user "fm" get_or_create_service "fm" "faultmanagement" "Fault Management Service"
get_or_create_service "fm" "faultmanagement" "Fault Management Service" get_or_create_endpoint \
get_or_create_endpoint \ "faultmanagement" \
"faultmanagement" \ "$REGION_NAME" \
"$REGION_NAME" \ "$FM_RESTAPI_SERVICE_PROTOCOL://$FM_RESTAPI_SERVICE_HOST:$FM_RESTAPI_SERVICE_PORT/v1"
"$FM_RESTAPI_SERVICE_PROTOCOL://$FM_RESTAPI_SERVICE_HOST:$FM_RESTAPI_SERVICE_PORT/v1"
fi
} }
function create_fault_cache_dir { function create_fault_cache_dir {
@ -186,10 +228,9 @@ function init_fault {
function install_fault { function install_fault {
if is_service_enabled fm-common; then if is_service_enabled fm-common; then
install_fm_common install_fm_common
install_fm_client
fi fi
if is_service_enabled fm-api; then if is_service_enabled fm-client || is_service_enabled fm-common; then
install_fm_api install_fm_client
fi fi
if is_service_enabled fm-api; then if is_service_enabled fm-api; then
install_fm_api install_fm_api
@ -203,7 +244,7 @@ function install_fault {
} }
function install_fm_api { function install_fm_api {
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-api pushd $STX_FAULT_DIR/fm-api
sudo python setup.py install \ sudo python setup.py install \
--root=/ \ --root=/ \
--install-lib=$PYTHON_SITE_DIR \ --install-lib=$PYTHON_SITE_DIR \
@ -214,7 +255,7 @@ function install_fm_api {
} }
function install_fm_client { function install_fm_client {
pushd ${GITDIR[$STX_FAULT_NAME]}/python-fmclient/fmclient pushd $STX_FAULT_DIR/python-fmclient/fmclient
sudo python setup.py install \ sudo python setup.py install \
--root=/ \ --root=/ \
--install-lib=$PYTHON_SITE_DIR \ --install-lib=$PYTHON_SITE_DIR \
@ -225,22 +266,21 @@ function install_fm_client {
} }
function install_fm_common { function install_fm_common {
local x version pushd $STX_FAULT_DIR/fm-common/sources
local major minor version x
# get fm-common version # get fm-common version
read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-common/PKG-INFO) read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-common/PKG-INFO)
local major=${version%%.*} major=${version%%.*}
local minor=${version##*.} minor=${version##*.}
build_fm_common $major $minor
# Set up the destinations # Set up the destinations
# Making an assumption here about STX_BIN_DIR having ../include be valid # Making an assumption here about STX_BIN_DIR having ../include be valid
local prefix=${STX_BIN_DIR%/*} local prefix=${STX_BIN_DIR%/*}
# build
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-common/sources
make MAJOR=$major MINOR=$minor
sudo python setup.py build
# install # install
sudo make \ sudo make \
DEST_DIR=$prefix \ DEST_DIR=$prefix \
@ -273,16 +313,16 @@ function install_fm_common {
} }
function install_fm_mgr { function install_fm_mgr {
local x version pushd $STX_FAULT_DIR/fm-mgr/sources
local major minor version x
# get fm-mgr version # get fm-mgr version
read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/PKG-INFO) read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-mgr/PKG-INFO)
local major=${version%%.*} major=${version%%.*}
local minor=${version##*.} minor=${version##*.}
# build build_fm_mgr $major $minor
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/sources
make MAJOR=$major MINOR=$minor
# install # install
sudo make \ sudo make \

View File

@ -3,7 +3,7 @@
# devstack/plugin.sh # devstack/plugin.sh
# Triggers stx-fault specific functions to install and configure Fault Management # Triggers stx-fault specific functions to install and configure Fault Management
echo_summary "fault devstack plugin.sh called: $1/$2" echo_summary "stx-fault devstack plugin.sh called: $1/$2"
# check for service enabled # check for service enabled
if is_service_enabled stx-fault; then if is_service_enabled stx-fault; then

View File

@ -1,6 +1,14 @@
#!/bin/bash #!/bin/bash
# Devstack settings # Devstack settings
# Services
# stx-fault - Overall enable for this plugin
# fm-client
# fm-common
# fm-api
# fm-rest-api
# fm-mgr
# Defaults # Defaults
# -------- # --------
@ -8,9 +16,7 @@ STX_FAULT_NAME=stx-fault
######### Plugin Specific ########## ######### Plugin Specific ##########
enable_service $STX_FAULT_NAME enable_service $STX_FAULT_NAME
#define_plugin $STX_FAULT_NAME
# Handle STX pre-reqs
if is_service_enabled fm-rest-api; then if is_service_enabled fm-rest-api; then
enable_service tsconfig enable_service tsconfig
fi fi

View File

@ -86,6 +86,10 @@ commands =
sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
whitelist_externals = rm whitelist_externals = rm
[testenv:build]
deps =
commands = {toxinidir}/devstack/build.sh
[testenv:functional] [testenv:functional]
basepython = python3 basepython = python3
whitelist_externals = cat whitelist_externals = cat