blob: 5c7c2534e252c1ee2bfc1dcc96ed382160191212 [file] [log] [blame]
Sergey Lukjanov7ff84432014-03-10 20:04:51 +04001# lib/sahara
2
3# Dependencies:
4# ``functions`` file
5# ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
6
7# ``stack.sh`` calls the entry points in this order:
8#
9# install_sahara
Sergey Lukjanova90898d2014-08-05 16:14:12 +040010# install_python_saharaclient
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040011# configure_sahara
12# start_sahara
13# stop_sahara
14# cleanup_sahara
15
16# Save trace setting
17XTRACE=$(set +o | grep xtrace)
18set +o xtrace
19
20
21# Defaults
22# --------
23
24# Set up default repos
25SAHARA_REPO=${SAHARA_REPO:-${GIT_BASE}/openstack/sahara.git}
26SAHARA_BRANCH=${SAHARA_BRANCH:-master}
27
Sergey Lukjanova90898d2014-08-05 16:14:12 +040028SAHARA_PYTHONCLIENT_REPO=${SAHARA_PYTHONCLIENT_REPO:-${GIT_BASE}/openstack/python-saharaclient.git}
29SAHARA_PYTHONCLIENT_BRANCH=${SAHARA_PYTHONCLIENT_BRANCH:-master}
30
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040031# Set up default directories
32SAHARA_DIR=$DEST/sahara
Sergey Lukjanova90898d2014-08-05 16:14:12 +040033SAHARA_PYTHONCLIENT_DIR=$DEST/python-saharaclient
34
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040035SAHARA_CONF_DIR=${SAHARA_CONF_DIR:-/etc/sahara}
36SAHARA_CONF_FILE=${SAHARA_CONF_DIR}/sahara.conf
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040037
38SAHARA_SERVICE_HOST=${SAHARA_SERVICE_HOST:-$SERVICE_HOST}
39SAHARA_SERVICE_PORT=${SAHARA_SERVICE_PORT:-8386}
40SAHARA_SERVICE_PROTOCOL=${SAHARA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
41
42SAHARA_AUTH_CACHE_DIR=${SAHARA_AUTH_CACHE_DIR:-/var/cache/sahara}
43
Sergey Lukjanov10f41612014-04-25 11:42:41 +040044SAHARA_ENABLED_PLUGINS=${SAHARA_ENABLED_PLUGINS:-vanilla,hdp,fake}
45
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040046# Support entry points installation of console scripts
47if [[ -d $SAHARA_DIR/bin ]]; then
48 SAHARA_BIN_DIR=$SAHARA_DIR/bin
49else
50 SAHARA_BIN_DIR=$(get_python_exec_prefix)
51fi
52
53# Tell Tempest this project is present
54TEMPEST_SERVICES+=,sahara
55
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040056# Functions
57# ---------
58
59# create_sahara_accounts() - Set up common required sahara accounts
60#
61# Tenant User Roles
62# ------------------------------
63# service sahara admin
64function create_sahara_accounts {
65
Dean Troyer16ef9762014-08-19 19:31:34 -050066 local service_tenant=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
67 local admin_role=$(openstack role list | awk "/ admin / { print \$2 }")
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040068
Dean Troyer16ef9762014-08-19 19:31:34 -050069 local sahara_user=$(get_or_create_user "sahara" \
70 "$SERVICE_PASSWORD" $service_tenant)
71 get_or_add_user_role $admin_role $sahara_user $service_tenant
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040072
73 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Bartosz Górski0abde392014-02-28 14:15:19 +010074
Dean Troyer16ef9762014-08-19 19:31:34 -050075 local sahara_service=$(get_or_create_service "sahara" \
Bartosz Górski0abde392014-02-28 14:15:19 +010076 "data_processing" "Sahara Data Processing")
Dean Troyer16ef9762014-08-19 19:31:34 -050077 get_or_create_endpoint $sahara_service \
Bartosz Górski0abde392014-02-28 14:15:19 +010078 "$REGION_NAME" \
79 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \
80 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \
81 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040082 fi
83}
84
85# cleanup_sahara() - Remove residual data files, anything left over from
86# previous runs that would need to clean up.
87function cleanup_sahara {
88
89 # Cleanup auth cache dir
90 sudo rm -rf $SAHARA_AUTH_CACHE_DIR
91}
92
93# configure_sahara() - Set config files, create data dirs, etc
94function configure_sahara {
95
96 if [[ ! -d $SAHARA_CONF_DIR ]]; then
97 sudo mkdir -p $SAHARA_CONF_DIR
98 fi
99 sudo chown $STACK_USER $SAHARA_CONF_DIR
100
101 # Copy over sahara configuration file and configure common parameters.
Sergey Lukjanov51ebda62014-03-12 22:26:12 +0400102 cp $SAHARA_DIR/etc/sahara/sahara.conf.sample $SAHARA_CONF_FILE
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400103
104 # Create auth cache dir
105 sudo mkdir -p $SAHARA_AUTH_CACHE_DIR
106 sudo chown $STACK_USER $SAHARA_AUTH_CACHE_DIR
107 rm -rf $SAHARA_AUTH_CACHE_DIR/*
108
Brant Knudson05952372014-09-19 17:22:22 -0500109 configure_auth_token_middleware $SAHARA_CONF_FILE sahara $SAHARA_AUTH_CACHE_DIR
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400110
Vitaly Gridneve50fcb12014-08-11 12:01:12 +0000111 # Set configuration to send notifications
112
113 if is_service_enabled ceilometer; then
114 iniset $SAHARA_CONF_FILE DEFAULT enable_notifications "true"
115 iniset $SAHARA_CONF_FILE DEFAULT notification_driver "messaging"
116 iniset_rpc_backend sahara $SAHARA_CONF_FILE DEFAULT
117 fi
118
Sergey Lukjanov3cd59e12014-03-25 00:06:31 +0400119 iniset $SAHARA_CONF_FILE DEFAULT verbose True
120 iniset $SAHARA_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400121
Sergey Lukjanov10f41612014-04-25 11:42:41 +0400122 iniset $SAHARA_CONF_FILE DEFAULT plugins $SAHARA_ENABLED_PLUGINS
123
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400124 iniset $SAHARA_CONF_FILE database connection `database_connection_url sahara`
125
126 if is_service_enabled neutron; then
127 iniset $SAHARA_CONF_FILE DEFAULT use_neutron true
128 iniset $SAHARA_CONF_FILE DEFAULT use_floating_ips true
129 fi
130
131 if is_service_enabled heat; then
132 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine heat
133 else
134 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine direct
135 fi
136
137 iniset $SAHARA_CONF_FILE DEFAULT use_syslog $SYSLOG
138
Luigi Toscanob4bef1f2014-04-03 19:24:57 +0200139 # Format logging
140 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
141 setup_colorized_logging $SAHARA_CONF_FILE DEFAULT
142 fi
143
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400144 recreate_database sahara utf8
145 $SAHARA_BIN_DIR/sahara-db-manage --config-file $SAHARA_CONF_FILE upgrade head
146}
147
148# install_sahara() - Collect source and prepare
149function install_sahara {
150 git_clone $SAHARA_REPO $SAHARA_DIR $SAHARA_BRANCH
151 setup_develop $SAHARA_DIR
152}
153
Sergey Lukjanova90898d2014-08-05 16:14:12 +0400154# install_python_saharaclient() - Collect source and prepare
155function install_python_saharaclient {
156 git_clone $SAHARA_PYTHONCLIENT_REPO $SAHARA_PYTHONCLIENT_DIR $SAHARA_PYTHONCLIENT_BRANCH
157 setup_develop $SAHARA_PYTHONCLIENT_DIR
158}
159
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400160# start_sahara() - Start running processes, including screen
161function start_sahara {
Chris Dent2f27a0e2014-09-09 13:46:02 +0100162 run_process sahara "$SAHARA_BIN_DIR/sahara-all --config-file $SAHARA_CONF_FILE"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400163}
164
165# stop_sahara() - Stop running processes
166function stop_sahara {
167 # Kill the Sahara screen windows
168 screen -S $SCREEN_NAME -p sahara -X kill
169}
170
171
172# Restore xtrace
173$XTRACE
174
175# Local variables:
176# mode: shell-script
177# End: