blob: 70319d9f2a109f413d97a9277d7815f2c83df546 [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
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400109 # Set actual keystone auth configs
110 iniset $SAHARA_CONF_FILE keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/
Sergey Lukjanov65dabd32014-04-22 18:37:45 +0400111 iniset $SAHARA_CONF_FILE keystone_authtoken auth_host $KEYSTONE_AUTH_HOST
112 iniset $SAHARA_CONF_FILE keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
113 iniset $SAHARA_CONF_FILE keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400114 iniset $SAHARA_CONF_FILE keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
115 iniset $SAHARA_CONF_FILE keystone_authtoken admin_user sahara
116 iniset $SAHARA_CONF_FILE keystone_authtoken admin_password $SERVICE_PASSWORD
117 iniset $SAHARA_CONF_FILE keystone_authtoken signing_dir $SAHARA_AUTH_CACHE_DIR
118 iniset $SAHARA_CONF_FILE keystone_authtoken cafile $KEYSTONE_SSL_CA
119
Vitaly Gridneve50fcb12014-08-11 12:01:12 +0000120 # Set configuration to send notifications
121
122 if is_service_enabled ceilometer; then
123 iniset $SAHARA_CONF_FILE DEFAULT enable_notifications "true"
124 iniset $SAHARA_CONF_FILE DEFAULT notification_driver "messaging"
125 iniset_rpc_backend sahara $SAHARA_CONF_FILE DEFAULT
126 fi
127
Sergey Lukjanov3cd59e12014-03-25 00:06:31 +0400128 iniset $SAHARA_CONF_FILE DEFAULT verbose True
129 iniset $SAHARA_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400130
Sergey Lukjanov10f41612014-04-25 11:42:41 +0400131 iniset $SAHARA_CONF_FILE DEFAULT plugins $SAHARA_ENABLED_PLUGINS
132
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400133 iniset $SAHARA_CONF_FILE database connection `database_connection_url sahara`
134
135 if is_service_enabled neutron; then
136 iniset $SAHARA_CONF_FILE DEFAULT use_neutron true
137 iniset $SAHARA_CONF_FILE DEFAULT use_floating_ips true
138 fi
139
140 if is_service_enabled heat; then
141 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine heat
142 else
143 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine direct
144 fi
145
146 iniset $SAHARA_CONF_FILE DEFAULT use_syslog $SYSLOG
147
Luigi Toscanob4bef1f2014-04-03 19:24:57 +0200148 # Format logging
149 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
150 setup_colorized_logging $SAHARA_CONF_FILE DEFAULT
151 fi
152
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400153 recreate_database sahara utf8
154 $SAHARA_BIN_DIR/sahara-db-manage --config-file $SAHARA_CONF_FILE upgrade head
155}
156
157# install_sahara() - Collect source and prepare
158function install_sahara {
159 git_clone $SAHARA_REPO $SAHARA_DIR $SAHARA_BRANCH
160 setup_develop $SAHARA_DIR
161}
162
Sergey Lukjanova90898d2014-08-05 16:14:12 +0400163# install_python_saharaclient() - Collect source and prepare
164function install_python_saharaclient {
165 git_clone $SAHARA_PYTHONCLIENT_REPO $SAHARA_PYTHONCLIENT_DIR $SAHARA_PYTHONCLIENT_BRANCH
166 setup_develop $SAHARA_PYTHONCLIENT_DIR
167}
168
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400169# start_sahara() - Start running processes, including screen
170function start_sahara {
Sergey Lukjanov850e0fb2014-05-03 00:53:01 +0400171 screen_it sahara "cd $SAHARA_DIR && $SAHARA_BIN_DIR/sahara-all --config-file $SAHARA_CONF_FILE"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400172}
173
174# stop_sahara() - Stop running processes
175function stop_sahara {
176 # Kill the Sahara screen windows
177 screen -S $SCREEN_NAME -p sahara -X kill
178}
179
180
181# Restore xtrace
182$XTRACE
183
184# Local variables:
185# mode: shell-script
186# End: