Set up the fault plugin

* Use stx-update and stx-integ plugins as-is
* Copy stx-fault here and validate running external plugins

Zuul jobs are stx-devstack-tis-base and stx-devstack-test1

Change-Id: I554b20d83dce8c0fbad67785bb04232be8c10183
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
This commit is contained in:
Dean Troyer 2019-03-04 14:17:44 -06:00
parent d513e5cb27
commit 818d513530
7 changed files with 566 additions and 3 deletions

View File

@ -1,3 +1,97 @@
- project:
templates:
- noop-jobs
check:
jobs:
- openstack-tox-linters
- stx-devstack-test1
gate:
jobs:
- openstack-tox-linters
- stx-devstack-test1
# This job is to begin testing a DevStack run here
- job:
name: stx-devstack-tis-base
nodeset: openstack-single-node-bionic
parent: devstack
description: |
Base job template for StarlingX DevStack tests
roles:
- zuul: openstack-infra/devstack
timeout: 9000
required-projects:
- name: git.openstack.org/openstack-dev/devstack
- name: git.openstack.org/openstack/keystone
- name: git.openstack.org/openstack/requirements
vars:
devstack_services:
# Turn off a number of upstream projects
# Ceilometer services
ceilometer-acentral: false
ceilometer-acompute: false
ceilometer-alarm-evaluator: false
ceilometer-alarm-notifier: false
ceilometer-anotification: false
ceilometer-api: false
ceilometer-collector: false
# Cinder services
c-api: false
c-bak: false
c-sch: false
c-vol: false
cinder: false
# Glance services
g-api: false
g-reg: false
# Horizon services
horizon: false
# Neutron services
q-agt: true
q-dhcp: false
q-l3: false
q-meta: false
q-metering: false
q-svc: false
# Nova services
n-api: false
n-api-meta: false
n-cauth: false
n-cond: false
n-cpu: false
n-novnc: false
n-obj: false
n-sch: false
placement-api: false
# Swift services
s-account: false
s-container: false
s-object: false
s-proxy: false
tempest: false
# Database
mysql: false
postgresql: true
devstack_localrc:
LIBS_FROM_GIT: keystone
FORCE: yes
- job:
name: stx-devstack-test1
parent: stx-devstack-tis-base
timeout: 7800
required-projects:
- name: openstack/stx-fault
- name: openstack/stx-integ
- name: openstack/stx-update
vars:
tox_envlist: functional
devstack_services:
fm-common: true
fm-api: true
fm-rest-api: true
fm-mgr: true
devstack_plugins:
stx-tis-repo: git://git.starlingx.io/stx-tis-repo
stx-integ: git://git.starlingx.io/stx-integ
stx-update: git://git.starlingx.io/stx-update
devstack_localrc:
LIBS_FROM_GIT: keystone

View File

@ -1,4 +1,12 @@
stx-tis-repo
============
Placeholder repo
This repo is being used for development of DevStack plugins
for StarlingX flock services. It is not used in the build
or operation of StarlingX in any way in spite of it having
that resembles a historical repo for this project.
The reason for doing this separate form the service plugins
is that there are some interesting dependencies between the
plugins and the base stx devstack job should be not in one of
the service repos.

354
devstack/lib/stx-fault Normal file
View File

@ -0,0 +1,354 @@
#!/bin/bash
#
# lib/stx-fault
# Functions to control the configuration and operation of the **fault** service
# Dependencies:
#
# - The stx-update plugin must be enabled
# ``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
# --------
STX_FAULT_DIR=${GITDIR[$STX_FAULT_NAME]}
STX_FAULT_CONF_DIR=/etc/fm
FM_RESTAPI_CONF=$STX_FAULT_CONF_DIR/fm.conf
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_DIR=$STX_FAULT_DIR/fm-rest-api/fm
if is_service_enabled tls-proxy; then
FM_RESTAPI_SERVICE_PROTOCOL="https"
fi
FM_RESTAPI_SERVICE_PROTOCOL=${FM_RESTAPI_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
FM_RESTAPI_SERVICE_HOST=${FM_RESTAPI_SERVICE_HOST:-$SERVICE_HOST}
FM_RESTAPI_SERVICE_PORT=${FM_RESTAPI_SERVICE_PORT:-18002}
FM_RESTAPI_WORKERS=${FM_RESTAPI_WORKERS:-4}
# STX_INST_DIR should be a non-root-writable place to install build artifacts
STX_INST_DIR=${STX_INST_DIR:-$DEST/usr}
STX_BIN_DIR=$STX_INST_DIR/bin
PYTHON_SITE_DIR=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
# 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
CPATH=$STX_INST_DIR/include LIBRARY_PATH=$STX_INST_DIR/lib make \
MAJOR=$major \
MINOR=$minor
popd
}
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
if is_service_enabled fm-rest-api; then
cleanup_fm_rest_api
fi
}
function cleanup_fm_common {
local x version
# get fm-common version
read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-common/PKG-INFO)
local major=${version%%.*}
local minor=${version##*.}
sudo rm /etc/ld.so.conf.d/stx-fault.conf
pushd $STX_FAULT_DIR/fm-common/sources
make \
DESTDIR=$STX_INST_DIR \
BINDIR=/bin \
LIBDIR=/lib \
INCDIR=/include \
MAJOR=$major \
MINOR=$minor \
clean
rm $STX_BIN_DIR/fm_db_sync_event_suppression.py \
$STX_INST_DIR/include/fmConfig.h \
$STX_INST_DIR/include/fmLog.h
popd
}
function cleanup_fm_mgr {
local x version
# get fm-mgr version
read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-mgr/PKG-INFO)
local major=${version%%.*}
local minor=${version##*.}
pushd $STX_FAULT_DIR/fm-mgr/sources
make \
DESTDIR=$STX_INST_DIR \
BINDIR=/bin \
MAJOR=$major \
MINOR=$minor \
clean
popd
}
function cleanup_fm_rest_api {
sudo rm -rf $FM_RESTAPI_AUTH_CACHE_DIR $FM_RESTAPI_CONF
}
function configure_fault {
if is_service_enabled fm-rest-api; then
configure_fm_rest_api
create_fault_user_group
create_fault_accounts
fi
}
function configure_fm_rest_api {
sudo install -d -o $STACK_USER -m 755 $STX_FAULT_CONF_DIR
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
iniset $FM_RESTAPI_CONF database connection $(database_connection_url fm)
iniset $FM_RESTAPI_CONF api api_paste_config $FM_RESTAPI_PASTE_INI
iniset $FM_RESTAPI_CONF api api_workers $FM_RESTAPI_WORKERS
iniset $FM_RESTAPI_CONF api bind_host $FM_RESTAPI_SERVICE_HOST
iniset $FM_RESTAPI_CONF api bind_port $FM_RESTAPI_SERVICE_PORT
iniset $FM_RESTAPI_CONF oslo_middleware enable_proxy_headers_parsing True
if [ "$SYSLOG" != "False" ]; then
iniset $FM_RESTAPI_CONF DEFAULT use_syslog True
# stx specific?
iniset $FM_RESTAPI_CONF DEFAULT syslog_log_facility local2
fi
# Additional things set in stx config
iniset $FM_RESTAPI_CONF DEFAULT region_name RegionOne
iniset $FM_RESTAPI_CONF DEFAULT event_log_max_size 4000
iniset $FM_RESTAPI_CONF DEFAULT system_name $(hostname)
iniset $FM_RESTAPI_CONF database idle_timeout 60
iniset $FM_RESTAPI_CONF database max_pool_size 1
iniset $FM_RESTAPI_CONF database max_overflow 20
iniset $FM_RESTAPI_CONF keystone_authtoken region_name RegionOne
# sysinv settings to move there...
iniset $FM_RESTAPI_CONF sysinv catalog_info platform:sysinv:internalURL
iniset $FM_RESTAPI_CONF sysinv os_region_name RegionOne
}
function create_fault_accounts {
create_service_user "fm"
get_or_create_service "fm" "faultmanagement" "Fault Management Service"
get_or_create_endpoint \
"faultmanagement" \
"$REGION_NAME" \
"$FM_RESTAPI_SERVICE_PROTOCOL://$FM_RESTAPI_SERVICE_HOST:$FM_RESTAPI_SERVICE_PORT/v1"
}
function create_fault_cache_dir {
# Create cache dir
sudo install -d -o $STACK_USER $FM_RESTAPI_AUTH_CACHE_DIR
rm -f $FM_RESTAPI_AUTH_CACHE_DIR/*
}
function create_fault_user_group {
:
}
function init_fault {
create_fault_cache_dir
}
function install_fault {
if is_service_enabled fm-common; then
install_fm_common
fi
if is_service_enabled fm-client || is_service_enabled fm-common; then
install_fm_client
fi
if is_service_enabled fm-api; then
install_fm_api
fi
if is_service_enabled fm-mgr; then
install_fm_mgr
fi
if is_service_enabled fm-rest-api && is_service_enabled stx-config; then
install_fm_rest_api
fi
}
function install_fm_api {
pushd $STX_FAULT_DIR/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_client {
pushd $STX_FAULT_DIR/python-fmclient/fmclient
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 {
pushd $STX_FAULT_DIR/fm-common/sources
local major minor version x
# get fm-common version
read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-common/PKG-INFO)
major=${version%%.*}
minor=${version##*.}
build_fm_common $major $minor
# install to STX_INST_DIR
# Note that DESTDIR prefixes the other locations in the Makefile
make \
DESTDIR=$STX_INST_DIR \
BINDIR=/bin \
LIBDIR=/lib \
INCDIR=/include \
MAJOR=$major \
MINOR=$minor \
install
sudo python setup.py install \
--root=/ \
--install-lib=$PYTHON_SITE_DIR \
--prefix=/usr \
--install-data=/usr/share \
# This _is_ still a little nasty, clean it up
install -m 755 fm_db_sync_event_suppression.py \
$STX_INST_DIR/bin/fm_db_sync_event_suppression.py
# install the headers that used by fm-mgr package
install -m 644 -p -D fmConfig.h $STX_INST_DIR/include/fmConfig.h
install -m 644 -p -D fmLog.h $STX_INST_DIR/include/fmLog.h
# Make sure we can find it later
# TODO: this should be managed better
echo $STX_INST_DIR/lib | sudo tee /etc/ld.so.conf.d/stx-fault.conf
sudo ldconfig
popd
}
function install_fm_mgr {
pushd $STX_FAULT_DIR/fm-mgr/sources
local major minor version x
# get fm-mgr version
read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-mgr/PKG-INFO)
major=${version%%.*}
minor=${version##*.}
build_fm_mgr $major $minor
# install to STX_INST_DIR
# Note that DESTDIR prefixes the other locations in the Makefile
make \
DESTDIR=$STX_INST_DIR \
BINDIR=/bin \
MAJOR=$major \
MINOR=$minor \
install
popd
}
function install_fm_rest_api {
setup_develop $FM_RESTAPI_DIR
}
function start_fault {
if is_service_enabled fm-rest-api; then
run_process fm-api "$STX_BIN_DIR/fm-api --config-file $FM_RESTAPI_CONF"
fi
}
function stop_fault {
if is_service_enabled fm-rest-api; then
stop_process fm_api
fi
}
$_XTRACE_STX_FAULT

44
devstack/plugin.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
# devstack/plugin.sh
# Triggers specific functions to install and configure stx-integ
echo_summary "$STX_TIS_NAME devstack plugin.sh called: $1/$2"
# check for service enabled
if is_service_enabled $STX_TIS_NAME; then
if [[ "$1" == "stack" && "$2" == "install" ]]; then
# Perform installation of source
echo_summary "Install $STX_TIS_NAME"
install_fault
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
# Configure after the other layer 1 and 2 services have been configured
echo_summary "Configure $STX_TIS_NAME"
configure_fault
create_fault_user_group
create_fault_accounts
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
# Initialize and start the service
echo_summary "Initialize and start $STX_TIS_NAME"
init_fault
start_fault
elif [[ "$1" == "stack" && "$2" == "test-config" ]]; then
# do sanity test
echo_summary "test-config $STX_TIS_NAME"
fi
if [[ "$1" == "unstack" ]]; then
# Shut down services
echo_summary "Stop $STX_TIS_NAME"
stop_fault
fi
if [[ "$1" == "clean" ]]; then
echo_summary "Clean $STX_TIS_NAME"
cleanup_fault
fi
fi

27
devstack/settings Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Devstack settings
# This must not use any variables to work properly in OpenStack's DevStack playbook
define_plugin stx-tis-repo
# This works for Zuul jobs using OpenStack's DevStack roles
plugin_requires stx-tis-repo stx-update
plugin_requires stx-tis-repo stx-integ
STX_TIS_NAME=stx-tis-repo
enable_service $STX_TIS_NAME
# Settings for stx-fault
# Circular dependencies are fun!
# fm-rest-api has an undeclared dependency on cgtsclient from stx-config
# so if that is not present we can't install it
if ! is_service_enabled stx-config; then
disable_service fm-rest-api
fi
# but fm-rest-api has its own (declared!) external dependencies too
if is_service_enabled fm-rest-api; then
# stx-update
enable_service tsconfig
fi
# Initial source of lib script
source $DEST/stx-fault/devstack/lib/stx-fault

2
test-requirements.txt Normal file
View File

@ -0,0 +1,2 @@
hacking!=0.13.0,<0.14,>=0.12.0
bashate >= 0.2

34
tox.ini Normal file
View File

@ -0,0 +1,34 @@
[tox]
envlist = linters
minversion = 2.3
skipsdist = True
[testenv]
install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
deps = -r{toxinidir}/test-requirements.txt
[testenv:linters]
whitelist_externals = bash
# Ignore bashate:
# - E006 Line too long
commands =
bash -c "find {toxinidir} \
-not \( -type d -name .?\* -prune \) \
-type f \
-not -name \*~ \
-not -name \*.md \
\( \
-name \*.sh \
-or -not -wholename \*/devstack/files/\* \
-wholename \*/devstack/\* \
\) \
-print0 | xargs -0 bashate -v -iE006"
[testenv:functional]
basepython = python3
whitelist_externals = cat
commands = cat /etc/group