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 }