Create devstack plugin for osprofiler configuration
[doctor.git] / devstack / plugin.sh
1 #!/usr/bin/env bash
2
3 ##############################################################################
4 # Copyright (c) 2017 ZTE Corporation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 # Defaults
13 # --------
14
15 CONF_FILES=(
16     $CINDER_CONF
17     $HEAT_CONF
18     $KEYSTONE_CONF
19     $NOVA_CONF
20     $NEUTRON_CONF
21     $GLANCE_API_CONF
22     $GLANCE_REGISTRY_CONF
23 # Supported by osprofiler but not used in doctor at the moment
24 #    $TROVE_CONF
25 #    $TROVE_CONDUCTOR_CONF
26 #    $TROVE_GUESTAGENT_CONF
27 #    $TROVE_TASKMANAGER_CONF
28 #    $SENLIN_CONF
29 #    $MAGNUM_CONF
30 #    $ZUN_CONF
31 )
32
33 function install_doctor {
34     # no-op
35     :
36 }
37
38 function configure_doctor {
39     for conf in ${CONF_FILES[@]}; do
40         if [ -f $conf ]
41         then
42             iniset $conf profiler enabled true
43             iniset $conf profiler trace_sqlalchemy true
44             iniset $conf profiler hmac_keys $(iniget $conf profiler hmac_keys),${DOCTOR_HMAC_KEYS:=doctor}
45             iniset $conf profiler connection_string ${OSPROFILER_CONNECTION_STRING:=redis://127.0.0.1:6379}
46         fi
47     done
48 }
49
50 function init_doctor {
51     # no-op
52     :
53 }
54
55 # check for service enabled
56 if is_service_enabled doctor; then
57
58     if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
59         # Set up system services
60         echo_summary "Configuring system services Doctor"
61         # install_package cowsay
62
63     elif [[ "$1" == "stack" && "$2" == "install" ]]; then
64         # Perform installation of service source
65         echo_summary "Installing Doctor"
66         install_doctor
67
68     elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
69         # Configure after the other layer 1 and 2 services have been configured
70         echo_summary "Configuring Doctor"
71         configure_doctor
72
73     elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
74         # Initialize and start the doctor service
75         echo_summary "Initializing Doctor"
76         init_doctor
77     fi
78
79     if [[ "$1" == "unstack" ]]; then
80         # Shut down doctor services
81         # no-op
82         :
83     fi
84
85     if [[ "$1" == "clean" ]]; then
86         # Remove state and transient data
87         # Remember clean.sh first calls unstack.sh
88         # no-op
89         :
90     fi
91 fi
92