From b31bf2f86067c7f2218b26c94f351a1c542a96d4 Mon Sep 17 00:00:00 2001 From: "Chen, Haochuan Z" Date: Wed, 27 Feb 2019 12:19:01 +0800 Subject: [PATCH] [devstack] fmManager process launch * add cleanup for fm-api and fm-client * fmManager process launch including * 1, collate /etc/fm/fm.conf for fmManager * 2, create fm database * 3, create table event_suppression/alarm/event * with fm-dbsync --config-file /etc/fm/fm.conf * 4, update fm_db_sync_event_suppression.py install * for hardcode in fm-common/sources/fmConstants.h * 5, add event type file /etc/fm/events.yaml * 6, fmManager process launch Test case: $./stack.sh ========================= DevStack Component Timing (times are in seconds) ========================= run_process 21 test_with_retry 2 apt-get-update 9 pip_install 128 osc 143 wait_for_service 16 dbsync 20 apt-get 35 ------------------------- Unaccounted time 343 ========================= Total runtime 717 This is your host IP address: 192.168.122.80 This is your host IPv6 address: ::1 Horizon is now available at http://192.168.122.80/dashboard Keystone is serving at http://192.168.122.80/identity/ The default users are: admin and demo The password: secret Task: 23294 Story: 2003159 Depends-on: https://review.openstack.org/#/c/648119/ Depends-on: https://review.openstack.org/#/c/641710/ Change-Id: Icbbf4b57261ccd46c12cf765919e26c3916d0fc6 Signed-off-by: Martin, Chen --- devstack/lib/stx-fault | 53 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/devstack/lib/stx-fault b/devstack/lib/stx-fault index 58997364..988470f7 100644 --- a/devstack/lib/stx-fault +++ b/devstack/lib/stx-fault @@ -31,6 +31,7 @@ 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_EVENT_YAML=$STX_FAULT_CONF_DIR/events.yaml FM_RESTAPI_AUTH_CACHE_DIR=${FM_RESTAPI_AUTH_CACHE_DIR:-/var/cache/fault} FM_RESTAPI_DIR=$STX_FAULT_DIR/fm-rest-api/fm @@ -108,15 +109,29 @@ function build_fm_mgr { function cleanup_fault { stop_fault + if is_service_enabled fm-client || is_service_enabled fm-common; then + cleanup_fm_client + fi + if is_service_enabled fm-api; then + cleanup_fm_api + fi 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 + if is_service_enabled fm-common; then + cleanup_fm_common + fi +} + +function cleanup_fm_api { + sudo pip uninstall -y fm_api +} + +function cleanup_fm_client { + sudo pip uninstall -y fmclient } function cleanup_fm_common { @@ -128,6 +143,7 @@ function cleanup_fm_common { local minor=${version##*.} sudo rm /etc/ld.so.conf.d/stx-fault.conf + sudo pip uninstall -y fm-core pushd $STX_FAULT_DIR/fm-common/sources @@ -168,7 +184,10 @@ function cleanup_fm_mgr { } function cleanup_fm_rest_api { - sudo rm -rf $FM_RESTAPI_AUTH_CACHE_DIR $FM_RESTAPI_CONF + sudo pip uninstall -y fm + + sudo rm -rf $FM_RESTAPI_AUTH_CACHE_DIR $FM_RESTAPI_CONF $FM_RESTAPI_PASTE_INI $FM_EVENT_YAML + dropdb -h 127.0.0.1 -Uroot fm } function configure_fault { @@ -183,6 +202,7 @@ 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 + cp -p $STX_FAULT_DIR/fm-doc/fm_doc/events.yaml $FM_EVENT_YAML configure_auth_token_middleware $FM_RESTAPI_CONF fm $FM_RESTAPI_AUTH_CACHE_DIR @@ -204,6 +224,7 @@ function configure_fm_rest_api { 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 DEFAULT sql_connection $(database_connection_url fm) 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 @@ -235,6 +256,16 @@ function create_fault_user_group { function init_fault { create_fault_cache_dir + + if is_service_enabled fm-rest-api && is_service_enabled stx-config; then + init_rest_api + fi +} + +function init_rest_api { + # create db for fm + createdb -h 127.0.0.1 -Uroot -l C -T template0 -E utf8 fm + fm-dbsync --config-file $FM_RESTAPI_CONF } function install_fault { @@ -318,6 +349,12 @@ function install_fm_common { # TODO: this should be managed better echo $STX_INST_DIR/lib | sudo tee /etc/ld.so.conf.d/stx-fault.conf sudo ldconfig + + # in fm-common/sources/fmMsgServer.cpp,requst get "getaddrinfo(host.c_str()," + # hostname "controller" ip, so change hosname to controller + ADD_LINE="$HOST_IP controller" + grep "$ADD_LINE" /etc/hosts || sudo sed -i "/127.0.0.1 */a$ADD_LINE" /etc/hosts + popd } @@ -353,11 +390,17 @@ 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 + if is_service_enabled fm-mgr; then + run_process fm-mgr "$STX_BIN_DIR/fmManager start -c $FM_RESTAPI_CONF" + fi } function stop_fault { if is_service_enabled fm-rest-api; then - stop_process fm_api + stop_process fm-api + fi + if is_service_enabled fm-mgr; then + stop_process fm-mgr fi }