blob: a84a06f1ce7cfe4d46082075a0ab3197dbe4ff22 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Sergey Lukjanov7ff84432014-03-10 20:04:51 +04003# lib/sahara
4
5# Dependencies:
6# ``functions`` file
7# ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
8
9# ``stack.sh`` calls the entry points in this order:
10#
11# install_sahara
Sergey Lukjanova90898d2014-08-05 16:14:12 +040012# install_python_saharaclient
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040013# configure_sahara
Andrew Lazarevb3130482014-12-16 14:36:59 -080014# sahara_register_images
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040015# start_sahara
16# stop_sahara
17# cleanup_sahara
18
19# Save trace setting
20XTRACE=$(set +o | grep xtrace)
21set +o xtrace
22
23
24# Defaults
25# --------
26
27# Set up default repos
Sergey Lukjanova90898d2014-08-05 16:14:12 +040028
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040029# Set up default directories
Sean Dagueee5ae7b2014-11-13 13:23:27 -050030GITDIR["python-saharaclient"]=$DEST/python-saharaclient
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040031SAHARA_DIR=$DEST/sahara
Sergey Lukjanova90898d2014-08-05 16:14:12 +040032
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040033SAHARA_CONF_DIR=${SAHARA_CONF_DIR:-/etc/sahara}
34SAHARA_CONF_FILE=${SAHARA_CONF_DIR}/sahara.conf
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040035
36SAHARA_SERVICE_HOST=${SAHARA_SERVICE_HOST:-$SERVICE_HOST}
37SAHARA_SERVICE_PORT=${SAHARA_SERVICE_PORT:-8386}
38SAHARA_SERVICE_PROTOCOL=${SAHARA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
39
40SAHARA_AUTH_CACHE_DIR=${SAHARA_AUTH_CACHE_DIR:-/var/cache/sahara}
41
Sergey Reshetnyak32ac55a2015-02-25 15:54:20 +030042SAHARA_ENABLED_PLUGINS=${SAHARA_ENABLED_PLUGINS:-vanilla,hdp,cdh,spark,fake}
Sergey Lukjanov10f41612014-04-25 11:42:41 +040043
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040044# Support entry points installation of console scripts
45if [[ -d $SAHARA_DIR/bin ]]; then
46 SAHARA_BIN_DIR=$SAHARA_DIR/bin
47else
48 SAHARA_BIN_DIR=$(get_python_exec_prefix)
49fi
50
51# Tell Tempest this project is present
52TEMPEST_SERVICES+=,sahara
53
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040054# Functions
55# ---------
56
57# create_sahara_accounts() - Set up common required sahara accounts
58#
59# Tenant User Roles
60# ------------------------------
61# service sahara admin
62function create_sahara_accounts {
63
Jamie Lennoxe8bc2b82015-02-10 20:38:56 +110064 create_service_user "sahara"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040065
66 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Bartosz Górski0abde392014-02-28 14:15:19 +010067
Dean Troyer16ef9762014-08-19 19:31:34 -050068 local sahara_service=$(get_or_create_service "sahara" \
Bartosz Górski0abde392014-02-28 14:15:19 +010069 "data_processing" "Sahara Data Processing")
Dean Troyer16ef9762014-08-19 19:31:34 -050070 get_or_create_endpoint $sahara_service \
Bartosz Górski0abde392014-02-28 14:15:19 +010071 "$REGION_NAME" \
72 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \
73 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \
74 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040075 fi
76}
77
78# cleanup_sahara() - Remove residual data files, anything left over from
79# previous runs that would need to clean up.
80function cleanup_sahara {
81
82 # Cleanup auth cache dir
83 sudo rm -rf $SAHARA_AUTH_CACHE_DIR
84}
85
86# configure_sahara() - Set config files, create data dirs, etc
87function configure_sahara {
88
89 if [[ ! -d $SAHARA_CONF_DIR ]]; then
90 sudo mkdir -p $SAHARA_CONF_DIR
91 fi
92 sudo chown $STACK_USER $SAHARA_CONF_DIR
93
Andrew Lazarev627ca742014-10-29 17:01:15 -070094 if [[ -f $SAHARA_DIR/etc/sahara/policy.json ]]; then
95 cp -p $SAHARA_DIR/etc/sahara/policy.json $SAHARA_CONF_DIR
96 fi
97
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040098 # Copy over sahara configuration file and configure common parameters.
Sergey Lukjanov51ebda62014-03-12 22:26:12 +040099 cp $SAHARA_DIR/etc/sahara/sahara.conf.sample $SAHARA_CONF_FILE
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400100
101 # Create auth cache dir
102 sudo mkdir -p $SAHARA_AUTH_CACHE_DIR
103 sudo chown $STACK_USER $SAHARA_AUTH_CACHE_DIR
Andrew Lazarev28d43922014-10-29 17:25:12 -0700104 sudo chmod 700 $SAHARA_AUTH_CACHE_DIR
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400105 rm -rf $SAHARA_AUTH_CACHE_DIR/*
106
Brant Knudson05952372014-09-19 17:22:22 -0500107 configure_auth_token_middleware $SAHARA_CONF_FILE sahara $SAHARA_AUTH_CACHE_DIR
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400108
Vitaly Gridneve50fcb12014-08-11 12:01:12 +0000109 # Set configuration to send notifications
110
111 if is_service_enabled ceilometer; then
112 iniset $SAHARA_CONF_FILE DEFAULT enable_notifications "true"
113 iniset $SAHARA_CONF_FILE DEFAULT notification_driver "messaging"
114 iniset_rpc_backend sahara $SAHARA_CONF_FILE DEFAULT
115 fi
116
Sergey Lukjanov3cd59e12014-03-25 00:06:31 +0400117 iniset $SAHARA_CONF_FILE DEFAULT verbose True
118 iniset $SAHARA_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400119
Sergey Lukjanov10f41612014-04-25 11:42:41 +0400120 iniset $SAHARA_CONF_FILE DEFAULT plugins $SAHARA_ENABLED_PLUGINS
121
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400122 iniset $SAHARA_CONF_FILE database connection `database_connection_url sahara`
123
124 if is_service_enabled neutron; then
125 iniset $SAHARA_CONF_FILE DEFAULT use_neutron true
126 iniset $SAHARA_CONF_FILE DEFAULT use_floating_ips true
Andrew Lazarev4f7e0f22015-02-06 16:16:01 -0800127
128 if is_ssl_enabled_service "neutron" || is_service_enabled tls-proxy; then
129 iniset $SAHARA_CONF_FILE neutron ca_file $SSL_BUNDLE_FILE
130 fi
Andrew Lazarev0943e072014-12-17 16:07:32 -0800131 else
132 iniset $SAHARA_CONF_FILE DEFAULT use_neutron false
133 iniset $SAHARA_CONF_FILE DEFAULT use_floating_ips false
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400134 fi
135
136 if is_service_enabled heat; then
137 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine heat
Andrew Lazarev4f7e0f22015-02-06 16:16:01 -0800138
139 if is_ssl_enabled_service "heat" || is_service_enabled tls-proxy; then
140 iniset $SAHARA_CONF_FILE heat ca_file $SSL_BUNDLE_FILE
141 fi
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400142 else
143 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine direct
144 fi
145
Andrew Lazarev4f7e0f22015-02-06 16:16:01 -0800146 if is_ssl_enabled_service "cinder" || is_service_enabled tls-proxy; then
147 iniset $SAHARA_CONF_FILE cinder ca_file $SSL_BUNDLE_FILE
148 fi
149
150 if is_ssl_enabled_service "nova" || is_service_enabled tls-proxy; then
151 iniset $SAHARA_CONF_FILE nova ca_file $SSL_BUNDLE_FILE
152 fi
153
154 if is_ssl_enabled_service "swift" || is_service_enabled tls-proxy; then
155 iniset $SAHARA_CONF_FILE swift ca_file $SSL_BUNDLE_FILE
156 fi
157
158 if is_ssl_enabled_service "key" || is_service_enabled tls-proxy; then
159 iniset $SAHARA_CONF_FILE keystone ca_file $SSL_BUNDLE_FILE
160 fi
161
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400162 iniset $SAHARA_CONF_FILE DEFAULT use_syslog $SYSLOG
163
Luigi Toscanob4bef1f2014-04-03 19:24:57 +0200164 # Format logging
165 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
166 setup_colorized_logging $SAHARA_CONF_FILE DEFAULT
167 fi
168
Ihar Hrachyshka157c84b2014-10-06 13:29:39 +0200169 recreate_database sahara
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400170 $SAHARA_BIN_DIR/sahara-db-manage --config-file $SAHARA_CONF_FILE upgrade head
171}
172
173# install_sahara() - Collect source and prepare
174function install_sahara {
175 git_clone $SAHARA_REPO $SAHARA_DIR $SAHARA_BRANCH
176 setup_develop $SAHARA_DIR
177}
178
Sergey Lukjanova90898d2014-08-05 16:14:12 +0400179# install_python_saharaclient() - Collect source and prepare
180function install_python_saharaclient {
Sean Dagueee5ae7b2014-11-13 13:23:27 -0500181 if use_library_from_git "python-saharaclient"; then
182 git_clone_by_name "python-saharaclient"
183 setup_dev_lib "python-saharaclient"
184 fi
Sergey Lukjanova90898d2014-08-05 16:14:12 +0400185}
186
Andrew Lazarevb3130482014-12-16 14:36:59 -0800187# sahara_register_images() - Registers images in sahara image registry
188function sahara_register_images {
189 if is_service_enabled heat && [[ ! -z "$HEAT_CFN_IMAGE_URL" ]]; then
190 # Register heat image for Fake plugin
191 local fake_plugin_properties="--property _sahara_tag_0.1=True"
192 fake_plugin_properties+=" --property _sahara_tag_fake=True"
193 fake_plugin_properties+=" --property _sahara_username=fedora"
194 openstack --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT image set $(basename "$HEAT_CFN_IMAGE_URL" ".qcow2") $fake_plugin_properties
195 fi
196}
197
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400198# start_sahara() - Start running processes, including screen
199function start_sahara {
Chris Dent2f27a0e2014-09-09 13:46:02 +0100200 run_process sahara "$SAHARA_BIN_DIR/sahara-all --config-file $SAHARA_CONF_FILE"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400201}
202
203# stop_sahara() - Stop running processes
204function stop_sahara {
205 # Kill the Sahara screen windows
Sean Dague9a413ab2015-02-04 12:44:18 -0500206 stop_process sahara
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400207}
208
209
210# Restore xtrace
211$XTRACE
212
213# Local variables:
214# mode: shell-script
215# End: