Add DevStack support for FM dependencies
Add a DevStack plugin to build and install the basic Fault dependencies required by most of the other STX projects. The bulk of this was originally submitted in https://review.openstack.org/#/c/595865/. Installing and starting the REST API service will follow in a later review. Also enable bashate on the devstack plugin and max yaml line length set to 260 Change-Id: I95009fceee28a81e6d8795e90b259e0e1b175327 Signed-off-by: Dean Troyer <dtroyer@gmail.com>
This commit is contained in:
parent
62431965cd
commit
e207777eda
231
devstack/lib/stx-fault
Normal file
231
devstack/lib/stx-fault
Normal file
@ -0,0 +1,231 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# lib/stx-fault
|
||||
# Functions to control the configuration and operation of the **fault** service
|
||||
|
||||
# Dependencies:
|
||||
#
|
||||
# - ``functions`` file
|
||||
# - ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
|
||||
# - ``SERVICE_{TENANT_NAME|PASSWORD}`` must be defined
|
||||
# - ``SERVICE_HOST``
|
||||
# - ``KEYSTONE_TOKEN_FORMAT`` must be defined
|
||||
|
||||
# ``stack.sh`` calls the entry points in this order:
|
||||
#
|
||||
# - install_fault
|
||||
# - configure_fault
|
||||
# - init_fault
|
||||
# - start_fault
|
||||
# - stop_fault
|
||||
# - cleanup_fault
|
||||
|
||||
_XTRACE_STX_FAULT=$(set +o | grep xtrace)
|
||||
set -o xtrace
|
||||
|
||||
|
||||
# Defaults
|
||||
# --------
|
||||
|
||||
PYTHON_BIN_DIR=$(get_python_exec_prefix)
|
||||
PYTHON_SITE_DIR=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
|
||||
|
||||
# Functions
|
||||
# ---------
|
||||
|
||||
function cleanup_fault {
|
||||
stop_fault
|
||||
|
||||
if is_service_enabled fm-mgr; then
|
||||
cleanup_fm_mgr
|
||||
fi
|
||||
if is_service_enabled fm-common; then
|
||||
cleanup_fm_common
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanup_fm_common {
|
||||
local x version
|
||||
|
||||
# get fm-common version
|
||||
read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-common/PKG-INFO)
|
||||
local major=${version%%.*}
|
||||
local minor=${version##*.}
|
||||
local prefix=${PYTHON_BIN_DIR%/*}
|
||||
|
||||
sudo rm /etc/ld.so.conf.d/stx-fault.conf
|
||||
|
||||
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-common/sources
|
||||
|
||||
sudo make \
|
||||
DEST_DIR=$prefix \
|
||||
BIN_DIR=/bin \
|
||||
LIB_DIR=/lib \
|
||||
INC_DIR=/include \
|
||||
MAJOR=$major \
|
||||
MINOR=$minor \
|
||||
clean
|
||||
|
||||
sudo rm $prefix/bin/fm_db_sync_event_suppression.py \
|
||||
$prefix/include/fmConfig.h \
|
||||
$prefix/include/fmLog.h
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
function cleanup_fm_mgr {
|
||||
local x version
|
||||
|
||||
# get fm-mgr version
|
||||
read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/PKG-INFO)
|
||||
local major=${version%%.*}
|
||||
local minor=${version##*.}
|
||||
|
||||
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/sources
|
||||
|
||||
sudo make \
|
||||
BIN_DIR=/bin \
|
||||
LIB_DIR=/lib \
|
||||
INC_DIR=/include \
|
||||
MAJOR=$major \
|
||||
MINOR=$minor \
|
||||
clean
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
function configure_fault {
|
||||
:
|
||||
}
|
||||
|
||||
function create_fault_accounts {
|
||||
:
|
||||
}
|
||||
|
||||
function create_fault_cache_dir {
|
||||
:
|
||||
}
|
||||
|
||||
function create_fault_user_group {
|
||||
:
|
||||
}
|
||||
|
||||
function init_fault {
|
||||
:
|
||||
}
|
||||
|
||||
function install_fault {
|
||||
if is_service_enabled fm-common; then
|
||||
install_fm_common
|
||||
fi
|
||||
if is_service_enabled fm-api; then
|
||||
install_fm_api
|
||||
fi
|
||||
if is_service_enabled fm-rest-api; then
|
||||
install_fm_api
|
||||
fi
|
||||
if is_service_enabled fm-mgr; then
|
||||
install_fm_mgr
|
||||
fi
|
||||
}
|
||||
|
||||
function install_fm_api {
|
||||
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-api
|
||||
sudo python setup.py install \
|
||||
--root=/ \
|
||||
--install-lib=$PYTHON_SITE_DIR \
|
||||
--prefix=/usr \
|
||||
--install-data=/usr/share \
|
||||
--single-version-externally-managed
|
||||
popd
|
||||
}
|
||||
|
||||
function install_fm_common {
|
||||
local x version
|
||||
|
||||
# get fm-common version
|
||||
read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-common/PKG-INFO)
|
||||
local major=${version%%.*}
|
||||
local minor=${version##*.}
|
||||
|
||||
# Set up the destinations
|
||||
# Making an assumption here about PYTHON_BIN_DIR having ../include be valid
|
||||
local prefix=${PYTHON_BIN_DIR%/*}
|
||||
|
||||
# build
|
||||
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-common/sources
|
||||
make MAJOR=$major MINOR=$minor
|
||||
sudo python setup.py build
|
||||
|
||||
# install
|
||||
sudo make \
|
||||
DEST_DIR=$prefix \
|
||||
BIN_DIR=/bin \
|
||||
LIB_DIR=/lib \
|
||||
INC_DIR=/include \
|
||||
MAJOR=$major \
|
||||
MINOR=$minor \
|
||||
install_non_bb
|
||||
|
||||
sudo python setup.py install \
|
||||
--root=/ \
|
||||
--install-lib=$PYTHON_SITE_DIR \
|
||||
--prefix=/usr \
|
||||
--install-data=/usr/share \
|
||||
|
||||
# This _is_ nasty, clean it up
|
||||
sudo install -m 755 fm_db_sync_event_suppression.py \
|
||||
$prefix/bin/fm_db_sync_event_suppression.py
|
||||
|
||||
# install the headers that used by fm-mgr package
|
||||
sudo install -m 644 -p -D fmConfig.h $prefix/include/fmConfig.h
|
||||
sudo install -m 644 -p -D fmLog.h $prefix/include/fmLog.h
|
||||
|
||||
# Make sure we can find it later
|
||||
# TODO: this should be managed better
|
||||
echo /usr/local/lib | sudo tee /etc/ld.so.conf.d/stx-fault.conf
|
||||
sudo ldconfig
|
||||
popd
|
||||
}
|
||||
|
||||
function install_fm_mgr {
|
||||
local x version
|
||||
|
||||
# get fm-mgr version
|
||||
read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/PKG-INFO)
|
||||
local major=${version%%.*}
|
||||
local minor=${version##*.}
|
||||
|
||||
# build
|
||||
pushd ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/sources
|
||||
make MAJOR=$major MINOR=$minor
|
||||
|
||||
# install
|
||||
sudo make \
|
||||
BIN_DIR=/bin \
|
||||
LIB_DIR=/lib \
|
||||
INC_DIR=/include \
|
||||
MAJOR=$major \
|
||||
MINOR=$minor \
|
||||
install_non_bb
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
function install_fm_rest_api {
|
||||
:
|
||||
}
|
||||
|
||||
function start_fault {
|
||||
:
|
||||
}
|
||||
|
||||
function stop_fault {
|
||||
:
|
||||
}
|
||||
|
||||
function stop_fault_api {
|
||||
:
|
||||
}
|
||||
|
||||
$_XTRACE_STX_FAULT
|
2
devstack/override-defaults
Normal file
2
devstack/override-defaults
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
# Plug-in overrides
|
50
devstack/plugin.sh
Executable file
50
devstack/plugin.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# devstack/plugin.sh
|
||||
# Triggers stx_fault specific functions to install and configure Fault Management
|
||||
|
||||
# Dependencies:
|
||||
#
|
||||
# - ``functions`` file
|
||||
# - ``DATA_DIR`` must be defined
|
||||
|
||||
# ``stack.sh`` calls the entry points in this order:
|
||||
#
|
||||
echo_summary "fault devstack plugin.sh called: $1/$2"
|
||||
source $DEST/stx-fault/devstack/lib/stx-fault
|
||||
|
||||
# check for service enabled
|
||||
if [[ ,${ENABLED_SERVICES} =~ ,"fm-" ]]; then
|
||||
if [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
# Perform installation of source
|
||||
echo_summary "Installing fault service"
|
||||
install_fault
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||
# Configure after the other layer 1 and 2 services have been configured
|
||||
echo_summary "Configuring fault"
|
||||
configure_fault
|
||||
create_fault_user_group
|
||||
create_fault_accounts
|
||||
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
|
||||
# Initialize and start the service
|
||||
echo_summary "Initializing and start fault"
|
||||
init_fault
|
||||
start_fault
|
||||
elif [[ "$1" == "stack" && "$2" == "test-config" ]]; then
|
||||
# do sanity test
|
||||
echo_summary "do test-config"
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
# Shut down services
|
||||
echo_summary "Stop fault service"
|
||||
stop_fault
|
||||
:
|
||||
fi
|
||||
|
||||
if [[ "$1" == "clean" ]]; then
|
||||
cleanup_fault
|
||||
:
|
||||
fi
|
||||
fi
|
11
devstack/settings
Normal file
11
devstack/settings
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# Devstack settings
|
||||
|
||||
# Defaults
|
||||
# --------
|
||||
|
||||
STX_FAULT_NAME=stx-fault
|
||||
|
||||
######### Plugin Specific ##########
|
||||
enable_service $STX_FAULT_NAME fm-common fm-api fm-rest-api fm-mgr
|
||||
#define_plugin $STX_FAULT_NAME
|
12
tox.ini
12
tox.ini
@ -20,13 +20,15 @@ commands =
|
||||
-type f \
|
||||
-not -name \*~ \
|
||||
-not -name \*.md \
|
||||
-name \*.sh \
|
||||
-print0 | xargs --no-run-if-empty -0 bashate -v"
|
||||
\( \
|
||||
-name \*.sh \
|
||||
-or -wholename \*/devstack/\* \
|
||||
\) \
|
||||
-print0 | xargs -0 bashate -v -iE006"
|
||||
bash -c "find {toxinidir} \
|
||||
\( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \
|
||||
-o \( -name .tox -prune \) \
|
||||
\( -name .tox -prune \) \
|
||||
-o -type f -name '*.yaml' \
|
||||
-print0 | xargs -0 yamllint -d '\{extends: relaxed, rules: \{line-length: \{max: 120\}\}\}'"
|
||||
-print0 | xargs -0 yamllint -d '\{extends: relaxed, rules: \{line-length: \{max: 260\}\}\}'"
|
||||
|
||||
####
|
||||
# Add flake8 as pep8 codestyle check.
|
||||
|
Loading…
Reference in New Issue
Block a user